Monday, February 17, 2014

bmp picture on color judgment! ! Great God seeking answers


Brother busy recently encountered a problem of a task, that is, how to get a map of a point after RGB judge what its color is? The main point is to determine the selection of what is inside the red yellow and green. I tried to convert the RGB color IHS to judge, but do not know the algorithm in question, the red color range jade other two intersect. It makes me very egg pain. Here is what I seek to identify ways
 private void gethis (int xxx, int yyy) {
int c = bitmap.getPixel (xxx, yyy);

/ / Extract RGB components from color pixel
int datar = (c & 0xff0000) >> 16;
int datag = (c & 0x00ff00) >> 8;
int datab = (c & 0x0000ff);
double r = datar * 1.0 / 255;
double g = datag * 1.0 / 255;
double b = datab * 1.0 / 255;

double min = Math.min (r, Math.min (g, b));
double h = 0.0, i = 0.0, s = 0.0;

if (min == r) {
h = ((b-r) / (3 * (g+ b-2 * r))) +1 / 3;
} Else if (min == g) {
h = ((r-g) / (3 * (r + b-2 * g))) +2 / 3;
} Else if (min == b) {
h = (g-b) / (3 * (g+ r-2 * b));
}

i = (r + g+ b) / 3;
s = 1-min / i;

RgbDao rgbDao = new RgbDao (getBaseContext ());
Rgb rgb = new Rgb (xxx + "", yyy + "", h + "", i + "", s + "", r + "",
g
+ "", + B + "");
/ / RgbDao.addgreen (rgb);
rgbDao.addred (rgb);

Log.i ("xixi", "x:" + xxx + "y" + yyy + "\ n" + "R" + r + "G" + g + "B"
+ B);
Log.i ("xixi", h + "h" + i + "v" + s + "s");

}
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Bangding! Draw from
Reply:
rgb and ihs this is a converted document, you can look, and you are not the same thing < / a>
Reply:
When state development concerns

No comments:

Post a Comment