Page 1 of 1

Wrong pixel values.

Posted: 2012-07-02T16:07:42-07:00
by Atirag
Hello I have an image that is mostly yellow and I tried to turn it into a grayscale image by using this.

Code: Select all

MagickQuantizeImage(image_wand,256,GRAYColorspace,0,MagickFalse,MagickFalse);
and it worked the image turned into grayscale and I saved it as a new file.

I later used that same file but now I need to use the grayscale value of the pixels. The grayscale value is supposed to be any of the RGB colors since they're supposed to be the same. Yet when I use this

Code: Select all

PixelGetRed(pixels_wand[i])
I get many 0 values so I printed each pixel RGB and I got different values mainly 1 with PixelGetRed or PixelGetBlue but never the same.

Then I used the image without a grayscale conversion and I got the same. The weird thing is that the image is mostly yellow so I would expect PixelGetRed and PixelGetGreen to return 1 both but I mostly get 1 on Red and 0 elsewhere or 1 on Blue and 0 elsewhere.

Any ideas what might be happening?

Re: Wrong pixel values.

Posted: 2012-07-17T23:15:00-07:00
by anthony
Quantize does not grayscale the image. It reduces colors.

The colorspace for it is for the determination of how close colors are, not for setting the colorspace of an image.

Re: Wrong pixel values.

Posted: 2012-08-22T12:11:48-07:00
by Atirag
Thx Anthony!

And how can I change the image to grayscale?