Skip navigation.
KDE Developer's Journals

Photo KDE Tutorial 1-3: White balance

uga's picture

This is the 3rd tutorial in this series, trying to show how effective KDE photography applications can be for fixing and/or improving your photographs overall. In the first and second tutorials we addressed light exposure issues. Ie, we addressed photos that had regions gone too dark or too bright, and we showed how to fix them using either the levels tool or the curves tool.

In this third part we will continue addressing the light issues, but we will target color issues rather than brightness issues.

So lets begin!

Most of the times we use our cameras outdoors. Light is nice, sun shines, and we get nice pictures out of our cameras. But sometimes we need to take pictures indoors, in parties or conferences, and light conditions aren't the best. We even take pictures with flash, sometimes. So what's the problem? - you will ask. Well, many times when taking photos the effect goes unnoticed, but indoor lights are either tungsten lights (yellowish or orangeish) or fluorescent lights (more bluish), and depending on the light conditions, the photo results vary a lot.

Lets see the following example, from Akademy 2008 pictures, kindly donated by Sebastian Kügler for this tutorial:

Yes, it's Mike and Paul, while discussing backwards compatibility issues of core kdelibs changes, in a serious akademy meeting Sticking out tongue Uh, isn't Mike's face a bit reddish? does he actually look like this? is it due to the heated discussion they are having? ... oh wait... no, that's just poor lighting Eye-wink

So what happenned to that photo. Simply, the room was poorly illuminated by yellowish tungsten lamps, and the camera captured that nicely. Our eyes (or rather, our brain), compensate it automatically to identify the colors, but cameras not always manage doing that.

Most or all digital cameras these days allow correcting that when taking the picture, with an option called "white balance (WB) setting". The menu is usually similar to the following image:

If the camera was set like in this picture (light bulb/tungsten light selected), the picture would have turned out better colored. In the same camera menu, you will find many more options for cloudy/sunny days, fluorescent light, flash light, etc. Please refer to your own camera's manual for more details, since each particular camera is different.

By default, though, cameras are usually preset to AWB (auto white balance). This means that the camera will try guessing which setting of all is the most adequate in each case. It can work nicely, but honestly, most of the times they fail while indoors, like in this case.

So what to do now? Showfoto to the rescue again!!!!!!

Lets open the photo in Showfoto, and select the option Color->White balance... in the menu:

You will get the following dialog popping up:

It sounds complex, right? Well, it's very simple. The most important parts are the top two ones, marked in the image.

Both tools do exactly the same, but the input is a bit different in each case.

The second tool is what you already know. It's equivalent to the camera's White Balance Settings. There's different presets for each light types: 40watt lamps, 100 watt lamps... You can select one of them, and it should fix the colors, but... which of them is the correct one for our light source? hard choice huh?

The first tool is much more flexible. It allows adjusting the Kelvin Temperature of the light. The Kelvin temperature indicates just if the light source was warmer (reddish), or colder (bluish). The more you move the slider to the right, the orange/redder the image will become. The more you move it to the left, the more blueish it will turn. But this tool can be a bit hard to tweak, and usually requires extra hard work like adjusting the green color slider. Not very easy to do.

So what's the solution? It's easy. In the same dialog, right besides the Kelvin temperature setting, you will find a color picker as shown in the next picture. The color picker allows us selecting a point in the original image that should have been white or gray (i.e., not colored, same R=G=B values).

Most pictures have such places. For example, Mike's t-shirt is possibly white around his neck, given the photograph. So I clicked on it:

Impressive, isn't it? Yes, that's the power of white balance correction. Now you really get to see the real colors in the photograph. You can now know that his face isn't orange (Eye-wink), the wall was actually painted yellow, and his t-shirt was dark blue. You can adjust further the tool manually by adjusting the kelvin temperature, brightness of the picture etc (for length reasons, I will leave the exploring of those tools to the reader)

I could just be satisfied with this photo and be done with the tutorial, but I am not. Look at Mike's forehead, the tool has overexposed it and it's all white now. There's no information there, we clipped the histogram. Somehow, for reasons unknown to me, Showfoto's white balance tool has a tendency to do this in some photos where highlights exist and have little detail. And no matter how much you tweak the tool you may not get it right, like in this case. But I won't give up.

If you remember from the second tutorial, we learned how to adjust the brightness of the image using curves. Lets do it then. BEFORE applying the white balance tool, lets darken a bit Mike's forehead:

(Notice that moving the right point of the curves tool down is equivalent to using the levels tool, and moving the maximum output level left. Give it a thought Eye-wink )

And now yes, after repeating the same process, I got the forehead not that much overexposed:

In the same tool, I adjusted saturation a bit lower since the shadows were still a bit reddish, and yes. Now just press okay.
Before presenting the image, adjust a bit levels (as shown before in the first tutorial) and we are now done:

Another nice photo and tool for our collection Smiling

Thanks Mike and Paul for this great image and I really hope you enjoy these series. Feel free to give suggestions for improvements and cya in the next tutorial!

