A Photography forum. PhotoBanter.com

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » PhotoBanter.com forum » Digital Photography » Digital Photography
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Formulas for white balance and exposure models



 
 
Thread Tools Display Modes
  #1  
Old January 3rd 06, 06:05 AM posted to rec.photo.digital
external usenet poster
 
Posts: n/a
Default Formulas for white balance and exposure models

Right now, I am working with a pretty cheap Kodak digital camera, using
series of photos to make panoramics by stitching with Hugin/Panotools.
The camera has two particular annoyances that make this more
difficult...
(1) It sets white balance automatically at every single shot, and
records only "Auto" in the Exif data for white balance. The white
balance is not always consistent; I can have two shots at about the
same time with the same exposure and get different colors in them (i.e.
a purple sky in one, a blue sky in the other).
(2) It sets exposure time automatically (though it allows +- 2 EV
offset). I guess I can't be too annoyed about this, as it's a standard
feature and it gives the proper data in Exif, but I need to find how to
correct it.

I have searched around online for some formulas used to set white
balance, but so far all I have found is about 100 sites that only
really explain why you would use white balance. I suspected a pretty
simple relationship, like multiplying each channel by the scale factors
that set a white point a,b,c equal to 1,1,1, but some people told
me it would be logarithmic, and one reference said it was a lot more
complex than that to deal with the different color temperatures.

I have also been searching for some models of how a CCD exposes - for
instance, to predict color values given a change in exposure value. I
tried to work with some data from my camera, but it was too coarse of a
sampling to tell me much.

Does anyone have any useful references for either of these? A better
camera is in the works (one with RAW and manual everything) but in the
meantime I have some older files that need correction, and I've never
been successful at doing it by eye.

Thanks,
-Chris Hodapp

  #2  
Old January 3rd 06, 06:40 AM posted to rec.photo.digital
external usenet poster
 
Posts: n/a
Default Formulas for white balance and exposure models

Read this article to see if it helps.
http://www.anandtech.com/digitalcame...oc.aspx?i=2380

Marten

wrote in message
oups.com...
Right now, I am working with a pretty cheap Kodak digital camera, using
series of photos to make panoramics by stitching with Hugin/Panotools.
The camera has two particular annoyances that make this more
difficult...
(1) It sets white balance automatically at every single shot, and
records only "Auto" in the Exif data for white balance. The white
balance is not always consistent; I can have two shots at about the
same time with the same exposure and get different colors in them (i.e.
a purple sky in one, a blue sky in the other).
(2) It sets exposure time automatically (though it allows +- 2 EV
offset). I guess I can't be too annoyed about this, as it's a standard
feature and it gives the proper data in Exif, but I need to find how to
correct it.

I have searched around online for some formulas used to set white
balance, but so far all I have found is about 100 sites that only
really explain why you would use white balance. I suspected a pretty
simple relationship, like multiplying each channel by the scale factors
that set a white point a,b,c equal to 1,1,1, but some people told
me it would be logarithmic, and one reference said it was a lot more
complex than that to deal with the different color temperatures.

I have also been searching for some models of how a CCD exposes - for
instance, to predict color values given a change in exposure value. I
tried to work with some data from my camera, but it was too coarse of a
sampling to tell me much.

Does anyone have any useful references for either of these? A better
camera is in the works (one with RAW and manual everything) but in the
meantime I have some older files that need correction, and I've never
been successful at doing it by eye.

Thanks,
-Chris Hodapp



  #3  
Old January 3rd 06, 06:44 AM posted to rec.photo.digital
external usenet poster
 
Posts: n/a
Default Formulas for white balance and exposure models

I use the open source "ufraw" plug-in with "gimp" software. I really
like the white balance features of ufraw. I have been wanting to
reverse-engineer the algorithms from the source code, for use in other
parts of the "gimp." So far, I haven't found the time.

You can download ufraw source code from sourceforge if you are
interested.
--
David Arnstein |
|
  #4  
Old January 3rd 06, 07:15 AM posted to rec.photo.digital
external usenet poster
 
Posts: n/a
Default Formulas for white balance and exposure models

Are you suggesting then...
(a) Dig around in the source and find the formulas, or
(b) Use the Ufraw plugin on what's technically not RAW data? Can I do
this?

I guess I had always assumed that ufraw/dcraw was only for conversion
of RAW data, and it never totally hit me that the source would contain
white balance formulas.

  #5  
