rgba

How to convert an RGBA image to Grayscale in python?

落花浮王杯 提交于 2019-12-24 02:21:54
问题 I have array of shape (height, width, 4) , i.e., RGBA format, and I want to convert this to grayscale. The original array has RGB values as 0 and the picture is rendered completely based on the alpha values over a white background, hence the traditional ways of turning this into grayscale fail (e.g., cv2.cvtColor(img,cv2.COLOR_RGBA2GRAY) ). Source image: 回答1: Assumptions: Your image is always black-n-white; White is defined as a transparency; If these things are true, then you can use the

Convert RGB color value to RGBA at 0.75 alpha

让人想犯罪 __ 提交于 2019-12-23 07:00:09
问题 I have the following code to get the background color of an element. var currentColor = $(this).css('background-color'); which returns something like rgb(123,123,123) What I now want to do convert this to rgba and show it at 0.75 alpha So returning something like rgba(123,123,123,0.75) Any ideas? 回答1: Since jQuery always seems to return the color like rgb(r, g, b) for elements that have no alpha, you could simply use: $(this).css('background-color').replace(')', ', 0.75)').replace('rgb',

Problem reconstituting UIImage from RGBA pixel byte data

与世无争的帅哥 提交于 2019-12-20 07:08:33
问题 I need to create 12 coloured images from a single greyscale image ( red orange yellow etc ) Source image is actually a PNG, RGBA: I'm using a library I found ( https://github.com/PaulSolt/UIImage-Conversion/ ) to break the UIImage into a RGBA byte array which I then process pixel by pixel, and use the same library to reconstitute a new UIImage. This is my code: - (UIImage*) cloneWithTint3: (CGColorRef) cgTint { enum { R, G, B, A }; // - - - assert( CGColorGetNumberOfComponents( cgTint ) == 4

What is the bit depth of the alpha channel in CSS3 colors?

好久不见. 提交于 2019-12-19 04:23:24
问题 Inspired by this question, I realized I haven't been able to find a clear answer to what the bit depth of the a part of rgba and hsla in CSS3 colors actually is. I've hunted through various W3C documentation, but aside from specifying that alpha is represented as a float range 0.0% - 100.0%, and the definition for the bit depth of the alpha channel in PNGs, I don't really have a clear picture (haha) of what the limits of the alpha channel in CSS3 actually are. Can someone find something more

How do I get the corresponding Hex value of an RGB color in Excel/VBA?

早过忘川 提交于 2019-12-17 18:42:30
问题 I'm trying to set a public const of a color in my VBA code. Normally, I can use: Dim BLUE As Long BLUE = RGB(183, 222, 232) However, there's no way to public const that because of the RGB function. I converted this RGB value to Hex using an online converter, and I got back B7DEE8 Using: BLUE = &HB7DEE8 results in a completely different color. I think this may actually be an RGBA color, and I've tried B7DEE8__ and got the color pretty close (with the last digit being B8), but I'd like to know

regex javascript to match both RGB and RGBA

青春壹個敷衍的年華 提交于 2019-12-17 16:58:48
问题 Currently I have this regex which matches to an RGB string. I need it enhanced so that it is robust enough to match either RGB or RGBA. rgbRegex = /^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/; //matches RGB http://jsfiddle.net/YxU2m/ var rgbString = "rgb(0, 70, 255)"; var RGBAString = "rgba(0, 70, 255, 0.5)"; var rgbRegex = /^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/; //need help on this regex //I figure it needs to be ^rgba?, and then also an optional clause to handle the opacity var partsRGB = rgbString.match

Convert 8-digit hex colors to rgba colors?

▼魔方 西西 提交于 2019-12-17 15:58:09
问题 Everything I've found on this subject simply converts the hex to rgb and then adds an alpha of 1. I want to get the intended alpha from the hex digits as well. A color such as #949494E8 or #DCDCDC8F clearly has an alpha value that's not 0 or 1. 回答1: I have made a quick JSfiddle form that allows you to convert from 8-digit hex code into CSS rgba values ;) https://jsfiddle.net/teddyrised/g02s07n4/embedded/result/ The basis is rather simple — to split the string you have provided into parts of 2

Using UIColor with CAShapeLayer

可紊 提交于 2019-12-14 03:36:48
问题 I'm passing an RGB color to shapeLayer.fillColor and shapeLayer.strokeColor , and my code is crashing. Here's what I tried: let shapeLayer = CAShapeLayer() shapeLayer.fillColor = (UIColor(red: 57, green: 65, blue: 101, alpha: 1) as! CGColor) shapeLayer.strokeColor = (UIColor(red: 57, green: 65, blue: 101, alpha: 1) as! CGColor) If I write my RGB color as: UIColor(red: 57, green: 65, blue: 101, alpha: 1) Xcode gives me a warning to change it to: (UIColor(red: 57, green: 65, blue: 101, alpha: 1

How to blend 2 transparency layers?

隐身守侯 提交于 2019-12-13 03:25:20
问题 For example we have 2 transparency layers: first is black (0, 0, 0, 0.75) and second is white (255, 255, 255, 0.64) . I don't know how to blend them. But I know how to blend one opaque and one transparent layers. It's look like this: https://wikimedia.org/api/rest_v1/media/math/render/svg/1e35c32f13d5eedc7ac21e9e566796dd048a31e6 回答1: Assume that the background colour is (C, 1) (RGB, A), the first layer is (A, s) and the second layer (B, t) . Applying the blending equation twice: C' = t * B +

Html rgba color opacity?

别等时光非礼了梦想. 提交于 2019-12-12 03:06:05
问题 When we use RGBA in Html we use sth like this. <div style="Background: rgba (x, x, x, 0.dd)">Some Content</div> How many decimals can you go in the dd (opacity) . Is it browser dependent? Or are its limits specified in HTML standards? 回答1: The specification says it is a <number> which is defined as: zero or more digits followed by a dot (.) followed by one or more digits So there is no limit specified in the CSS spec. I'd be surprised if any human eye could distinguish beyond two decimal