white balance problem

white balance problem

Post by Vojtech Tryh » Sat, 12 Jul 2003 16:56:48



Hi,

I'm writing an algorithm for manual chromatic adaptation of
photographs which were taken with bad white balance. I'm using
bradford matrix as described in
http://www.color.org/ICC_Minor_Revision_for_Web.pdf
Everything works fine except one thing. Pixels that have one or more
components saturated get wrong color - they are "overcorrected" I'd
say. What's worse, pixels around them are also affected although they
don't have any saturated component.
I've tried various tricks like to compute a saturation and less
process such pixels, but none of the tricks really helped.
If you have any ideas how to handle this problem or if you've already
solved it, I'd appreciate your help.

Thanks
Vojtech

 
 
 

white balance problem

Post by Hans-Bernhard Broeke » Sat, 12 Jul 2003 22:09:36



> I'm writing an algorithm for manual chromatic adaptation of
> photographs which were taken with bad white balance. I'm using
> bradford matrix as described in
> http://www.color.org/ICC_Minor_Revision_for_Web.pdf
> Everything works fine except one thing. Pixels that have one or more
> components saturated get wrong color - they are "overcorrected" I'd
> say. What's worse, pixels around them are also affected although they
> don't have any saturated component.

If any pixel of an image is saturated in any colour component, then
that image is technically over-exposed, and there's quite exactly
nothing you can do to avoid problems caused by that.  These horses are
_gone_, so no matter how tightly you close the barn doors now, it
won't help a bit.

Modifying the image in any way will tend to increase this problem if
you don't actively avoid it.  You'll have to either adapt your
white-balancing process to allow for a global darkening of the whole
image, to avoid driving even more pixels into saturation, or just live
with saturation artefacts.  At least clip over-exposure as part of the
modification, i.e. all results larger than maximum for a single colour
component must be mapped back to the maximum itself.  Same for
under-shoot, i.e. RGB drifting into the negative.

Quote:> I've tried various tricks like to compute a saturation and less
> process such pixels, but none of the tricks really helped.

You can't usefully do that on individual pixels.  Do it on the whole
image, instead.
--

Even if all the snow were burnt, ashes would remain.

 
 
 

white balance problem

Post by Gernot Hoffma » Sat, 12 Jul 2003 22:45:41



> Hi,

> I'm writing an algorithm for manual chromatic adaptation of
> photographs which were taken with bad white balance. I'm using
> bradford matrix as described in
> http://www.color.org/ICC_Minor_Revision_for_Web.pdf
> Everything works fine except one thing. Pixels that have one or more
> components saturated get wrong color - they are "overcorrected" I'd
> say. What's worse, pixels around them are also affected although they
> don't have any saturated component.
> I've tried various tricks like to compute a saturation and less
> process such pixels, but none of the tricks really helped.
> If you have any ideas how to handle this problem or if you've already
> solved it, I'd appreciate your help.

> Thanks
> Vojtech

Vojtech,

IMO, you are tackling the problem at the wrong end.

Lets have a look at the importance of the Bradford correction:
a) Lab values are converted to sRGB, using D50/D65 and Bradford.
b) Lab values are converted to sRGB, using D65/D65.
Reading back the sRGB values as Lab values in Photoshop shows:
a) Lab values are correct.
b) Lab values differ maximal 3 deltaE.
Obviously, the Bradford correction is not very important.

Now the photo:
The original scene light is unknown. Its never D50 or D65.
Real light can have a correlated color temperature, but if the
scene is illuminated by flash and tungsten as well, then "color
temperature" doesnt make any sense.

A formal color correction is simply impossible if one doesnt
know the spectrum of the scene light. Who knows the spectrum ?
It boils down to interactive corrections as usual, tweaking.

Now lets assume, the scene was about D50 and the camera was
corrected for D65. A compensation is theoretically possible.
For RGB values which are larger than 255 after the multipli-
cation by the Bradford matrix we can choose:
a) Strict clipping.
b) Proportional clipping.
   M=Max(R,G,B)
   If M>255 Then
   Begin
    s=255/Max
    R=R*s
    G=G*s
    B=B*s
   End
In my tests I found that proportional clipping doesnt improve
the appearance. The reason is the loss of luminance by p.c.,
Luminance loss is more perceivable than a slightly wrong hue.
Either method shouldnt affect NEIGHBOUR pixels. Probably a
programming error.
Clipping is applied in practically all image processing: some
interpolations, color and contrast corrections, sharpening.

Resumed:
A color correction has primarily nothing to do with the adaption
correction (Bradford, v.Kries). The latter is a subtle additional
feature, which takes human perception into account.
The color correction itself means physical colors (the image is
observed by an instrument).
The quoted doc doesnt tell us Bradford matrices. These have to
be calculated for the actual case and here we can choose ONLY
correlated color temperatures as references.

If all this should sound a little strict: comments and other
opinions are welcome.

Best regards  --Gernot Hoffmann

 
 
 

white balance problem

Post by Vojtech Tryh » Mon, 14 Jul 2003 06:12:08


Thank you for your answers.

