I am working on a project where colour is an important component. I need to compare the colours of subjects between photos, however the lighting between photos is not absolutely consistent and so the colours are inconsistent and skewed.
I have a colour standard present in every photo, of which I know the precise colours. I have a separate PNG of it and would like to use it as a reference for the other photos so that the colour/lighting can be matched up. The problem is that I cannot figure out how to achieve this – especially in a timely manner. I have a couple hundred photos that I have to analyze so manual tweaking of the colour curves will not do. Instead, I need some automated way (or semi-automated) to be able to run through the photos and accurately match the colour standards in each photo to the true colour standard, ensuring that the lighting/colouration in each photo overall is consistent throughout.
I am using GIMP to try to figure all of this out, so references to it specifically would be more helpful than talking about Photoshop.
I have tried the match histogram script that can be downloaded via this link
http://www.silent9.com/blog/archives/162-Gimp-Script-Histogram-Match.html
that Rob A made a while ago, but it doesn’t quite work the way I need it to; the colours of the standard in the edited photo don’t match up to the true standard properly.
This is an image containing the subject and the standard for scale and colour reference.
I need the standard in this photo to match the true colour standard (could not provide due to low reputation!)so that the colours of the subject are accurately represented in the photograph.
Thank you for any help you can give – I really appreciate it.
Andrew
[edit]In response to Mark Setchell,
Sorry – I’ve been away for the past little while and this project was set on the back burner.
I tried your method, however, the colours on the colour card in the photo needs to match their true RGB values. When I did your method, it did get rid of that blue colour cast that you referred to which is awesome, but it didn’t let me alter the photo to view it in its “true colours”.
For example, I averaged the RGB values for top right corner red tile in a photo and got R: 173.7 G: 64.2 B: 38.0. However, the true colour of that tile (as quoted from the manufacturer of the colour card) is supposed to be R:162 G: 60 B: 60. I’ve tried various methods to match the tiles but the difference in RGB values across the different colour tiles is not uniform – what I mean by that is that the difference in R values for the red tile mentioned above is 173.7-162=11.7, but for the yellow tile underneath it, the difference in R values (in-photo and true colour) is 44.7. There doesn’t seem to be a pattern so I’m not sure how to go about this.
The fact that it matches is imperative as the true colour of the shell needs to be quantified and used in statistical analysis. If I use values that do not truly represent the shell, then the statistical work done will be irrelevant as it would not reflect the true colour of the shell.
Do you get what I’m saying?
Sorry again for taking a while to get back. Hopefully you can help me out with this!
2
Answers
I normally use Photoshop to colour correct – using the grey eyedropper on a grey midtone. As you don’t want Photoshop solutions, I would fall back to Imagemagick which is free and installed on most Linux distros and is available for OSX and Windows – it also has Python, Perl, PHP, .NET, Ruby and Java bindings but I am just using it at the command prompt in the Terminal here.
Basically, one way of colour correcting is to find a midtone and see how far it is from pure grey (i.e. from all the colour components being equal) and then applying that distance as a correction. So, in your image, I can find the mid-grey tile and crop it out like this:
I can also see its components by squidging it (TM) down to a single pixel by averaging and asking ImageMagick to tell me what that value is:
So the red and green are higher than the blue – it has a colour cast.
To correct it, one approach would be to get that colour and negate (invert) it and then apply that inverse of the colour cast to the entire image like a colour (correction) wash. I would do that like this:
So, the
( ... )
sets up some “aside processing” in which I clone the original image and crop out the grey tile. I then average that grey by resizing it to a single 1×1 pixel. Then I invert it to make it a correction and rescale it back up to the original size. That resulting wash is then applied to the original image by compositing it as an overlay.If your grey card moves around between images, there is a bit more work to do to locate the mid-grey tile, but that shouldn’t be insurmountable.
I guess you could adapt and use this technique with the GIMP, but that is not something I am familiar with.
Luca de Alfaro’s white balance script does more or less what you need. It changes the tone of the whole image so that a color in the image exactly matches a reference.
It can also take one color and make it exactly gray (with same luminosity), so typically you just sample something that should be gray/white (such as a gray chart, a sheet of paper, the dishwasher or the cap of a Nutella jar) and run the script.
Source code of the script shows that doing it right is a bit more complex than it seems.