How to color correct an image from with a color checker

21 views (last 30 days)
We are developing an open source image analysis pipeline ( http://bit.ly/VyRFEr) for processing timelapse images of plants growing. Our lighting conditions vary dynamically throughout the day ( http://youtu.be/wMt5xtp9sH8) but we want to be able to automate removal of the background and then count things like green pixels between images of the same plant throughout the day despite the changing lighting. All the images have x-rite (equivalent) color checkers in them. I've looked through a lot of posts but I'm still a unclear on how we go about doing color (and brightness) correction to normalize the images so they are comparable. Am I wrong in assuming this is a relatively simple undertaking?
Anyone have any working code, code samples or suggested reading to help me out?
Thanks!
Tim

Accepted Answer

Image Analyst
Image Analyst on 15 Jun 2013
Tim: I do this all the time, both in RGB color space, when we need color correction to a standard RGB image, and in XYZ color space, when we want calibrated color measurements. In theory it's simple, but the code and formulas are way too lengthy to share here. Basically for RGB-to-RGB correction, you make a model of your transform, say linear, quadratic, or cubic, with or without cross terms (RG, RB, R*B^2, etc.). Then you do a least squares model to get a model for Restimated, Gestimated, and Bestimated. Let's look at just the Red. You plug in the standard values for your 24 red chips (that's the "y"), and the values of R, G, B, RG, RB, GB, R^2G, etc. into the "tall" 24 by N matrix, and you do least squares to get the coefficients, alpha. Then repeat to get sets of coefficients beta, and gamma, for the estimated green and blue. Now, for any arbitrary RGB, you plug them into the three equations to get the estimated RGB as if that color was snapped at the same time and color temperature as your standard. If all you have are changes in intensity you probably don't need any cross terms, but if you have changes in the color of the illumination, then including cross terms will correct for that, though sometimes people do white balancing as a separate step before color correction. Here is some code I did to do really crude white balancing (actually too crude and simple for me to ever actually use but simple enough that people can understand it).
I don't have any demo code to share with you - it's all too intricately wired into my projects. Someone on the imaging team at the Mathworks (I think it was Grant if I remember correctly) has a demo to do this. I think it was for the Computer Vision System Toolbox, but might have been for the Image Processing Toolbox. Call them and try to track it down. In the mean time try this: http://www.mathworks.com/matlabcentral/answers/?search_submit=answers&query=color+checker&term=color+checker
  9 Comments
Image Analyst
Image Analyst on 12 May 2020
I assume you're talking about RGB-to-RGB color correction, rather than RGB-to-LAB color calibration.
You say "for the other chips I have to apply the other alphas, betas and thetas specific to that square in order to get something correct." The alphas, betas, and gammas are independent of the RGB color. There is only one set of them and you can use them for any test RGB color to get the estimated gold standard/reference RGB color. So there are no "other" alphas, betas, and gammas -- there is only the one set of them. Let me be clear : you do not have a triplet of alphas, betas, and gammas for each of the 24 chips. There is only one set that is derived from all 24 of the color chips and those alphas, betas, and gammas apply to any color, any pixel for the entire image. I have no idea how you're getting 24 different sets of alphas, betas, and gammas (one for each chip) -- that doesn't make sense or even seem possible.
You say "I use slightly different values then I get a completely RGB value". I'm not sure what "different values" you're thinking of -- the "other" set of alphas, betas, and gammas you mistakenly mentioned (which doesn't exist), OR the RGB values. Of course if you plug different test RGB values in you will get different estimated values out. So basically I don't know what you're trying to describe with that sentence.
James Lauer
James Lauer on 12 May 2020
Edited: James Lauer on 12 May 2020
Thank you for the clarication, I knew I had done something really wrong I just couldn't figure out where (I'm new to programming and matlab).

Sign in to comment.

More Answers (1)

SC
SC on 17 Nov 2017
Hi, anyone aware of a toolbox/function in File Exchange that allows me to color correct an image using an X Rite chart?
Thanks

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!