It seems to me that my question made you think I'm not properly
handling color corrected data. I'm performing clipping and luminosity
correction, the problem I'm trying to solve is elsewhere.
Imagine an image with yellow cast over it. It is illuminated with one
light or multiple lights with a same temperature. I'm not that
foolish, that I'd attempt to fix images taken under multiple different
light sources. All light sources that appear in the image are
over-exposed. Also many objects that were close to the light have at
least one component overexposed. On such objects, the hue is near to
the original one, but it doesn't have that strong color cast as the
rest of the image.
If I apply a color correction on such image, all areas described above
will go blue. What's worse, the maximum channel value on problematic
pixels doesn't have to be 255 to show this problem.

my code looks like this:

for every pixel
  convert RGB to gamma 1
  convert to XYZ
  apply conversion matrix
  convert back to rgb
  clip rgb to <0,1> range
  modify rgb to have the same lightness as before conversion
  apply gamma and perform clipping again

I've made a modification which checks for over-saturated channels and
doesn't let them fall below certain level, but it's not perfect. As
I've mentioned before, there are pixels around light sources that have
a high level of one component (like 240),  you can't say these are
over-saturated, but they will be also too blue in the case I've
described. Truly I don't know why this happens.

I agree that the choice of matrix (identity or any advanced one) isn't
that important in most cases. But I think it might have its reason in
cases where the cast is so strong that one of the components goes zero
- by using the matrix you can transfer a part of the light power from
other components to the zero one. However this might be an unwanted
effect on objects that never had this missing color component.

I hope that this explanation is easier to understand. I don't think
it's a programming error, it's rather an expected effect that I'm
trying to suppress.

Regards
Vojtech Tryhuk

 
 
 

white balance problem

Post by Gernot Hoffma » Mon, 14 Jul 2003 23:55:12



> Thank you for your answers.

> It seems to me that my question made you think I'm not properly
> handling color corrected data. I'm performing clipping and luminosity
> correction, the problem I'm trying to solve is elsewhere.
> Imagine an image with yellow cast over it. It is illuminated with one
> light or multiple lights with a same temperature. I'm not that
> foolish, that I'd attempt to fix images taken under multiple different
> light sources. All light sources that appear in the image are
> over-exposed. Also many objects that were close to the light have at
> least one component overexposed. On such objects, the hue is near to
> the original one, but it doesn't have that strong color cast as the
> rest of the image.
> If I apply a color correction on such image, all areas described above
> will go blue. What's worse, the maximum channel value on problematic
> pixels doesn't have to be 255 to show this problem.

> my code looks like this:

> for every pixel
>   convert RGB to gamma 1
>   convert to XYZ
>   apply conversion matrix
>   convert back to rgb
>   clip rgb to <0,1> range
>   modify rgb to have the same lightness as before conversion
>   apply gamma and perform clipping again

> I've made a modification which checks for over-saturated channels and
> doesn't let them fall below certain level, but it's not perfect. As
> I've mentioned before, there are pixels around light sources that have
> a high level of one component (like 240),  you can't say these are
> over-saturated, but they will be also too blue in the case I've
> described. Truly I don't know why this happens.

> I agree that the choice of matrix (identity or any advanced one) isn't
> that important in most cases. But I think it might have its reason in
> cases where the cast is so strong that one of the components goes zero
> - by using the matrix you can transfer a part of the light power from
> other components to the zero one. However this might be an unwanted
> effect on objects that never had this missing color component.

> I hope that this explanation is easier to understand. I don't think
> it's a programming error, it's rather an expected effect that I'm
> trying to suppress.

> Regards
> Vojtech Tryhuk

Vojtech,

Hans-Bernhard is right: If any channel is clipped then the image
is spoiled. Therefore we have in (some) digital cameras the histo-
gram on the LCD screen. This replaces the good old exposure meter.

I cant see how you can solve the clipping problem by adaption cor-
rection. Its not a matter of a wrong white point setting.

One may try to reconstruct a reasonable unclipped image.
The only practical advice: Find areas in the image which are origi-
nally white or neutral gray und measure the unbalance.
Adjust this and correct similarly the whole image.
This is a matrix operation, valid for the test area. The same opera-
tion will of course create new clipping in other areas.

Once the correction matrix is found, this has to be applied to the
whole image by using a gamut compression. This is really difficult.
It can be done in CieLab, e.g. by projecting the values onto the sur-
face of the RGB volume (in CieLab), using  the center of projection
at e.g. L*=50. Or orthogonal to the volume surface (but this has
sharp edges). Or in radial direction to the RGB boundary in L*=con-
stant planes.  

By the way: Nicon D100 produces always underexposed images (according
to the histogram). One may think its a bug. No, its the policy to
avoid clipping under all circumstances.

Best regards --Gernot Hoffmann

 
 
 

white balance problem

Post by Gernot Hoffma » Mon, 14 Jul 2003 23:55:28



> Thank you for your answers.

