How to apply the same white balance to a series of images in matlab?

8 views (last 30 days)
Hi, I have images taken every second of a fluid moving between two parallel plates. I am using RAW images from a canon 50d camera that I have converted to a .dng format, linearized, and demosaiced in matlab. However, my images have a greenish-tint to them after I view them in matlab after applying the code I have to demosaic them. I have been reading various blogs and other forums online and have noticed that other people typically have images with a greenish tint to them as well. They recommend white balancing the images to get rid of this greenish hue. However, I can't seem to really grasp how to apply a white balance to my images in matlab, I also cannot use an "auto" white balancing code because I need to control every step in the image processing for every image (I need to apply the same code to every image, since this is scientific work as opposed to just recreational work). I hope this makes sense, Thanks!

Accepted Answer

Image Analyst
Image Analyst on 12 Dec 2017
Edited: Image Analyst on 12 Dec 2017
You need to have something in your image that you know for a fact is defined to be white. For example, the X-rite Color Checker Chart is embedded in each snapshot. Then segment or extract the white region, and multiply each color channel by the appropriate factor such that all white region intensities (in each color channel) all have the same value. This simple method should probably be good enough for your situation, though there are more sophisticated methods.

More Answers (1)

Mahmoud Afifi
Mahmoud Afifi on 12 Aug 2019
You can use any simple algorithm to estimate the illuminant value instead of manually picking it. Here is an example of using gray-world algorithm to white balance your raw images.
I = reshape(image,[],3);
R = mean(I(:,1)); G = mean(I(:,2)); B = mean(I(:,3));
ill = [R G B];
I = I * diag(G./ill);
I(I>1) = 1; I(I<0) = 0;
outImage = reshape(I,size(image));

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!