Page 3 of 3

Re: White Balance Correction Using a Grey-card Reference

Posted: 2012-11-26T17:48:00-07:00
by fmw42
snibgo wrote:If white is taken as 100% and black as 1/60th of this, 100%/60 (=1.6667%), the geometric mean is sqrt (100 * 100/60) = 12.9099%.

Thanks. That makes more sense and show where the 13% value originates. I did not realize black was not 0. But as I said, I know very little about photography. I appreciate this clarification. So I learned several things new today.

Re: White Balance Correction Using a Grey-card Reference

Posted: 2012-11-27T00:16:33-07:00
by rcolba
@fmw42:
The wbref.jpg image is intended to be an picture of a grey or white reference chart taken under the same illumination conditions, most importantly the same color temperature. It shouldn't matter whether it is white or grey, as long as it is pure, meaning that R, G and B values are the same. These charts are common photography accessories.
White balance should be set to manual on your camera in order to prevent it from doing the correction similar to what we are doing with the script. (There would be a double correction otherwise.)
In order to try this processing, you can use the pictures provided in the beginning of this thread by user stupid.
Robert

Re: White Balance Correction Using a Grey-card Reference

Posted: 2012-11-27T11:18:44-07:00
by fmw42
rcolba wrote:@fmw42:
The wbref.jpg image is intended to be an picture of a grey or white reference chart taken under the same illumination conditions, most importantly the same color temperature. It shouldn't matter whether it is white or grey, as long as it is pure, meaning that R, G and B values are the same. These charts are common photography accessories.
White balance should be set to manual on your camera in order to prevent it from doing the correction similar to what we are doing with the script. (There would be a double correction otherwise.)
In order to try this processing, you can use the pictures provided in the beginning of this thread by user stupid.
Robert

Thanks for the clarification.

Fred

Re: White Balance Correction Using a Grey-card Reference

Posted: 2012-12-17T22:49:42-07:00
by anthony
This is a nice solution. But is this the right solution?

Overlay composition is used to add highlights and shadow textures, it isn't really meant for this use.

I would have thought a 'divide' would have been the right solution to make the white card white.
http://www.imagemagick.org/Usage/compose/#divide

Though you probably want the white card slightly grey in the final image not truely white.
Perhaps that is why they use a 'grey card'?

The true test is to apply the 'fix' to the original reference image.

Code: Select all

convert reference.jpg \
        \( +clone -gravity center -crop "50x60+0+0" \
           -scale 1x1! -negate -scale 400x300! \) \
        -compose overlay -composite \
        test.jpg
Is the 'white card' in the test image now the right grayscale shade?

Re: White Balance Correction Using a Grey-card Reference

Posted: 2012-12-18T10:01:11-07:00
by snibgo
The "traditional" method of correcting white balance is by multiplying the red by a certain factor, and the blue channel by another factor, in linear space (not sRGB).

The "divide" operator will do this, although in sRGB space. The other issue is that if the image of the gray card isn't mid gray, it will shift the tones in the image. (It doesn't matter whether the card is actually white or gray; IM just does arithmetic. If the pixel values are above 50%, "divide" will darken the image.)

In practise, I find that multiplying two channels by factors works well for consistent lighting conditions -- when all the objects in the photograph receive the same light. This is often not the case, especially when clouds are the lightest part of the scene. Do I balance for the clouds or foreground? Balancing the foreground with the "traditional" method will often create a horrible cast in the sky. In these conditions, "overlay" works better as it shifts the balance in the mid-tones but the effect fades away to zero at black and white pixels.

For very critical work, I use a script to extract grey patches at different tone levels (eg bright cloud, white card in sun, white card in shadow, grey card, etc) and software that generates a pair of channel curves that ensures all the gray patches become gray in the output image.

Re: White Balance Correction Using a Grey-card Reference

Posted: 2012-12-18T15:58:49-07:00
by anthony
Thank you for the clarification. It makes sense.

Note that you can convert images from sRGB to linear RGB for the composition then convert back again, after the re-balancing.

With scenes involving sky, sunlight and shadow, do you divide the image into different areas for separate adjustment?
Or just generate a single curve from all the reference cards?

Re: White Balance Correction Using a Grey-card Reference

Posted: 2012-12-18T16:28:10-07:00
by snibgo
I just use a single curve for one channel, and another for a second channel, that covers all areas. The curves are derived from all the patches.

True, this assumes that the required balance is determined by the local tone in the photograph, when in fact it's determined by what light falls on the subject. I could divide the image as appropriate but, in practise, I find that the assumption is sufficiently accurate.