rgb

Extracting the RGB value from a string

瘦欲@ 提交于 2020-01-14 06:56:50
问题 How would I extract the RBG value from the following string?: let string = "<span style=\"background-color: rgb(230, 0, 0);\"> I would like to get extract "rgb(230, 0, 0)" from the background-color value, so I can convert it to a hex string and update some UI. let range = string.range(of: "\"background-color: ") let startPoint = range.location + range.length let subString = string.substring(from: startPoint) //generating error claiming 'cannot convert value of type 'int' to expected argument

Get background-color in #000 format and not RGB [duplicate]

我怕爱的太早我们不能终老 提交于 2020-01-12 08:04:22
问题 This question already has answers here : How to get hex color value rather than RGB value? (18 answers) Closed 6 years ago . With this code, I get the RGB color of any TD in my table : alert($(this).css('background-color')); the result is : rgb(0, 255, 0) Is it possible with jquery to obtain the #000 format or have I to use a function to transform the rgb in #000 format ? Thanks in advance for your help 回答1: Try var color = ''; $('div').click(function() { var hexcolor = $(this).css(

How can I know if a given string is hex, rgb, rgba or hsl color using javascript/jquery?

陌路散爱 提交于 2020-01-12 07:41:09
问题 I used regex for the hex. /^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/ but I dont know what I should for do for finding rgb, rgba and hsl. I am getting the input in string. For example, the input will contain "rgb(0,0,0)"or "rgb(0,0,0,0.2)". 回答1: There are different options here: 1. Use a dummy element Use the browser's validation. Create a dummy HTML element, assign the color and check if it's set. This is by far the best option. It's not only easier, but it will also allow forward compatibility.

Algorithm for Hue/Saturation Adjustment Layer from Photoshop

蹲街弑〆低调 提交于 2020-01-11 15:38:05
问题 Does anyone know how adjustment layers work in Photoshop? I need to generate a result image having a source image and HSL values from Hue/Saturation adjustment layer. Conversion to RGB and then multiplication with the source color does not work. Or is it possible to replace Hue/Saturation Adjustment Layer with normal layers with appropriately set blending modes (Mulitiply, Screen, Hue, Saturation, Color, Luminocity,...)? If so then how? Thanks 回答1: I've reverse-engineered the computation for

Image binary interpretation: unknown image format

℡╲_俬逩灬. 提交于 2020-01-11 14:27:08
问题 Let's say I've got an image of some format (its binary representation, say, cv::Mat from OpenCV or YuvImage from Android, not compressed), and interpreted its data as YUV NV21 (well, this was in example provided by DJI SDK, pretty much it). Here's what I've got: From this, I assume that original format is NOT NV21. YUV2? RGB888? RGB32? Some other stuff? How would one guess what's the original format of the binary data? If that'll help, frame is taken from DJI drone stream. 回答1: The YUV image

RGBA format HEX into RGB format HEX? PHP

时光怂恿深爱的人放手 提交于 2020-01-11 07:56:08
问题 I want to convert back and forth between RGBA-formated HEX colors (like 0xFF0000FF ) and RGB-formated HEX colors (like 0xFF0000 ) in PHP. How can I do this? 回答1: How about these: function rgbaToRgb ($rgba, $blend = 0xFFFFFF) { return (($rgba >> 8)*($rgba & 0xFF)/0xFF) * ($blend / 0xFFFFFF); } function rgbToRgba ($rgb) { return ($rgb << 8) | 0xFF; } $blend in the first is effectively a background color to blend with. Edit: fix due to not enough space in ints ruining RGBA. RGBA is now handled

All RGB colors combinations in Javascript

只谈情不闲聊 提交于 2020-01-09 23:56:19
问题 I want all RGB colors in Javascript. I have made this schema; R G B 0 0 0 255 255 255 0 255 255 255 0 255 255 255 0 0 255 0 0 0 255 255 0 0 And I made this in Javascript: click Do I have now all possible combinations with the RGB colors? 回答1: If you want to iterate through all 16,777,216 possible 24-bit RGB colours, this can be achieved quite simply with one loop: for( i=0; i < 1<<24; i++) { r = (i>>16) & 0xff; g = (i>>8) & 0xff; b = i & 0xff; colour = "rgb("+r+","+g+","+b+")"; } In your code

视频监控之颜色模型——RGB、HSV模型

∥☆過路亽.° 提交于 2020-01-07 12:35:40
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 目前常用的颜色模型可分为两类,一类面向诸如彩色显示器或打印机之类的硬件设备,另一类面向以彩色处理为目的的应用,如动画中的彩色图形。面向硬件设备的最常用彩色模型是 RGB 模型,而面向彩色处理的最常用的模型是 HSV 模型,其中 H表示色调(Hue),S 表示饱和度(Saturation),V 表示亮度(Value)。 RGB颜色模型 RGB 颜色模型由红、绿、蓝三种基色组成,它大多用于 CRT 显示器和颜色光栅图形。这个模型基于笛卡儿坐标系统,3 个轴分别为 R,G,B。通过红、绿、蓝三种基色可以混合得到大多数的颜色。如下图所示: 坐标原点代表(0,0,0)黑色,而坐标点(1,1,1)代表白色。坐标轴上的顶点代表三个基色,而余下的顶点则代表第一个基色的补色。为方便表示,将立方体归一化为单位立方体,这样所有的 R,G,B 的值都在[0,1]中。根据这个模型,每幅彩色图像包括3个独立的基色平面,或者说可分解到 3 个平面上。反过来如果一幅图像可被表示为 3个平面,使用这个模型比较方便。 HSV颜色模型 在 HSV 模型中,亮度(V)是光作用于人眼时所引起的明亮程度的感觉,它与被观察物体的发光强度有关。色调(H)是当人眼看到一种或多种波长的光时所产生的彩色感觉,它反映颜色的种类,是决定颜色的基本特性,如红色

Array of all RGB permutations in PHP

让人想犯罪 __ 提交于 2020-01-07 04:33:09
问题 I am trying to make an array of all the possible colours made out of RGB values. Every permutation between r=0 b=0 g=0 to r=255 b=255 g=255. The idea of my function is that when it's called you supply a limit number so that the function returns an array of RGB values up to this number to stop it returning all 16 million. The code I have below returns 767 permutations (256 * 3) how do I get this to return the full 16 million up to the limit number I provide? function colourArray($number) { $r

How to make a binary image with python?

别来无恙 提交于 2020-01-07 03:16:30
问题 I built my image with cv2.THRESH_BINARY and the function ret, im_thresh = cv2.threshold( gray_image, 40, 255, cv2.THRESH_BINARY ) BUT White must be 1 to Work with my program. To help I made: height = int(np.size(im_thresh, 0)) width = int(np.size(im_thresh, 1)) for x in range(height): for y in range(width): if im_thresh[x,y]==255: im_thresh[x,y] = 1 My question: Have any way to do this faster in python? 回答1: Try using a boolean index to get and set the values of the arrays, which avoids the