> It seems to me that my question made you think I'm not properly
> handling color corrected data. I'm performing clipping and luminosity
> correction, the problem I'm trying to solve is elsewhere.
> Imagine an image with yellow cast over it. It is illuminated with one
> light or multiple lights with a same temperature. I'm not that
> foolish, that I'd attempt to fix images taken under multiple different
> light sources. All light sources that appear in the image are
> over-exposed. Also many objects that were close to the light have at
> least one component overexposed. On such objects, the hue is near to
> the original one, but it doesn't have that strong color cast as the
> rest of the image.
> If I apply a color correction on such image, all areas described above
> will go blue. What's worse, the maximum channel value on problematic
> pixels doesn't have to be 255 to show this problem.

> my code looks like this:

> for every pixel
>   convert RGB to gamma 1
>   convert to XYZ
>   apply conversion matrix
>   convert back to rgb
>   clip rgb to <0,1> range
>   modify rgb to have the same lightness as before conversion
>   apply gamma and perform clipping again

> I've made a modification which checks for over-saturated channels and
> doesn't let them fall below certain level, but it's not perfect. As
> I've mentioned before, there are pixels around light sources that have
> a high level of one component (like 240),  you can't say these are
> over-saturated, but they will be also too blue in the case I've
> described. Truly I don't know why this happens.

> I agree that the choice of matrix (identity or any advanced one) isn't
> that important in most cases. But I think it might have its reason in
> cases where the cast is so strong that one of the components goes zero
> - by using the matrix you can transfer a part of the light power from
> other components to the zero one. However this might be an unwanted
> effect on objects that never had this missing color component.

> I hope that this explanation is easier to understand. I don't think
> it's a programming error, it's rather an expected effect that I'm
> trying to suppress.

> Regards
> Vojtech Tryhuk

Vojtech,

Hans-Bernhard is right: If any channel is clipped then the image
is spoiled. Therefore we have in (some) digital cameras the histo-
gram on the LCD screen. This replaces the good old exposure meter.

I cant see how you can solve the clipping problem by adaption cor-
rection. Its not a matter of a wrong white point setting.

One may try to reconstruct a reasonable unclipped image.
The only practical advice: Find areas in the image which are origi-
nally white or neutral gray und measure the unbalance.
Adjust this and correct similarly the whole image.
This is a matrix operation, valid for the test area. The same opera-
tion will of course create new clipping in other areas.

Once the correction matrix is found, this has to be applied to the
whole image by using a gamut compression. This is really difficult.
It can be done in CieLab, e.g. by projecting the values onto the sur-
face of the RGB volume (in CieLab), using  the center of projection
at e.g. L*=50. Or orthogonal to the volume surface (but this has
sharp edges). Or in radial direction to the RGB boundary in L*=con-
stant planes.  

By the way: Nicon D100 produces always underexposed images (according
to the histogram). One may think its a bug. No, its the policy to
avoid clipping under all circumstances.

Best regards --Gernot Hoffmann

 
 
 

white balance problem

Post by Gernot Hoffma » Mon, 14 Jul 2003 23:57:09


My last message seems to be lost.
Therefore once again. Sorry if finally duplicated:

Vojtech,

       Hans-Bernhard is right: If any channel is clipped then the image
       is spoiled. Therefore we have in (some) digital cameras the histo-
       gram on the LCD screen. This replaces the good old exposure meter.

       I cant see how you can solve the clipping problem by adaption cor-
       rection. Its not a matter of a wrong white point setting.

       One may try to reconstruct a reasonable unclipped image.
       The only practical advice: Find areas in the image which are origi-
       nally white or neutral gray und measure the unbalance.
       Adjust this and correct similarly the whole image.
       This is a matrix operation, valid for the test area. The same opera-
       tion will of course create new clipping in other areas.

       Once the correction matrix is found, this has to be applied to the
       whole image by using a gamut compression. This is really difficult.
       It can be done in CieLab, e.g. by projecting the values onto the sur-
       face of the RGB volume (in CieLab), using  the center of projection
       at e.g. L*=50. Or orthogonal to the volume surface (but this has
       sharp edges). Or in radial direction to the RGB boundary in L*=con-
       stant planes.  

       By the way: Nicon D100 produces always underexposed images (according
       to the histogram). One may think its a bug. No, its the policy to
       avoid clipping under all circumstances.

       Best regards --Gernot Hoffmann

 
 
 

1. auto white balancing of video streams

Hello,

I'm looking for software and algorithms which I can use for doing
auto white balancing  on video streams (h.261). A pointer to
a ftp-site or to a book/paper would be great.

Please respond via email because I'm not reading this newsgroup
regularly.

        thanks in advance

                Nic
--

Technical University of Berlin             phone: +49-30-314-21294
http://www.prz.tu-berlin.de:80/~nicolai/     fax: +49-30-314-21114

2. Highlighting listview

3. Adjust white balance in PS CS

4. Corel Draw SDK - Structure File.

5. White balance

6. How to scan CMYK printed originals (de-screen Q)?

7. Has anyone used any Expodisc white balance filter products

8. Contour plotting for non-uniformly distributed data

9. batch? correction of wrongly set white balance

10. White balance, Color temperature and Adobe Camera Raw.

11. White Balance PS Actio

12. White balance with filter??