colorspace conversion issue....

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
sound_image
Posts: 1
Joined: 2012-11-09T17:28:28-07:00
Authentication code: 67789

colorspace conversion issue....

Post by sound_image »

Hi All,
I'm brand new to ImageMagick, so please bear with me, should I make any mistakes!
The plan is to convert the color space of a bunch of .tif files from sRGB to generic RGB or XYZ... (on the way there might be some gamma conversions to be addressed).
1) Checking the original file:
# identify -format "%[colorspace]" 1ab_dcp.v01_1440.tif
sRGB
2) Converting to XYZ color space:
convert 1ab_dcp.v01_1440.tif -colorspace XYZ out2.tif
3) Checking the output file:
identify -format "%[colorspace]" out2.tif
sRGB

Now why is that? I would have expected this to come back with a XYZ??
Any help/ advise/ solution is appreciated!

ptitude -v show imagemagick:
Package: imagemagick
State: installed
Automatically installed: yes
Version: 8:6.7.7.10-4

uname -r
3.2.0-3-amd64
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: colorspace conversion issue....

Post by fmw42 »

I do not think IM keeps colorspace information of images that are not sRGB, RGB or CMYK. You will find the conversion to other colorspaces are not kept by IM in the verbose information, either. The files will be labeled with one of the above. sRGB for non-linear (gamma=0.4545), RGB for linear (gamma=1). Some image types such as TIFF may keep track of some information in the image meta data for that format, such as noting LAB, for example.

I do not believe that any other tools will keep track of colorspaces other than the ones above. PS may keep track of LAB also.

I defer to anyone else who has more/correct information on this.

P.S. You have to tell IM what colorspace you are using (via -set colorspace) once you separate channels and then want to recombine them. See http://www.imagemagick.org/Usage/color_ ... bine_other

Also note that from between IM 6.7.5.5 and about 6.7.6.7, IM was in the process of swapping the notation for RGB and sRGB to conform properly. See viewtopic.php?f=4&t=21269

See also http://www.imagemagick.org/script/forma ... colorspace

I would expect on a newer version of IM that a conversion from sRGB to XYZ would show colorspace as RGB, since I believe that XYZ is a linear colorspace. But I get the same sRGB colorspace, so perhaps I am mistaken about XYZ being linear.

But on the other hand, the verbose info shows that tiff thinks it is RGB (though that may just be a generic label for sRGB).

identify -verbose rose_xyz.tif
Image: rose_xyz.tif
Format: TIFF (Tagged Image File Format)
Class: DirectClass
Geometry: 70x46+0+0
Units: PixelsPerInch
Type: TrueColor
Base type: TrueColor
Endianess: MSB
Colorspace: sRGB
Depth: 8-bit
...
Properties:
date:create: 2012-11-09T17:23:36-08:00
date:modify: 2012-11-09T17:23:36-08:00
signature: a6cb0cd265ea54acf66bd452fc3e67d065e227c5e9d45da38f74bb94c42636e4
tiff:document: rose_xyz.tif
tiff:endian: lsb
tiff:photometric: RGB
tiff:rows-per-strip: 39


I am not really sure what version 8:6.7.7.10-4 means. Is that 6.7.7.10? Best way to find out is

convert -version


I think one of the IM developers will have to comment about the linearity or nonlinearity of XYZ colorspace.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: colorspace conversion issue....

Post by magick »

XYZ colorspace is linear. TIFF does not have a photometric for XYZ:
  • #define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */
    #define PHOTOMETRIC_MINISWHITE 0 /* min value is white */
    #define PHOTOMETRIC_MINISBLACK 1 /* min value is black */
    #define PHOTOMETRIC_RGB 2 /* RGB color model */
    #define PHOTOMETRIC_PALETTE 3 /* color map indexed */
    #define PHOTOMETRIC_MASK 4 /* $holdout mask */
    #define PHOTOMETRIC_SEPARATED 5 /* !color separations */
    #define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */
    #define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */
    #define PHOTOMETRIC_ICCLAB 9 /* ICC L*a*b* [Adobe TIFF Technote 4] */
    #define PHOTOMETRIC_ITULAB 10 /* ITU L*a*b* */
    #define PHOTOMETRIC_LOGL 32844 /* CIE Log2(L) */
    #define PHOTOMETRIC_LOGLUV 32845 /* CIE Log2(L) (u',v') */
yellow
Posts: 28
Joined: 2011-06-15T14:01:24-07:00
Authentication code: 8675308

Re: colorspace conversion issue....

Post by yellow »

If you know what the color space of an image is then you could use -set colorspace sRGB -colorpace XYZ ?

If you want to keep track of an images colorspace you could use ICC profiles, they're available from the ICC website and using IM's -profile feature, download the ICC required and drop into the folder with your images, then use -profile.

Although XYZ colorspace is regarded as linear, XYZ for dcp has a gamma of 2.6 applied and a whitepoint defined ? So you'd need to apply gamma after.

Again ICC profiles for ICC color managed applications are available from the website including dcp at specific whitepoints.

All color space conversions I believe are done in linear so sRGB to XYZ would linearize the source first.
Post Reply