Making a new 16-bit Lab color

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
tom_dl
Posts: 43
Joined: 2015-02-26T08:25:44-07:00
Authentication code: 6789

Making a new 16-bit Lab color

Post by tom_dl »

Version: ImageMagick 6.9.0-10 Q16 x64

Hi, I'm having trouble setting the canvas a very specific color. The line I want to use would look like this:

Code: Select all

convert -depth 16 -size 2700x5120 -colorspace lab xc:"lab(0,-223,204)" output.tif
But that produces the following 16-bit Lab values:

Code: Select all

0,16256,16256
If I want to input 8-bit values, I can use this line:

Code: Select all

convert -depth 16 -size 2700x5120 -colorspace lab xc:"lab(0,-2,2)" output.tif
and I get the following 8-bit Lab values:

Code: Select all

0,-2,2
so the line has worked. When I set the 16-bit values (as in the first example), the line doesn't work. If I didn't need the specificity of 16-bit, I would settle with the above. However, I do, so any suggestions are very welcome!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Making a new 16-bit Lab color

Post by fmw42 »

Lab colors other than in HDRI mode are not negative. They have been biased for non-hdri mode compiles. -depth 16 should come after creating the image and before the output, though it may not matter in IM 6. See http://www.imagemagick.org/script/color.php and search for lab. It says:

Specify the Lab colors like this:
cielab(62.253188, 23.950124, 48.410653)

which I believe are in the range 0 to 255. For HDRI, I am not sure about the range, but I think it conforms to the standard lab values with negate A and B channels. See also http://www.brucelindbloom.com/index.htm ... lator.html
tom_dl
Posts: 43
Joined: 2015-02-26T08:25:44-07:00
Authentication code: 6789

Re: Making a new 16-bit Lab color

Post by tom_dl »

That's very helpful, thanks! I'll use that format instead. Just out of curiosity, how come my second line (0,-2,2) works with negative values, when I'm not in HDRI mode?
tom_dl
Posts: 43
Joined: 2015-02-26T08:25:44-07:00
Authentication code: 6789

Re: Making a new 16-bit Lab color

Post by tom_dl »

After trying out your advice, I can conclude two things:
* Using decimal precision does indeed work, so I can reach my desired values by using (0,-0.87109,0.79067)
* As alluded to above, negative values do seem to work (for a & b channels, at least) in non-HDRI mode
If you use -colorspace lab and output to *.txt, you will see IM stores lab values as such:

Code: Select all

# ImageMagick pixel enumeration: 1,1,65535,cielab
0,0: (73.6721%,-0.883497%,0.720226%)  #BC99000001D8  cielab(73.6721%,-0.883497%,0.720226%)
Got there eventually! Thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Making a new 16-bit Lab color

Post by fmw42 »

This is news to me. Perhaps IM now takes care of the bias automatically when using cielab color specification.

Are you sure you are not in HDRI? Does it list HDRI when you do convert -version.
tom_dl
Posts: 43
Joined: 2015-02-26T08:25:44-07:00
Authentication code: 6789

Re: Making a new 16-bit Lab color

Post by tom_dl »

I'm not in HDRI. When I do convert -version, I get this:

Code: Select all

$ convert -version
Version: ImageMagick 6.9.0-10 Q16 x64 2015-02-28 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: DPC Modules OpenMP
Delegates (built-in): bzlib cairo freetype jbig jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib
Post Reply