I write class, which converts 256 colors image to 16 colors image. But I don't know, how I can do it. I know this formule: Delta=(R1-R2)^2 + (G1-G2)^2+ (B1-B2)^2, but I don't understand how use it ?
So, please explain me how convert image ? :crying:
I write following code:
#define DELTA(RGB1, RGB2) ( \
sqrt(pow(RGB1.rgbRed-RGB2.rgbRed, 2) + \
pow(RGB1.rgbGreen-RGB2.rgbGreen, 2) + \
pow(RGB1.rgbBlue-RGB2.rgbBlue, 2)))
...
for ( int i = 0; i < 255; i++ )
{
RGBQUAD rgb1 = ColorTable256[i];
RGBQUAD rgb2 = ColorTable256[i + 1];
int index = DELTA( rgb1, rgb2 );
rgb1.rgbRed = ( ( rgb1.rgbRed + rgb2.rgbRed ) / 2 );
rgb1.rgbGreen = ( ( rgb1.rgbGreen + rgb2.rgbGreen ) / 2 );
rgb1.rgbBlue = ( ( rgb1.rgbBlue + rgb2.rgbBlue ) / 2 );
if ( index < 16 ) ColorTable16[index] = RGB( rgb1.rgbRed, rgb1.rgbGreen, rgb1.rgbBlue );
}
But this code don't too well works ...If anyone knows how does it - please tell me.
It's very important for me ...
TIA.


Sign In
Create Account

Back to top









