Page 1 of 1

Scanning and colour spaces

Posted: 2018-09-30T14:47:53-07:00
by quack
I have slides scanned using VueScan, saved as 64-bit TIFFs and what VueScan calls RAW. The infrared channel is stored in the alpha channel. I do it this way because I can re-process (using dust removal, for example) directly from the RAW files without the lengthy 5 to 10 min each scan normally takes. This is just by way of background.

Each image thus is not colour or gamma adjusted. I have profiled the scanner using coloraid.de targets for my film type and produced an 'Agfa.icc' profile. This can be applied to the image directly using ACDSee, for example, and the resulting image 'looks correct'. I can use Gimp similarly but have to jump through a couple of more hoops to get there. I should say that I produce JPGs with no embedded colour profile and the colour conversion applied.

Using ImageMagick I am currently unable to produce the same output images, probably due to my unfamiliarity with it. Naively I use

magick image.tif -intent perceptual -profile "Agfa.icc" image.jpg

I have used -colorspace arguments at various positions on the command line and nothing seems to affect what is written to "image.jpg".

I am sure that I am missing something obvious but am perplexed as to what it is.

Version: ImageMagick 7.0.8-11 Q16 x64 2018-08-29 (Windows 7 Pro)

Thanks for your help.

Re: Scanning and colour spaces

Posted: 2018-09-30T14:57:22-07:00
by snibgo
Assuming your image.tif contains no embedded profile, your command should assign Agfa.icc, which seems reasonable. But if it already has a profile, your command will convert to the new profile, which I expect is wrong.

Check the image.jpg to ensure it contains the embedded icc profile.

If your Gimp process works, I suggest you list the steps here. I expect they can be replicated in IM.

I suggest you post links to a sample image.tif and Agfa.icc so we can test.

Re: Scanning and colour spaces

Posted: 2018-10-01T00:34:51-07:00
by quack
Dear snibgo,

Thank you for your reply. I include links to 'image.tif', 'image.jpg' (which is what I would expect), and 'Agfa.icm'.

http://202.161.120.48/image.tif

http://202.161.120.48/image.jpg

http://202.161.120.48/Agfa.icm

The process I need to use with Gimp is:

1. Import image.tif
2. Add layer mask|White
3. Apply layer mask
4. Remove alpha channel
5. Image|Color Management|Convert to Color profile...|Agfa.icm
6. Image|Precision|Linear light
7. Export as image.jpg

Steps 2 and 3 are needed otherwise the RGB channels are modified when removing the alpha channel.

After step 5 the image is displayed correctly within Gimp but the export does not include the modified values. I do not understand why step 6 fixes this. I am not happy not to know because it is likely to haunt me when I least expect it.

Re: Scanning and colour spaces

Posted: 2018-10-02T15:24:10-07:00
by fmw42
I have repeated your steps in GIMP, but I cannot perfectly reproduce them in Imagemagick.

According to documentation adding a white layer mask should be equivalent to making the alpha channel opaque. See https://docs.gimp.org/en/gimp-layer-mask-add.html
With this option, the layer mask will make all of the layer fully opaque. That means that you will not notice any difference in the appearance of the layer until you paint on the layer mask.
But making the layer alpha channel to opaque in Imagemagick does not reproduce that. So I am puzzled what GIMP is actually doing.

Second, I have no idea what GIMP is doing with Precision and especially linear light. But I do not see much change when doing that.

Here is my Imagemagick result from

Code: Select all

convert image.tif -depth 8 -alpha opaque -intent perceptual -profile Agfa.icm image_fred.jpg
Image

I even tried several other agfa profiles, but no success in duplicating the GIMP results.

Re: Scanning and colour spaces

Posted: 2018-10-02T16:04:54-07:00
by quack
Dear Fred,

Thank's for looking into this for me; I appreciate your time. ImageMagick is a great command line tool and where I prefer to do my processing.

I will have to post to a Gimp forum to find out what they are doing with 'linear light'.

I shall also look closer at ACDSee to make sure that I understand what I am doing there.

Colour management still confuses me somewhat; not the process but what the defaults are in a particular program and what is applied when.

Thank you.

Re: Scanning and colour spaces

Posted: 2018-10-02T16:19:49-07:00
by fmw42
I would also be curious if you find out more about what GIMP does with a white layer mask and if there is more to it than what I found in the documentation and my interpretation of it.

Documentation here https://docs.gimp.org/en/gimp-image-precision.html says:
The Precision submenu contains commands which let you change the precision of the image. The Precision options affect the precision and channel encoding used for storing the image in RAM during processing.
and
On a very low-spec machine with not very much RAM, consider using 8-bit integer precision, in which case also choose the Perceptual gamma (sRGB) channel encoding (at 8-bit precision, if you choose the Linear light channel encoding your image will have horribly posterized shadows).
The second quote indicates that at 8-bit precision and linear light, the results would be badly posterized. I do not see any evidence of that. But perhaps you had chosen 16-bit precision.

So this linear light precision issue still puzzles me. But I am not a GIMP expert.

Re: Scanning and colour spaces

Posted: 2018-10-02T16:35:29-07:00
by fmw42
It is very odd. Yesterday, I could duplicate your result. But today every attempt seems to give a whitish washed out JPG. Also I am getting another window after selecting the precision that wants me to choose some dithering method. No matter what precision I choose, I still get the same washed out result. This is similar to some of the other commands that I tried yesterday.

I re-downloaded both your TIFF and your Agfa profile and repeated, but I am still getting washed out resulting JPGs. I am using GIMP 2.10.

Re: Scanning and colour spaces

Posted: 2018-10-02T17:23:04-07:00
by fmw42
OK. It seems to be something about saving to JPG in GIMP perhaps because JPG is 8-bit. If I save to 16-bit PNG, I can reproduce your result. Then if I use this command in Imagemagick, it also makes and image that appears identical visually to me. Here is the PNG result from

GIMP:
Image


Imagemagick:

Code: Select all

convert image.tif -alpha opaque -intent perceptual -profile Agfa.icm image_fred.png
Image

Re: Scanning and colour spaces

Posted: 2018-10-02T17:31:09-07:00
by snibgo
image.jpg has no profile, so I suppose it is encoded as sRGB. So we want the output from an IM command to be sRGB, also with no profile.

The profile inspector shows Agfa.icm has curves that are essentially linear, but with slight bumps. I'm not sure I could detect the effect of the bumps in an image.

In Gimp, Image | Precision | Linear light seems to have no effect on exported JPG files. It seems to be a setting that affects internal Gimp processes only.

Code: Select all

magick image.tiff -alpha off -profile Agfa.icm -profile ..\sRGB.icc -strip img_agfa.jpg
Image
The result img_agfa.jpg is very close to image.jpg, but slightly lighter. Perhaps the difference is between IM's sRGB.icc and Gimp's internal sRGB, though I don't think a difference there should be visible.

img_agfa.jpg is also very different to image.tiff with no alpha channel, so we are getting close.

Re: Scanning and colour spaces

Posted: 2018-10-02T17:35:50-07:00
by fmw42
Yes, snibgo is right. I had not noticed since yesterday when I discarded your JPG. But my two PNG results are slightly lighter than what you presented as your JPG result. So I am still puzzled why I cannot reproduce your GIMP result today. I was sure I had done it yesterday, but perhaps I just did not notice.

Re: Scanning and colour spaces

Posted: 2018-10-02T17:53:57-07:00
by snibgo
There seems to be something weird about Agfa.icm, that IM v7.0.7-28 doesn't like, but doesn't report errors. For example:

Code: Select all

f:\web\im\agfascan>%IMG7%magick imagec.tiff -alpha off -profile ..\sRGB.icc -profile ..\Agfa.icm -strip +write info: img_agfa2.jpg
That commands make no output, neither text from "info:" nor an image. Other profiles work fine.

Re: Scanning and colour spaces

Posted: 2018-10-02T20:53:19-07:00
by quack
Dear snibgo and Fred,

Thank you very much for your efforts.

I used snibgo's ImageMagick command line to produce 'img_agfa.jpg' and can confirm that this is slightly lighter than my original 'image.jpg'. Which is correct (ImageMagick or Gimp) I cannot really determine. One could say that ultimately this matters little, and that I should just leave it, but it is a bit unsettling not to know what is happening.

Using snibgo's ImageMagick command line to produce 'img_agfa2.jpg' results in a magick.exe APPCRASH in MSVCR120.dll, so that might be why you observe no output. I notice that we run slightly different version of ImageMagick.

Re: Agfa.icm being weird. I used Argyll's 'scanin' to analyse the calibration slide from Wolf Faust, then 'colprof' to produce Agfa.icm. What it produces I do not know in detail (I do store the log files). Still, that is beyond the scope of my query to you.

Getting a washed up jpg with Gimp is what happens when I do not remove the alpha channel before exporting. Printing information on 'image.jpg' shows that it is 24-bit. I have 8 GB of RAM, so that is plenty for the 16-bit version of Gimp, and by scanning to 16 bits per channel and VueScan's 'HDR' mode I am able to maintain as much shadow detail as I can before converting to other lower-precision formats, albeit at the cost of disk space (which is cheap). You are right, there is no evidence of posterization. The 'correct' version (as shown in 'image.jpg' that I uploaded) I can obtain only by checking the linear light option before exporting, though the image shown in Gimp stays the same.

I am using Gimp 2.10.6. All this is done under Window 7 Pro 64-bit on a Thinkpad T520, but would be surprised if that had anything to do with it.

P.S. How do you embed the images directly in the post?

Re: Scanning and colour spaces

Posted: 2018-10-02T21:27:38-07:00
by quack
I should mention that using ACDSee the output is a lot closer to what I can achieve from Gimp (differences almost imperceptible were I not currently drawn to differences), than from ImageMagick, but accept that that does not mean that ACDSee and Gimp are more correct. However, they are more pleasing to my eye.

Re: Scanning and colour spaces

Posted: 2018-10-02T22:58:34-07:00
by fmw42
This forum does not allow direct uploading. You must post to some free hosting service and put the URLs here.

When I got the washout image from GIMP, I had turned off the alpha channel. I could figure out how to actually remove it. But it should not have had an effect with JPG, since JPG does not support transparency. So that also was confusing.