Linear to regular gamma RGB conversion, other stuff

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
ElleStone
Posts: 7
Joined: 2012-07-23T08:02:50-07:00
Authentication code: 15

Linear to regular gamma RGB conversion, other stuff

Post by ElleStone »

I was trying to compile and use ImageMagick 6.7.8-6 to convert an image from one ICC color space profile to another, which led to a chain of peculiar events. In reverse order:

(4) Unexpected results using "convert" to convert from one ICC profile to another:

Short version: ImageMagick depresses the darkest colors upon converting from a linear gamma to a regular gamma version of the same ICC profile. Or I'm doing something stupidly wrong.

Long version: Upon converting a test image *from* a linear gamma version of the scarse prophoto ICC profile *to* the regular gamma=1.8 scarse prophoto ICC profile, using lcms2's "tificc" utility and also using Cinepaint, the Cinepaint and tificc values match. Upon doing the same conversion using ImageMagick, the ImageMagick values do not match the Cinepaint/tificc values.

Results when eye-droppering the darkest three blocks of the test image after conversion to regular 1.8 gamma ProPhoto:

tificc conversion: 0, 3021, 4439
Cinepaint conversion: 0, 3020, 4439
ImageMagick conversion: 0, 1437, 2874

Notice how the ImageMagick values are approximately half what they should be (assuming tificc is right, and that I used tificc correctly). There are actually ten blocks in the test image, each block twice as bright as the block before (in RGB/XYZ space, not in Lab space). The brighter the block, the closer the ImageMagick value is to the tificc/Cinepaint value. By 14085 (on a scale from 0 to 65535) the values are essentially identical.

This forum post might be relevant: viewtopic.php?f=3&t=20751&p=83893&hilit ... RGB#p83893
"However the page has been updated with the latest fixes that IM uses and IM passes the tests when images are correctly processed with colorspace or gamma correction. It also points out that the two are slightly different, but with the most differences in the extreme dark colors." I'm assuming the test is the Brasseur linear gamma scaling test? Anyway, notice the comment about "differences in the extreme dark colors".

I've seen this same depression of the lowest values in my test image upon conversion to a regular gamma color space from a linear gamma version of the same color space in several different "gui" image editors. Either there is a problem that all these editors share, or I'm doing something stupidly wrong and hope some kind soul will point out what that "something stupidly wrong" might be.

The linear gamma version of the test image does have the ICC profile embedded. ImageMagick command line:
convert -depth 32 -intent Relative linear.tif -profile scarse-prophoto.icc linear-ImageMagick2regular-relnobpc.tif

tificc command line:
tificc -v -i linear-scarse-prophoto.icc -o scarse-prophoto.icc -e -w 16 -c 0 -t 1 linear.tif linear-tificc2regular-relnobpc.tif

link to the linear gamma test image (in case anyone wants to check my results themselves):
http://ninedegreesbelow.com/temp/conver ... linear.tif

link to the linear gamma scarse prophoto ICC profile:
ninedegreesbelow.com/temp/conversion-test/imagemagick/scarse-prophoto/linear-scarse-prophoto.icc

link to the regular 1.8 gamma scarse prophoto ICC profile:
ninedegreesbelow.com/temp/conversion-test/imagemagick/scarse-prophoto/scarse-prophoto.icc

This ImageMagick forum post might also be relevant:
viewtopic.php?f=1&t=21281

The reason I was trying to compile ImageMagick 6.7.8-6 (see 1 below) was to see if the problem might have been fixed in 6.7.8-6.

(3) Started with RGB, ended up with Grayscale:
This is probably a feature, not a bug. After doing an ICC profile conversion using ImageMagick, even though the test image is "black and white" because everywhere R=G=B, it really is an RGB, three-channel image. For some reason ImageMagick outputs it as a grayscale image. Undoubtedly there is a switch to avoid this unwanted behavior. But it was a bit surprising.

(2) "This Connection is Untrusted":
While using Google to find relevant forum entries, frequently, but not always, this message pops up upon attempting to open a forum link:
https://www.imagemagick.org/discourse-s ... =1&t=21305
"This Connection is Untrusted
You have asked Firefox to connect securely to http://www.imagemagick.org, but we can't confirm that your connection is secure.
Normally, when you try to connect securely, sites will present trusted identification to prove that you are going to the right place. However, this site's identity can't be verified."

(1) I installed 6.7.8-6, quantum depth 32, but what I got was 6.7.6-9, quantum depth 16:
I'm running OpenSuse 12.1 Tumbleweed, with a few extra repositories thrown in. Originally ImageMagick was installed from OpenSuse. I uninstalled ImageMagick and restarted the computer. I downloaded "ImageMagick-6.7.8-6.tar.gz 22-Jul-2012 08:40 12M" from http://www.imagemagick.org/download/, extracted ImageMagick, and built it using:
./configure --with-quantum-depth=32 --enable-hdri
make
make install"

Running: "/usr/local/bin/identify"
produces: "Version: ImageMagick 6.7.6-9 2012-05-16 Q16 http://www.imagemagick.org". Neither the version nor the quantum depth match the version I downloaded and (thought I) installed.

Running: "/usr/bin/identify" produces: "bash: /usr/bin/identify: No such file or directory", so the original ImageMagick from the OpenSuse repository is definitely gone. All the ImageMagick files in /usr/local/bin have today's date and the correct time for having been created as I (thought I) was building 6.7.8-6. The version of ImageMagick previously installed (in /usr/bin) was earlier than 6.7.6-9 (perhaps 6.7.2ish). There has never been any other version of ImageMagick installed on this computer.

To summarize:
Of lesser importance: Why 6.7.6-9 instead of 6.7.8-6? And why quantum depth 16 instead of 32 as per the configure command line that I used?

The real question: Is there a bug that can account for the discrepencies between tificc and Cinepaint, on the one hand, and ImageMagick and various "gui" image editors, on the other hand? Or am I doing something stupidly wrong?

Elle
ElleStone
Posts: 7
Joined: 2012-07-23T08:02:50-07:00
Authentication code: 15

Re: Linear to regular gamma RGB conversion, other stuff

Post by ElleStone »

Sorry, here are the correct links to the ICC profiles:

link to the linear gamma scarse prophoto ICC profile:
http://ninedegreesbelow.com/temp/conver ... ophoto.icc

link to the regular 1.8 gamma scarse prophoto ICC profile:
http://ninedegreesbelow.com/temp/conver ... ophoto.icc

Elle
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Linear to regular gamma RGB conversion, other stuff

Post by magick »

Your image is interpreted as sRGB rather than linear gray because its 3 channel RGB. If the image was a single channel gray, its interpreted as linear gray. You can force linear with the -colorspace RGB option.
Post Reply