Old January 3rd 06, 08:11 AM posted to rec.photo.digital
external usenet poster
 
Posts: n/a
Default Formulas for white balance and exposure models

In article .com,
wrote:
Are you suggesting then...
(a) Dig around in the source and find the formulas, or


Yes. I apologize for being vague. I have been wanting to extract the
ufraw algorithms myself, but I have not found the time.

(b) Use the Ufraw plugin on what's technically not RAW data? Can I do
this?


I don't think this is possible.

I guess I had always assumed that ufraw/dcraw was only for conversion
of RAW data, and it never totally hit me that the source would contain
white balance formulas.


All I know is that I have enjoyed great success with the color
adjustment features of ufraw. I don't know (yet) if it will be
practical to apply these features to a generic image in the gimp.
--
David Arnstein |
|
  #6  
Old January 3rd 06, 08:28 AM posted to rec.photo.digital
external usenet poster
 
Posts: n/a
Default Formulas for white balance and exposure models


schreef in bericht
oups.com...
Right now, I am working with a pretty cheap Kodak digital camera, using
series of photos to make panoramics by stitching with Hugin/Panotools.
The camera has two particular annoyances that make this more
difficult...
(1) It sets white balance automatically at every single shot, and
records only "Auto" in the Exif data for white balance. The white
balance is not always consistent; I can have two shots at about the
same time with the same exposure and get different colors in them (i.e.
a purple sky in one, a blue sky in the other).
(2) It sets exposure time automatically (though it allows +- 2 EV
offset). I guess I can't be too annoyed about this, as it's a standard
feature and it gives the proper data in Exif, but I need to find how to
correct it.

I have searched around online for some formulas used to set white
balance, but so far all I have found is about 100 sites that only
really explain why you would use white balance. I suspected a pretty
simple relationship, like multiplying each channel by the scale factors
that set a white point a,b,c equal to 1,1,1, but some people told
me it would be logarithmic, and one reference said it was a lot more
complex than that to deal with the different color temperatures.

I have also been searching for some models of how a CCD exposes - for
instance, to predict color values given a change in exposure value. I
tried to work with some data from my camera, but it was too coarse of a
sampling to tell me much.

Does anyone have any useful references for either of these? A better
camera is in the works (one with RAW and manual everything) but in the
meantime I have some older files that need correction, and I've never
been successful at doing it by eye.

Thanks,
-Chris Hodapp

Why don't you make them beautiful B&W pano's?
All your problems will be solved then.
Aad


  #7  
Old January 3rd 06, 01:20 PM posted to rec.photo.digital
external usenet poster
 
Posts: n/a
Default Formulas for white balance and exposure models

Why don't you make them beautiful B&W pano's?
All your problems will be solved then.


Perhaps I wasn't clear, white balance isn't my only issue - the
exposure is inconsistent too. I'm probably getting some vignetting on
top of that. And I can only hope that white balance doesn't alter the
brightness too much.
I'll probably end up converting some of them, but many of these
panoramics have really brilliant color that I don't want to lose... or
they are still grainy or slightly motion blurred. I guess a tripod
might be in the future too.

-Chris

  #8  
Old January 3rd 06, 07:14 PM posted to rec.photo.digital
external usenet poster
 
Posts: n/a
Default Formulas for white balance and exposure models

writes:

I have searched around online for some formulas used to set white
balance, but so far all I have found is about 100 sites that only
really explain why you would use white balance. I suspected a pretty
simple relationship, like multiplying each channel by the scale factors
that set a white point a,b,c equal to 1,1,1, but some people told
me it would be logarithmic, and one reference said it was a lot more
complex than that to deal with the different color temperatures.


By the time you get the data, there are just 3 numbers per pixel. The
apparent colour is determined by the ratio of those 3 numbers. So white
balancing *is* just multiplying each channel by a scale factor to adjust
the apparent colour. If you are adjusting by eye, you just need to
provide a suitable user interface. If you adjust white balance by
selecting a sample of grey or white, the scale factors you need are
proportional to one over the RGB components (because a neutral colour
should have R=G=B after white balance correction).

