Message Boards Message Boards

Cie Lab color space problems while using Mathematica with Photoshop

Posted 7 years ago

The idea was to communicate image files (using the Cie Lab color space) between Photoshop CS6 and Mathematica 9.0.1.0 running on Mac OSX 10.11.6 El Capitan.

I created a file in Photoshop with four pixels (two per row) with the following Lab values from left to right; • row 1: L=100, a= -128, b= 127 / L=100, a= 127, b= 127 • row 2: L=100, a= -128, b= -128 / L=100, a= 127, b= -128

The file looks like this in Photoshop: see « sd1.png ».

I then imported in Mathematica the image and looked at the image data. I notice that « L » channel has been mapped to values between zero and one, and the « a » and « b » channels have been mapped to values between -0.5 and 0.496. So far so good.

However the imported image does not look like the Photoshop image and upon close inspection the values do not correspond to the imported values either. See « sd2.png ».

I then created a one pixel image in Mathematica with the following values: 1., 0.496, 0.496. The created image does not look right and, like above, on inspection the values do not correspond to the image data values given. See « sd3.png ». I exported the image to Photoshop. When I open the one pixel file in Photoshop the color and values are correct. See « sd4.png ».

I then made a four pixel image in Mathematica. Again the created image does not look right and upon inspection the values are not correct: See « sd5.png ». I exported the image to Photoshop. Here when I open the four pixel image file in Photoshop the values make no sense at all. See « sd6.png ». It should look exactly like the first four pixel image file I created initially in Photoshop.

Attached please find my Mathematica file, my Photoshop files and the screen dump files grouped together in one pdf file. ("sd1.png" is on page one, "sd2.png" is on page 2 etc.)

Please note that when I go through exactly the same procedure as above using the RGB color space, there are no problems at all.

Looking forward to your feedback.

Attachments:
POSTED BY: andrew gerzso
2 Replies

Tiff import/export got a major update in V11. If I rerun your code the values are:

enter image description here

Which I think are correct. I don't have acces to V9 anymore, but I'm not sure if it can import LAB tiff files at all... I have a feeling it reinterprets the signed ints from the lab color as unsigned ints in your example, though I'm not sure if that is possible at all.

What does:

Import["lab-4pix-input.tif", "ColorSpace"]

and

Import["lab-4pix-input.tif", "Data"]

return for you? Are those correct?

POSTED BY: Sander Huisman
Posted 7 years ago

The first Import returns the correct space (Lab).

In[4]:= Import["Desktop/m9-lab-tests/lab-4pix-input.tif", "ColorSpace"]
Out[4]= "LAB"

The second returns the same (apparently) wrong values.

In[5]:= Import["Desktop/m9-lab-tests/lab-4pix-input.tif", "Data"]
Out[5]= {{{1., -0.500008, 0.496101}, {1., 0.496101, 0.496101}}, {{1., -0.500008, -0.500008}, {1., 0.496101, -0.500008}}}

So I guess I have to update to v11 ... Thanks for your feedback !

POSTED BY: andrew gerzso
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract