Page 1 of 1

Adjusting colors to match calibrated sample

Posted: 2014-01-10T13:14:37-07:00
by aporthog
I'm trying to automatically adjust color images taken with two bookscanner cameras to match, more or less, the colors of the same page as scanned by a calibrated flat bed scanner. Here are the two images (Full size tiff versions are in ... ick/colors ):

Left camera:

Calibrated flatbed:

My idea was to use -level and -channel to adjust each RGB value as necessary to match the calibrated version. What I did was crop out a section of red, green, blue, and cyan from each image and a got the average RGB value from each of those 4 images.




Code: Select all

red_q13.tif: 229,34,45
green_q13.tif: 1,145,75
blue_q13.tif: 73,58,142
cyan_q13.tif: 0,159,222

red_left.tif: 179,31,29
green_left.tif: 65,161,41
blue_left.tif: 59,48,161
cyan_left.tif: 83,155,233
I naively thought that if the R channel of red_left.tif was off by 50 then the R channel of green_left.tif, blue_left.tif, cyan_left.tif would be off by about the same amount. But I can't see any rhyme or reason to how the channels differ for each image. I then created a 4 pixel long image of each color and took the average color of THAT to see if it gave me a satisfying values for each channel to adjust but the results are not good. The pages' whites are still a bit gray and dingy and the colors don't match the actual book pages.

I guess I have a lot to learn about color. I'm not looking for anything near perfection, just some adjustment I can make automatically to every single page image to make them close to real life. Any ideas?

Re: Adjusting colors to match calibrated sample

Posted: 2014-01-10T14:13:49-07:00
by snibgo
The colour selectivity of the two scanners probably don't match, so an approach that regards the three channels as independant won't work.

Hald-clut is a better approach. This is a look-up table that specifies, for any input colour, the desired output colour. You know the desired transformations for 18 colours, so you need to interpolate the rest. This is quite complex and I don't have a script for this. fmw42 might have, at . A compiled program may be more suitable.

Re: Adjusting colors to match calibrated sample

Posted: 2014-01-10T14:54:01-07:00
by GreenKoopa
snibgo is right that this can be quite complex, so creating your own solution will only get you so close.

Adjustments may be easier in a cylindrical color space, i.e. one with hue. If you can achieve the adjustments you want using GIMP, Photoshop, etc, you can use snibgo's hald-clut suggestion to carry those adjustments over to ImageMagick. GIMP's hue-saturation tool, or Photoshop's equivalent, may help.

Re: Adjusting colors to match calibrated sample

Posted: 2014-01-10T15:09:44-07:00
by aporthog
Thanks, I looked up Hald CLUT in the IM documentation and seems to be exactly what I want. I think creating a CLUT from the 18 colors I have and interpolating the rest is a task beyond me. What should work is doing the adjustment in Photoshop and generating a CLUT from that. I assume Photoshop can't export a Hald CLUT, but could I do the adjustment to my camera image, save it, then apply it to an identity CLUT I create with IM to create a new Hald CLUT?

Re: Adjusting colors to match calibrated sample

Posted: 2014-01-10T15:15:50-07:00
by GreenKoopa
Create a hald image using IM. Append it to your image and save in a lossless format. Make the adjustments in whatever program you like (including IM). Crop out the now adjusted hald image. Use IM and the adjusted hald color look-up table to apply the adjustment in batch to all your images.

Re: Adjusting colors to match calibrated sample

Posted: 2014-01-10T17:07:16-07:00
by aporthog
Appending the clut, adjusting the image in PS, then cropping it back out again worked like a charm! Thanks everyone.