Convert Images to LAB

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
tterpell
Posts: 3
Joined: 2018-06-11T05:08:14-07:00
Authentication code: 1152

Convert Images to LAB

Post by tterpell »

Hello,

i am completely new to Imagekick and i need to convert different types of images to the LAB colorspace.
I Am currently using this command:

Code: Select all

magick convert "input4.tif" -flatten +profile tiff:37724 -colorspace Lab -auto-orient -intent Absolute -compress LZW "output4.tif"
The problem is, that this command seems not to work for ECI-RGB images and CMYK images.
If I convert a CMYK image to LAB, the image looks completely oversaturated in magenta and cyan.
If I convert an ECI-RGB image to LAB, it is a bit darker than the original.

Help would be greatly appreciated,
Thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert Images to LAB

Post by fmw42 »

Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620

For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown

Note that for ImageMagick 7, convert is replaced by magick; otherwise, you are likely using ImageMagick 6.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert Images to LAB

Post by fmw42 »

Try converting from eci-rgb to srgb with profiles. Then convert to lab with -colorspace lab. I suspect ImageMagick does not know the eci-rgb colorspace, so you cannot convert from it using -colorspace. But you could with an eci-rgb profile. See http://www.eci.org/en/downloads for profiles.

Or use profiles to go from eci-rgb directly to lab.

Can you post a link to one of your eci-rgb files?
tterpell
Posts: 3
Joined: 2018-06-11T05:08:14-07:00
Authentication code: 1152

Re: Convert Images to LAB

Post by tterpell »

The Version i Use is ImageMagick 7.0.7-38 Q16 x86_64 2018-06-02.
The System i am on is macOS 10.13.5.

Using this Command

Code: Select all

magick convert in.tif -colorspace LAB -intent absolute out.tif
i get the following result (on the left is the in.tif, on the right the out.tif):
https://drive.google.com/file/d/1hJAjGN ... sp=sharing
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert Images to LAB

Post by snibgo »

What software do you have that is reading and displaying Lab images? What data format does it expect? IM writes unsigned integers. Perhaps your reader software expects signed integers.

I suggest you try with ordinary photos, not images that have only three colours: black, white and some other colour.
snibgo's IM pages: im.snibgo.com
tterpell
Posts: 3
Joined: 2018-06-11T05:08:14-07:00
Authentication code: 1152

Re: Convert Images to LAB

Post by tterpell »

WEll, i made progress. I split the conversion into two steps:
At first, i converted the original image to a sRGB colorprofile using

Code: Select all

convert ECI_RGB.tif -profile Profile/sRGB2014.icc out.tif
Then, i converted the resultfile to LAB:

Code: Select all

convert out.tif -colorspace LAB lab.tif
But i needed to install Imagemagick with

Code: Select all

brew reinstall imagemagick --with-little-cms --with-little-cms2
to get that working.

The result: The image i get from the first command (out.tif) looks completely identical to the original.
When i perform the final command (to LAB), i can notice a slight shift in color. barely noticable. But it is there. Any idea how i can get rid of that?
I Noticed that the color profile that the image has that i want to convert to LAB, makes a big difference. If the image is in ECI-RGB, it is darker after i converted it. If it is in sRGB, i notice only a slight color shift. If it is in a CMYK-Profile, it looks completely different.
That leads me to the question: is there a Colorprofile that is better suited for the LAB conversion than sRGB2014?
Or is there any magical parameter that i can add to the second command to get rid of the color shift?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert Images to LAB

Post by fmw42 »

If you do not start with sRGB image, then you will likely need a correct profile for the input, if there is not one attached to the input. So you may need to find an ECI_RGB profile from the page I reference and use two profiles, eci_rgb and then sRGB before you go to LAB. You may also be able to find an LAB profile and then just use the eci-rgb to lab profiles.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert Images to LAB

Post by fmw42 »

Can you post a link to an example ECI_RGB image?
Post Reply