Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How to do white balance ?

Could you please tell how to do white balance. I would like to get the real color of the image by my fluorescent  light source.
How should I do. I read from paper that we have to take image of white plate that we know the RGB value but I dont know how to do further to correct other images that I take to be correct RGB.


Thank you very much.

0 Kudos
Message 1 of 9
(6,201 Views)

What kind of camera are you using?  If it is a bayer encoded camera, you can use the white balance utility in MAX to take a picture of a white or gray card and balance it.  It will automatically adjust the coefficients of the bayer algorithm to give you a white balanced image.

If not, you can take a picture of a white or gray card and do it yourself.  Isolate the RGB components, then find the average intensity of each in a selected area.  Divide the largest value by each of the values to get the scaling factor for that color.  On a real image, split it into the RGB components, multiply each color component by the scaling factor for that color, then recombine the components.

Bruce

Bruce Ammons
Ammons Engineering
Message 2 of 9
(6,200 Views)

Dear Bruce

Thank you very much for your kindly reply. I shall follow your suggestion. May i ask one thing?

So we dont need the real RGB value that indicated at the white card right?

We only find the scaling factor from the image of white card we took right?

I am sorry if I ask awkward questions. 

Thank you very much. 

With Best reagrds,

Panmanas

0 Kudos
Message 3 of 9
(6,196 Views)

Dear Bruce

I tried to understand what you teach but still I dont understand. Could you please kindly clarify the following sentences for me.

-Isolate the RGB components, then find the average intensity of each in a selected area.  Divide the largest value by each of the values to get the scaling factor for that color.-

This I thought we do to get RGB and Intensity of each pixel of an area of white card. Then take average of Intensity of all pixels.

But I dont understand where to get the largest value. Is it the largest value of Intensity of a pixel from the selected area. I also dont understand what is the divider. Is the divider the average value of Intensity.

I also think that do we need the scale factor for R, G, and B. and Intensity.

Thank you very much.

With Best reagrds,

Panmanas

0 Kudos
Message 4 of 9
(6,188 Views)

When you take a picture of the white card, make sure it is not over-exposed.  Split the image into the RGB components using IMAQ Extract Color Planes.  Select the same ROI on all three color planes, and use the IMAQ brightness function to measure the average intensity of the ROI.  This gives you the values R, G, and B.  Pick the largest value and call it M.  The scaling factors for each color plane are M/R, M/G, and M/B.

Now, with a regular image, split the image into the RGB components.  Multiply each of the color planes by their scaling factor using IMAQ multiply.  Recombine the image using IMAQ Combine Color Planes, and you have a white balanced image.

I'm not sure if I used the correct names for all the IMAQ functions, so you may have to figure out the correct names.

Bruce

Bruce Ammons
Ammons Engineering
Message 5 of 9
(6,185 Views)

Dear Bruce

Thank you very much for your kind reply. We shall follow your sugestion. Thank you very much indeed.

With Best regards,

Panmanas

0 Kudos
Message 6 of 9
(6,162 Views)

Further advice for white balancing:

It is best to do the white balance within the camera if possible.  I recommend doing a preliminary white balance on the camera using the UB and VR settings to balance the blue and red components.  A final white balance with the bayer utility will work best.  In a separate post I talked about how to do this.

Bruce

Bruce Ammons
Ammons Engineering
Message 7 of 9
(6,006 Views)

Dear Bruce

Thank you very much for your new suggestion. I shall try to do on my camera. Anyway the method you teach us by calculating, we get a good result for our work. However, we still did see the image after doing white balance. We shall try to do it this summer.

Thank you very much again.

With best regards,

Panmanas

0 Kudos
Message 8 of 9
(6,003 Views)

When you take a picture of the white card, make sure it is not over-exposed.  Split the image into the RGB components using IMAQ Extract Color Planes.  Select the same ROI on all three color planes, and use the IMAQ brightness function to measure the average intensity of the ROI.  This gives you the values R, G, and B.  Pick the largest value and call it M.  The scaling factors for each color plane are M/R, M/G, and M/B.

Now, with a regular image, split the image into the RGB components.  Multiply each of the color planes by their scaling factor using IMAQ multiply.  Recombine the image using IMAQ Combine Color Planes, and you have a white balanced image.



Grt  grt explanation bruce. Thanx a lot
0 Kudos
Message 9 of 9
(5,520 Views)