XYZ colorspace pixels

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
drewvy

XYZ colorspace pixels

Post by drewvy »

I'm loading a tiff file that is in XYZ colorspace. Here is the call I use to get a row of pixels:

pixels=GetImagePixels(image1,0,loop,image1->columns,1);

Then I iterate the row with another loop like this:

X = (pixels1+loop2)->red
Y = (pixels1+loop2)->green
Z = (pixels1+loop2)->blue

Here is my question is. Does X, Y, and Z really mapped like I have it above to RED, GREEN, and BLUE?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: XYZ colorspace pixels

Post by anthony »

Yes. That is how the data is arranged. Don't think of the 'R' channel as being red, think of it as 'channel 1' which could be red, hue, X, cyan, or other things depending on the image color space.
'R' is just a label for the channel typically used for 'red'.

I have add the above to IM examples, Basics, and Channels.

http://www.imagemagick.org/Usage/basics/#colorspace


If you read and manipulate such an image within IM, you can also tell ImageMagick that this image is XYZ by using...

Code: Select all

    convert xyz_image.tiff  -set colorspace XYZ ....
the -set colorspace operator does not modify the image data, just re-defines how IM will interprete that data.

If you want to convert it between other color spaces.
EG: convert XYZ image to RGB image

Code: Select all

    convert xyz_image.tiff  -set colorspace XYZ -colorspace RGB image_RGB.tiff
-colorspace does modify the data converting the 'declared' XYZ image data to RGB image data.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
drewvy

Re: XYZ colorspace pixels

Post by drewvy »

Thanks. You guys rock.
Post Reply