Page 1 of 1
"convert -colorspace lab" output out of range
Posted: 2015-04-15T07:52:41-07:00
by displayguy
Hi all,
I'm trying to convert sRGB pictures to CIELAB by running:
Code: Select all
convert original.tif -colorspace lab output.tif
When I extract the values with:
The
L value is a LOT higher than the values that I get from resources like Photoshop and colormine.org. More worryingly, the
a and
b values routinely exceed 250. As far as I know,
a and
b should be between -110 and 110.
Could anyone please point out what I missed (if anything)? It seems important since both Inkscape and Gimp users are told to use Imagemagick to do RGB to CIELab conversions.
Thanks in advance!
P.S: I run Imagemagick from the Ubuntu repos.
Re: "convert -colorspace lab" output out of range
Posted: 2015-04-15T08:07:24-07:00
by snibgo
If you are running integer (non-HDRI) ImageMagic, the values can never be negative. The "middle" value of the a* and b* channels is 50% of quantum.
Does that answer the question?
Re: "convert -colorspace lab" output out of range
Posted: 2015-04-15T09:32:03-07:00
by fmw42
IM biases the A and B values to 50% as snibgo says for normal Q8 and Q16 IM compiles because all image must range from 0 to 256 or 0 to 65535. To get negative values you need to use HDRI compiled IM and tell tiff to save negatives. see quantum:format at
http://www.imagemagick.org/script/comma ... php#define
Re: "convert -colorspace lab" output out of range
Posted: 2015-04-17T09:55:09-07:00
by displayguy
Thanks a bunch!
To sum up, I installed libtiff* on my system and compiled IM from source with the following (just being thorough for the benefit of future inquirers):
Code: Select all
./configure --enable-hdri --with-libtiff
make clean
make
sudo make install
Then I convert the images with:
Code: Select all
convert input.tif -colorspace lab -define quantum:format=floating-point output.tif
The L* looks good, but the a* and b* deviate somewhat from the results I get with Photoshop and colormine.org. Then again, the latter don't match either. I'd trust IM and Colormine to do a better job than Photoshop since the conversion algorithm is open. Many eyeballs and all...
P.S: Increasing quantum-depth to 32 helps.
Re: "convert -colorspace lab" output out of range
Posted: 2015-04-17T10:17:55-07:00
by snibgo
If you can publish the input, and the versions converted by IM, PS and colormine, someone can take a look. (Upload to somewhere like dopbox.com and paste the result here.)
I would expect a trivial difference due to rounding errors. There may be larger differences due to different "zero" points in a* and b*, and/or full-scale differences (eg one program might use only 100 out of 256 possible values).
Re: "convert -colorspace lab" output out of range
Posted: 2015-04-17T10:51:23-07:00
by displayguy
Here comes the files (plus screenshots from Colormine and Photoshop):
https://drive.google.com/folderview?id= ... sp=sharing
It's the original sRGB file and the output of:
Code: Select all
convert original.tif -colorspace lab -define quantum:format=floating-point quatum-depth=32 output.tif
When I convert the original to text I get: 0,0: (45,65,87) #2D4157 srgb(45,65,87)
The CIELab one gives: 0,0: (26.6667%,-0.39292%,-6.27527%) #440000 cielab(26.6667%,-0.39292%,-6.27527%)
When I feed the original's sRGB values (i.e. 45,65,87) into Colormine it gives: CIELab (26.8, -1.09, -15.63)
Opening the original image in Photoshop gives: RGB (45, 64, 87) and CIELab (25, -6, -19)
As you can see, the a* and b* difference is fairly substantial.
Thanks again!
Re: "convert -colorspace lab" output out of range
Posted: 2015-04-17T12:13:19-07:00
by snibgo
But what are the units?
http://colormine.org/color-converter has units of -128 to +128. To see this, try converting from "CIE-L*ab". Why do they call it that? "CIE-L*a*b*" or "CIE-Lab", but having * beside just L is weird.
Colormine says it is open source. In theory, someone could look at the code.
Re: "convert -colorspace lab" output out of range
Posted: 2015-04-17T12:58:01-07:00
by fmw42
IM uses code from
http://www.brucelindbloom.com/. Photoshop is notorious for not following standards. See
http://en.wikipedia.org/wiki/Lab_color_space for the difference between Lab and La*b*