Now, strictly speaking, the above applies to channel values that are
linearly proportional to light. So if you're working in 16-bit linear
space, you can do this directly. But if you're working in a simple
gamma-corrected space, it happens to be true that multiplying a linear
sample value by a number is equivalent to multiplying a gamma-corrected
sample value by a different number. So multiplies in linear space turn
into multiplies in gamma-corrected space, with just a difference in the
number values, and you can use the same method for both.

On the other hand, if you're working with logarithmically-coded pixels,
the multiplies in linear space turn into adds in log space. Or if
you're using some other odd encoding, you're probably best to convert
back to linear before adjusting things. But most digital camera images
are either linear or gamma-corrected.

If you're trying to deal with colour temperature directly, in the sense
that you want to correct an image that was shot with the camera set to
one colour temperature when the lighting was a different colour
temperature, determining the ratios you need is more complex. But if
you have an example of grey or white in your picture for reference, you
don't need to know what the actual colour temperatures are.

I have also been searching for some models of how a CCD exposes - for
instance, to predict color values given a change in exposure value. I
tried to work with some data from my camera, but it was too coarse of a
sampling to tell me much.


The output of a CCD is quite linearly proportional to light intensity,
if you get the raw data. One stop additional exposure doubles the pixel
values (after you've subtracted off fixed pattern noise and dark
current). So this is very simple.

If you're looking at a JPEG, it has at least been gamma-corrected, so
the data in the file is proportional to intensity to the 0.45 power.
This means that one stop additional exposure multiplies the pixel
values by 2^0.45 = 1.37. But there may have been additional
compression of the tonal scale at the black and white ends of the scale
that don't follow this rule.

CMOS sensors can have nonlinear processing at each pixel, so the above
may not necessarily apply to them.

Dave
  #9  
Old January 4th 06, 03:50 AM posted to rec.photo.digital
external usenet poster
 
Posts: n/a
Default Formulas for white balance and exposure models

On the other hand, if you're working with logarithmically-coded pixels,
the multiplies in linear space turn into adds in log space. Or if
you're using some other odd encoding, you're probably best to convert
back to linear before adjusting things. But most digital camera images
are either linear or gamma-corrected.

I'd better look in the manual for that, maybe it will give me some
numbers.

If you're trying to deal with colour temperature directly, in the sense
that you want to correct an image that was shot with the camera set to
one colour temperature when the lighting was a different colour
temperature, determining the ratios you need is more complex. But if
you have an example of grey or white in your picture for reference, you
don't need to know what the actual colour temperatures are.

I'm not so much concerned with getting white balance perfect in a
single photo, I'm more concerned about matching it across a few images.
I got fairly decent results by trying to match input/output levels
(basically the same as the linear relationship you described) but it
still had some annoying differences.

The output of a CCD is quite linearly proportional to light intensity,
if you get the raw data. One stop additional exposure doubles the pixel
values (after you've subtracted off fixed pattern noise and dark
current). So this is very simple.

I expected that would be the relationship, but the data from my camera
just isn't matching up with that. I guess it's either CMOS or it is
doing some thoroughly nasty postprocessing before JPEG conversion.

If you're looking at a JPEG, it has at least been gamma-corrected, so
the data in the file is proportional to intensity to the 0.45 power.
This means that one stop additional exposure multiplies the pixel
values by 2^0.45 = 1.37. But there may have been additional
compression of the tonal scale at the black and white ends of the scale
that don't follow this rule.

I'm thinking the camera (under the title "Kodak Color Science") does
all sorts of operations like that. I compared pixel values between one
stop of difference and got a ratio of about 1.4 to 1.6, which is pretty
close... does JPEG have a standardized gamma? I'd probably better do
some research.

So, I think you just described a few dozen more reasons to get a camera
that supports RAW.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
WHITE BALANCE ISSUES Colin D Digital Photography 4 December 22nd 05 12:39 AM
White Balance Questions Walt Hanks Digital SLR Cameras 15 July 8th 05 07:12 PM
Kodak LS443 coulour balance / over exposure thing. Any explanations? kodak user via PhotoKB.com Digital Photography 2 March 14th 05 02:42 PM
Auto Exposure Bracketing in Canon S50 Paul Ferguson Digital Photography 0 March 5th 05 11:48 PM
Digital Photo Exposure Compensation, White Balance In Photoshop A Digital Photography 9 December 20th 04 12:59 AM


All times are GMT +1. The time now is 01:17 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 PhotoBanter.com.
The comments are property of their posters.