How to interpret IM Lab values?

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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to interpret IM Lab values?

Post by anthony »

Note negative values are NOT posible with IM

(unless you have a special floating point HDRI version which is not typically used) See IM examples, Basics, HDRI
http://www.imagemagick.org/Usage/basics/#hdri

Second -colorspace LAB will convert from whatever the images current color
space is (Usally RGB) to LAB colorspace. that data in the image is modified!!!!

To just tell IM that the data is already in LAB format, but without converting
you would use -set colorspace LAB

See IM Examples, Basics, Color Space for details..
http://www.imagemagick.org/Usage/basics/#colorspace

Now I don't know a lot about the LAB colorspace. I didn't even know it could have negative values (which can't be represented normally).

However looking at the source code IM does RGB to LAB colorspace conversions by convertign RGB to XYZ then from there to LAB

RGBtoXYZ is defined as

X=0.4124240*r+0.3575790*g+0.1804640*b;
Y=0.2126560*r+0.7151580*g+0.0721856*b;
Z=0.0193324*r+0.1191930*g+0.9504440*b;

whcih are foaling point values

Also as RGB is positive XYZ will be a positive value

XYZ to Lab is defines is a much more complex way.
involving some poweroff modifiers and some negatives, so I supose
it could produce negative values.


My own test

Code: Select all

convert xc:'RGB(64,165,214)' -colorspace LAB -depth 8 txt:-
had the same result you did a color of lab(230,107,102)

Hmm the bet idea is to check if going from RGB to LAB and back to RGB
produces something sensible...

Code: Select all

convert xc:'RGB(64,165,214)' -colorspace LAB -colorspace RGB -depth 8 txt:-
which returned rgb(64,165,214) which seems to indicate the formulas
are correct.

As such I am not certain how this relates to or differs from the TIFF version, or where ever your original version with negative values.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply