Page 1 of 1

Bug or feature - change of pixel values in seperate?

Posted: 2012-01-25T23:04:10-07:00
by Franz777
Hi,

I have two different strange behaviours:

1.) I have a 8 bit Lab Tiff image (can be send if wanted) which i want to split into three gray images (PNG's) containing L a and b.

Here is my code:

convert myLabTiff.tif -seperate myGrayTiff.png

Results first look good but when i compare pixel values to original tiff they changed a little bit (very little, only between zero and approximately 5 gray values), why?

i also tested

convert myLabTiff.tif -colorspace LAB -seperate myGrayTiff.png
convert myLabTiff.tif -set colorspace LAB -seperate myGrayTiff.png (whats the difference to above?)


2) Whats also very interresting is my second problem:
I have a 16 bit RGB Tiff which i want to seperate inte 3 L, a and b Gray images:

convert myRGBTiff.tif -set colorspace Lab myLabPNG.png
and then i make
convert myLabPNG.png -separate myGrayPNG.png

and result is different from
convert myRGBTiff.tif -set colorspace Lab -separate myGrayPNG.png
or from
convert myRGBTiff.tif -separate -set colorspace Lab myGrayPNG.png

why, i do not understand this....
and: Isn't a whitepoint necessary to convert from RGB to Lab or is the whitepoint stored in the RGB tiff ?

Re: Bug or feature - change of pixel values in seperate?

Posted: 2012-01-26T12:00:25-07:00
by fmw42
Check the verbose info (convert image -verbose info:) for each input and output image and see what the colorspace is. You are probably getting it automatically converted to RGB prior to separating it if you don't use the proper means of -set colorspace and separate and -colorspace as in my earlier post to you. Also one has to be careful as PNG only supports RGB, so you have to sort of trick the conversion so that it thinks the LAB channels are RGB without converting them.

I really don't understand all these differences and Anthony would have to explain in more detail.

Re: Bug or feature - change of pixel values in seperate?

Posted: 2012-01-27T04:30:53-07:00
by anthony
Franz777 wrote:

Code: Select all

convert myLabTiff.tif -colorspace LAB -seperate myGrayTiff.png
convert myLabTiff.tif -set colorspace LAB -seperate myGrayTiff.png 
(whats the difference to above?)
The first changes the colorspace to LAB and the image data as well. IT should produce 3 images as PNG can only save one image per file.

The Second chnages the images colorspace setting, but does NOT change the image data. That makes IM think the images original images color space is LAB without change.
2) Whats also very interresting is my second problem:
I have a 16 bit RGB Tiff which i want to seperate inte 3 L, a and b Gray images:

Code: Select all

convert myRGBTiff.tif -set colorspace Lab myLabPNG.png
and then i make

Code: Select all

convert myLabPNG.png -separate myGrayPNG.png
PNG can not save in LAB colorspace, at least not without profiles. So when the first command sets the colorspace to be LAB, (without data change), and you then save it, IM resets the colorspace to RGB, changing the data as well during the save to PNG file format. Thus the data was converted from what IM things to LAB to RGB.

The second simply separates the PNG channels to separate gray scale images.
and result is different from

Code: Select all

convert myRGBTiff.tif -set colorspace Lab -separate myGrayPNG.png
You set it to LAB, seperated the channels (the original unchanged data) as grayscale (RGB) channel images.
As such it is the same as if you never changed the color space at all!
or from

Code: Select all

convert myRGBTiff.tif -separate  -set colorspace Lab myGrayPNG.png
Now you read in the image, separate the three channels (unchanged) into Grayscale images (RGB), now you tell IM to consider those gray scale images to be LAB images (without data change) and save them into PNG (conveting LAB to RGB) essentially you get nonsense. Grayscale data pretending to be LAB (which is nonsense), converted to RGB!!!
why, i do not understand this....
and: Isn't a whitepoint necessary to convert from RGB to Lab or is the whitepoint stored in the RGB tiff ?
You can set 'whitepoint' and other color specification settings.

See the options: ‑black‑point‑compensation, ‑white‑point, ‑red‑primary, ‑green‑primary, ‑blue‑primary; on
http://imagemagick.org/script/command-line-options.php

However I have no idea what these settings really mean, or the result of changing the settings. I have not looked into them. I just know they are present and are used by some image file format coders (due to my current work for IMv7 CLI interface changes.