Click to See Complete Forum and Search --> : rgb question


celtics
December 6th, 2003, 10:46 PM
how to combine (a) and (b) for nice clear cut bw image?.


(a)
greylevel = (red * 0.30) + (green * 0.59) + (blue * 0.11);

(b)
for(int i=0; i<256; i++) {
p->bColors[i].rgbBlue = i;
p->bColors[i].rgbGreen = i;
p->bColors[i].rgbRed = i;
p->bColors[i].rgbReserved = 0;
}

yiannakop
December 8th, 2003, 10:26 AM
Do u mean you want to convert an rgb image to a gray-scale one?

Deniz
December 8th, 2003, 06:17 PM
(a)
greylevel = (red * 0.30) + (green * 0.59) + (blue * 0.11);

(b)
for(int i=0; i<256; i++) {
p->bColors[i].rgbBlue = i;
p->bColors[i].rgbGreen = i;
p->bColors[i].rgbRed = i;
p->bColors[i].rgbReserved = 0;
}

Q: whats the 256 for? How big is the image?

EarthHound
December 18th, 2003, 10:28 AM
Presuming that the palette contains RGB colors that you want
to convert to greyscale:

COLORREF grey;
for(int i=0; i<256; i++) {
grey =
p->bColors[i].rgbRed * 0.3 +
p->bColors[i].rgbGreen *0.59+
p->bColors[i].rgbBlue * 0.11:

p->bColors[i].rgbBlue = grey;
p->bColors[i].rgbGreen = grey;
p->bColors[i].rgbRed = grey;
p->bColors[i].rgbReserved = 0;
}

yiannakop
December 31st, 2003, 10:34 AM
Originally posted by EarthHound
.......
COLORREF grey;
for(int i=0; i<256; i++) {
grey =
p->bColors[i].rgbRed * 0.3 +
p->bColors[i].rgbGreen *0.59+
p->bColors[i].rgbBlue * 0.11:
.......
}

Why multyplying the rgb cooefficients by those numbers (0.3, 0.59 and 0.11). Rgb to gray scale conversion is simply done by that:
gray_value = (r_val+g_val+b_val)/3

EarthHound
December 31st, 2003, 10:56 AM
Because the human eye has better resolution for the color green than for any other color (because earlier our primary food came in different shades of green). Red also was an important color because ripe fruit tend to become red. Hence the proportional adjustment instead of weighting them all the same.

Happy new something.

dethany
February 12th, 2007, 12:59 AM
Please help me..how to convert 256 greylevel to 16 greylevel

VladimirF
February 12th, 2007, 03:38 AM
Please help me..how to convert 256 greylevel to 16 greylevel

/ 16

yiannakop
March 26th, 2007, 07:56 AM
Because the human eye has better resolution for the color green than for any other color (because earlier our primary food came in different shades of green). Red also was an important color because ripe fruit tend to become red. Hence the proportional adjustment instead of weighting them all the same.

Happy new something.
:) Nice. I admit I did not know that....
I've also found sth relevant in
http://en.wikipedia.org/wiki/RGB_color_model

:wave:

VladimirF
March 26th, 2007, 11:00 AM
:) Nice. I admit I did not know that....

And if you read replies to your posts, you would've known that back in 2003! :)