Wrong pixel values.

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
Atirag
Posts: 6
Joined: 2012-03-28T13:35:51-07:00
Authentication code: 8675308

Wrong pixel values.

Post by Atirag » 2012-07-02T16:07:42-07:00

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?

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Wrong pixel values.

Post by anthony » 2012-07-17T23:15:00-07:00

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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

Atirag
Posts: 6
Joined: 2012-03-28T13:35:51-07:00
Authentication code: 8675308

Re: Wrong pixel values.

Post by Atirag » 2012-08-22T12:11:48-07:00

Thx Anthony!

And how can I change the image to grayscale?

Post Reply