Reading as GrayScale
Posted: 2011-01-01T20:46:55-07:00
Greetings,
I am reading in a grayscale image, but it seems like somehow the wand is reading it as an RGB image.
The reason I suspect this is because if I run this:
It apparently is only doing the levels on a single channel of the image that looks different than if I run it on AllChannels. Also, it seems like the memory it is using is consistent with a 'RGB' not a 'I' map.
I have tried reading the image two ways, as a PNG:
And as raw pixels:
Is there anyway to confirm that the image is being loaded as a grayscale image? Or can someone recommend the correct way to read a grayscale image in? I have set these as well:
Are these supposed to be set before or after the image is read?
Note that if I write the wand out and open the file, it is in fact a grayscale, single channel image:
Any suggestions would be greatly appreciated!
I am reading in a grayscale image, but it seems like somehow the wand is reading it as an RGB image.
The reason I suspect this is because if I run this:
Code: Select all
MagickLevelImageChannel(magick_wand2, GrayChannel, (0.5f * QuantumRange), 0.6666f, (0.8f * QuantumRange));
I have tried reading the image two ways, as a PNG:
Code: Select all
status = MagickReadImageBlob(origWand, [dataObject bytes], [dataObject length]);
Code: Select all
status = MagickConstituteImage(origWand, width, height, "I", CharPixel, [dataObject bytes]);
Code: Select all
MagickSetImageType(origWand, GrayscaleType);
MagickSetImageColorspace(origWand, GRAYColorspace);
Note that if I write the wand out and open the file, it is in fact a grayscale, single channel image:
Code: Select all
status = MagickWriteImage(origWand, "out.png");