============
EDIT: as somebody pointed out, there might be some confusion when using certain terms.
When I wrote "The Kelvin temperature indicates just if the light source was warmer (reddish), or colder (bluish)",
"warm" and "cold" DO NOT mean the lamp's temperature (in centigrades). They refer to "color warmth". Red colors == warm, Blueish colors == cold
Just common photography terms, nothing to do with the physics of a tungsten lamp. Actually, you can say "the colder a tungsten fiber it is, the warmer (color) it shines" Eye-wink)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
alexander neundorf's picture

the white balance

Hi,

just some nitpicking about how to select the "white" area.

You shouldn't select an area which is very bright in the image, IOW make sure none of the channels (neither R nor G nor B) is 255 or very close to it (it may have been fully saturated but due to the image processing end up slightly below 255). If one of the channels is already 255 in the image, it probably wasn't exactly 255, but was clipped to the maximum value, so maybe the correct value would have been 300, but the range only goes up to 255. So choose a point which is more grayish, not white.
So I'm not sure the white T-shirt is the best choice, since it seems quite bright, in some places (according to kcolorchooser) red goes up to 253. So choose a point in a shadowed area of the T-shirt.

About the color picker: I don't know how it is implemented, but it shouldn't select a single point, but instead a small area, like 3x3. This will smooth away small variations in the "grayness" of the image. E.g. it could also be possible that some gray area gets slightly colored "stains" trough noise and JPEG compression. By using a small area instead of a single point this should give better results.

In the corrected image big parts of the T-shirt are almost 255-255-255. This means information has been lost. Ideally the overall brightness of the points shouldn't increase too much. So, I don't know how it is implemented. If the factors against red are calculated and then all points are multiplied with them, then the result would be very bright. Maybe this is what we see here. Maybe something more clever could be done. Maybe scaling everything to green (since this usually expresses the brightness quite good) ? Or calculating the brightness (sum of R + G + B ?) of the reference point and adjusting the factors so that it stays the same ?

Just some ideas...

Alex

uga's picture

Yes

"You shouldn't select an area which is very bright in the image,"

Very right indeed. Sorry that I missed commenting that. I usually go for gray levels. Actually I clicked on the top part of the neck stripe, which is darker.

"I don't know how it is implemented, but it shouldn't select a single point, but instead a small area, like 3x3. This will smooth away small variations"

I wish it did that, but I believe all white balance colro pickers I've seen select a point instead. Not sure if for accuracy reasons or what. But yes, you are right, averaging would do a much better work. It's how those filter disks for white metering work. Can you report that to bugs.kde.org? I think it'd be a nice feature to implement to digikam.

"In the corrected image big parts of the T-shirt are almost 255-255-255. This means information has been lost."

Could be, but it may be that the original colors were so high that compensation wasn't at all possible. I haven't coded this plugin myself. I tried my best to fix it without overexposing it. Also notice that I haven't worked with full sized pictures, but samples provided online. It's much easier that those scaled versions have high compression and lack of detail.

Thanks for all the suggestions!

dotancohen's picture

Here's a photo that I have been practicing on

Here's a photo that I have been practicing on:
http://en.wikipedia.org/wiki/Image:Victoria_Crater,_Cape_Verde-Mars.jpg

I would love to see what you could do with her. I have been able to get some of the detail of Cape Verde (the overhand on the left) to show, but I ruin the rest of the photo in the process. I have seen renditions where the whole thing looks detailed. This would be a great photo to summarize your first three tutorials with, as I have used techniques from all three.

Thanks!

uga's picture

Heh, there's much harder

Heh, there's much harder photos than that one, honestly Eye-wink
You just need to fix the white balance to show the middle area gray. Sky then will get fixed, although I'm not sure about the real colors since I wasn't there taking the shot. One should never attempt fixing a white balance of a photo that somebody else took Sticking out tongue
Then rise shadows to uncover details from under the rocks on the left part.

Do you have an e-mail or contact page to submit the result to? your profile doesn't show any

dotancohen's picture

Thanks, I have enabled the

Thanks, I have enabled the contact form:
http://www.kdedevelopers.org/user/6365/contact

Also, you can email me at <your-name-here><at>dotancohen<dot>com

I appreciate the tips, and I am enjoying learning the process. Thanks!

mikearthur's picture

Not Again

That picture will never die....

Also, my face is actually as red as a strawberry in real life so you've done it all wrong!

(Nice work, I look forward to trying it out!)

shaforostoff's picture

official docs

please add this to docbook documentation

uga's picture

trouble for that

That will be troublesome to do. All screenshots are in english version, so translators would need to reproduce all steps one by one. Then draw the lines etc. Not sure how many would offer themselves to do that.

Then there's the part of "image rights" issues. I don't think those people would like for their faces to turn up in every distro's packages Eye-wink so I'd rather replace those photos with others to avoid that.

And finally, the way it's written needs a few changes to become official docs.

The other option, is hosting tutorials elsewhere, and pointing to them from the application, but they'd be in english

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.