Hi,
how can I convert a RGB-Image to 8-Bit Greyscale ?
I use the Magick++ API and want to load a PNG-Image and convert it to
8-Bit Greyscale. The new Image is not written to Disk but used to fill
a 2-Dimensional Array, that is passed to another external API.
The Array that I want to fill with the 8bit-Greyscale Data looks like:
unsigned char *imagedata = new unsigned char[width*height];
My Problem is that I used
img.quantizeColorSpace( GRAYColorspace );
img.quantizeColors( 256 );
img.quantize( );
to lower the amount of colours. The Amount of different Colours is lowered to
256 but
if I call "image.pixelColor(x,y).redQuantum()" then I really like to get
results within [0..255]. Instead I get results within [0..MaxRGB].
As a Workaround Iam using a binary-Image with a Threshold-Value like this:
"pixel=(img.pixelColor(x,y).redQuantum()< threshold_value ) ? 0 : 255; "
But this does not give me satisfying results. What would be the best way to do
this?
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users