rgb

How to Judge if a Color is Green?

二次信任 提交于 2021-02-20 02:50:50
问题 What is the formula for deciding if an rgb code is green? Here is an attempt: public boolean isGreen(Color color){ return (color.getGreen() > 0.8*(color.getBlue()) && color.getBlue() > color.getRed()); } That is, return true if the green value of rgb is considerably greater than the blue, and the blue is greater than the red. A test was conducted on its accuracy. Methods: A JavaFX program generated 132 orbs every 6 seconds, each with an rgba (alpha is irrelevant in this case) value of (Math

Convert RGB array to Mat (OpenCv)

蹲街弑〆低调 提交于 2021-02-19 02:11:20
问题 I've been trying to convert an array [R,G,B,..] in Mat object with opencv. But is returning wrong data, someone knows why? double data[12] = {0,0,255,0,0,255,0,0,255,0,0,255}; Mat src = Mat(2,2, CV_16UC3, data); and returns: M = [0, 0, 0, 0, 0, 0; 0, 0, 0, 0, 57344, 16495] EDIT: Solved! use uchar instead double, and CV_8UC3 回答1: i think, you wanted: uchar data[12] = {0,0,255,0,0,255,0,0,255,0,0,255}; Mat src = Mat(2,2, CV_8UC3, data); (all red, 2x2 rbg image) 来源: https://stackoverflow.com

Convert RGB array to Mat (OpenCv)

吃可爱长大的小学妹 提交于 2021-02-19 02:09:00
问题 I've been trying to convert an array [R,G,B,..] in Mat object with opencv. But is returning wrong data, someone knows why? double data[12] = {0,0,255,0,0,255,0,0,255,0,0,255}; Mat src = Mat(2,2, CV_16UC3, data); and returns: M = [0, 0, 0, 0, 0, 0; 0, 0, 0, 0, 57344, 16495] EDIT: Solved! use uchar instead double, and CV_8UC3 回答1: i think, you wanted: uchar data[12] = {0,0,255,0,0,255,0,0,255,0,0,255}; Mat src = Mat(2,2, CV_8UC3, data); (all red, 2x2 rbg image) 来源: https://stackoverflow.com

Convert RGB array to Mat (OpenCv)

别来无恙 提交于 2021-02-19 02:07:01
问题 I've been trying to convert an array [R,G,B,..] in Mat object with opencv. But is returning wrong data, someone knows why? double data[12] = {0,0,255,0,0,255,0,0,255,0,0,255}; Mat src = Mat(2,2, CV_16UC3, data); and returns: M = [0, 0, 0, 0, 0, 0; 0, 0, 0, 0, 57344, 16495] EDIT: Solved! use uchar instead double, and CV_8UC3 回答1: i think, you wanted: uchar data[12] = {0,0,255,0,0,255,0,0,255,0,0,255}; Mat src = Mat(2,2, CV_8UC3, data); (all red, 2x2 rbg image) 来源: https://stackoverflow.com

Simulate color transparency

十年热恋 提交于 2021-02-18 21:30:32
问题 I have RGB color value and alpha value. How can I get new RGB value assuming that I have white backgound and alpha is applied? 回答1: The formula to be applied to each of the color channels is the following: cr = cf * af + cb * ab * (1 - af) where cr is the resulting color of the pixel, cf is the foreground color, cb the background color, af foreground alpha and ab background alpha. Note that often color values are stored already premultiplied by alpha in which case the formula simplifies to cr

Simulate color transparency

核能气质少年 提交于 2021-02-18 21:30:09
问题 I have RGB color value and alpha value. How can I get new RGB value assuming that I have white backgound and alpha is applied? 回答1: The formula to be applied to each of the color channels is the following: cr = cf * af + cb * ab * (1 - af) where cr is the resulting color of the pixel, cf is the foreground color, cb the background color, af foreground alpha and ab background alpha. Note that often color values are stored already premultiplied by alpha in which case the formula simplifies to cr

PHP: how to express “near white” as a color?

北城以北 提交于 2021-02-16 16:31:07
问题 I have a function for trimming white areas around images that works something like if(imagecolorat($img, $x, $top) != 0xFFFFFF) { //sets where the top part of the image is trimmed } The problem is some images have an occasional stray pixel that is so near white that it's unnoticeable but screws up the cropping because it's not exactly 0xFFFFFF but 0xFFFEFF or something. How could I rewrite the above statement so that it evaluates true for those near white images, say down to 0xFDFDFD,

When converting an image into an array and viceversa, are there extra considerations one must take into account?

∥☆過路亽.° 提交于 2021-02-11 06:22:57
问题 I wrote this code to switch the red and blue values in the RGB array from a given image: from PIL import Image import numpy as np image = Image.open("image.jpg") RGBarr = np.asarray(image) newRGB = np.full_like(RGBarr, 1) red = RGBarr[..., 0] green = RGBarr[...,1] blue = RGBarr[..., 2] newRGB[..., 0] = blue newRGB[..., 1] = green newRGB[..., 2] = red inv_image = Image.fromarray(newRGB, 'RGB') inv_image.save('inv_image.png') inv_image.show() I tried it with multiple images, and it works almost

Get hue (HSV/HSB) value of RGB using Emgu C# yields wrong result

久未见 提交于 2021-02-10 14:58:43
问题 I am using EMGU.CV 3.4.1.2976 (latest) library to analyze images but I am not getting the results I expect. I benchmark against ImageJ but any image package should do. To test functionality, I am analyzing a simple blue 640x320 jpeg like below. The RGB value for this image is 0,0,255. Hue histogram from ImageJ (value is 170, count 2048000) Using code below I get a spike at 120 instead of the 170 - count 2048000 is correct though. What am I doing wrong? public void AnalyzeEmgu(object image) {

Java for ImageJ. How to convert an image from RGB to 8 bit using code?

淺唱寂寞╮ 提交于 2021-02-08 04:07:39
问题 I am currently working on Connected Component Labelling. This is a process which takes an image and tells you how many separate objects are in the Image. My problem is that at the very start I need to be able to take any image (specifically RGB value) and convert it into 8-bit. EDIT: as in literally considered an 8bit, where the image is no longer recognised as RGB. Not an 8bit image that is recognised as an RGB. Is there a way using code to automatically do this without having to go into the