Showing newest 4 of 6 posts from 6/28/09 - 7/5/09. Show older posts
Showing newest 4 of 6 posts from 6/28/09 - 7/5/09. Show older posts

Friday, July 3, 2009

Fixing Highlights and Shadows - Part 3: Shadows & Highlights Filter

In the previous part of this tutorial I presented you a technique to improve shadows and highlights using multiply and screen render modes. In this last part I want to present you a filter, which is not part of the standard Gimp distribution but which is freely available: Shadows & Highlights filter. After installing it, will be available in Filters -> Light & Shadow -> Shadows & Highlights menu.

This filter does not have the powers of its Photoshop counterpart but sometimes it may offer you nice results in a fast manner. I read a lot of critics on the Internet against this filter just because it has not preview facility. My question is: why do you need a preview? Taking in consideration how this filter works, it really makes no sense to have a preview.

When you select the Shadows & Highlight filter, this dialog is activated:



This is tricky. Why?! Because no meter what values you enter for shadows and highlights, the algorithm will do the same this. Finally you will end up with 2 extra layers, one for shadows and one for highlights, both in overlay mode (this mode works as a multiply for darken zones and as a screen for lighter ones). All these 2 sliders do is specifying the opacity of each layer, which you can of course change after running the filter, having this way the preview in the image itself.

Since there is not to much left to say about this filter here is what I've done: on the original image, after correcting the dynamic range I run this filter. On the resulting two layers I played with the opacity until I considered I got the best result: 90% opacity on "fix shadows" layer (which actually increases the highlights, recovers shadows detail) and 25% opacity on "fix highlights" layer (which actually increases the shadows, reduces the excessive light), but again feel free to experiment:


Original image:


Shadows & Highlights result:


Result from Part 2:


That's it! I really hope you enjoyed this 3 part tutorial and you found something useful in it! By the way do you not that The Gimp is completely free of cost and it runs under Linux, Mac OS X and Windows, right?

See you at the next tutorial!

Part 1: Dynamic Range
Part 2: Multiply and Screen

Read more...

Thursday, July 2, 2009

Fixing Highlights and Shadows - Part 2: Multiply and Screen

In the first part of this tutorial we used the dynamic range correction, which will help us most of the time. But for situations like in this photo, we need more horse power:


Obviously this photo needs some improvements, but we will fix here only the luminosity. First of all I try levels and dynamic range approach:


Definitely, not so lucky like in the first part. I have a highlight gap, I will fix it of course, but the effect is not so impressive, I need something more:


I will duplicate the background layer twice and I rename the layers: shadows, respectively highlights. To duplicate a layer, first select it in the layers dialog and than click on the duplicate layer button or just press Ctrl+Shift+D. To rename a layer just double click over its name, than edit and press enter to validate.

Next I will change the mode of the Shadows layer to Multiply and the highlights layer to Screen mode. The multiply mode always darkens the image, the screen mode always make the image lighter. More details on render modes can be found into the Gimp manual.


You may wonder why do I need a layer like multiply, which darkens the image, since I already have a too dark one. Basically I have two reasons: I want to reduce the light of the sky a little bit and also because it will help me to give a more natural feel to the final result. The good thing is that you will do not need both multiply and screen layers all the time. It depends on your photo.

Here I have the result when only the background and the shadows layers are visible, next only background and highlights and all of them visible in the third one.





The screen mode increases the highlight of an image, multiply the shadow. The biggest problem we have now is that the highlights layer (screen mode) makes the sky too much brighter, unreal, loosing almost all the details.

In order to fix the sky I am going to use a layer mask on the highlights layer. Layer masks are very useful in lots of photo retouching scenarios, so please consult the Gimp manual for more details on this subject. Basically, you may consider a mask as a fully transparent foil placed over all the surface of a layer. After that placing the foil, you start to paint over it in order to hide some parts of that layer. You only have white pint to use with your brush. To be transparent, this foil is composed only of pixels with no value (0, which is equivalent to black). Pixels with maximum value (255, which is white) will obstruct completely the visibility to that layer. Anything between 0 and 255 will me partially transparent, the lower the value, the higher the transparency. Finally when you are happy with the painting you have made to that foil (mask) you will stick it to the layer, using a fully transparent glue (which means apply layer mask).

If you got the point with this masks I suppose you already know what I am going to do in order to this the sky: use a layer mask on the highlights layer, fully transparent (black) over the sky and fully white over the rest of the picture. In order to improve the transition between black and white I will use a gradient.


In order to create the gradient I will use the blend tool. This tool fills the selected area with a gradient blend of the foreground and background colors by default, but there are many options. To make a blend, drag the cursor in the direction you want the gradient to go, and release the mouse button when you feel you have the right position and size of your blend. The softness of the blend depends on how far you drag the cursor. The shorter the drag distance, the sharper it will be.For more details please consult the Gimp manual.

For this photo I want a sharper gradient, just above the line where the sea begins. To do this, I fist create a layer mask (no meter what option you select when creating this mask because the gradient will replace it anyway). To create a layer mask, select the layer you want to affect, than either right click and select Add Layer Mask, or go to Layers -> Mask -> Add Layer Mask. Click Add in the dialog which opens.

Notices that white rectangle next to the highlights layer? This means we have a fully opaque layer mask on this layer. Now, select this mask by clicking inside the white rectangle (in the picture above is already selected). In the layers dialog you can see where the current selection is by the color of the border surrounding each thumbnail. All, except the selected one are surrounded by a black border. The selected is surrounded by white, but since our mask is white we cannot observe that white border around it (the absence of a white border on other thumbnail should be the clue). While the layer mask is selected, pick the blend tool, leave all options to default and make sure your foreground color is black and the background color is white.

If you look carefully at the photo you will notice that I already have a gradient at the sea level (lighter close to the beach, darker at the horizon line). This is where I will place my gradient also. Usually you will do it just above the horizon line, but since I have also the sea I will do it below the horizon and above the beach (a no sand beach actually). Draw a vertical line starting from the line where the sky meets the sea and stop just above the beach line. Make sure the line is perfectly vertical and release the mouse.

Now watch the result below, the sky is not so over burned anymore (to sharp gradient, indeed but it will be fixed later as a side effect). The highlight layer is not applied anymore above the sky part of the picture:


We are almost finished. This gradient trick seems to work, but now we have a big problem. The guy with a yellow t-shirt has the head on the gradient area and now, part of his face is lighter than the upper part. He is too pretty to deserve this (unfortunately for you girls is married also). We should adjust that mask in order to be fully opaque over his head.

If you didn't noticed so far the problem with my dear fiend's head, I will turn off the visibility of all the layers except the highlights one (as you remember, this is done by clicking those eyes) and I zoom in. Do you see how his head is becoming almost transparent at the top of the face? In the not fully opaque zone, the highlights layer will not be fully applied, unlike it happens with all the other people in this photo and this is simply unfair:


We have to fix this because I do not what him to be upset on me. Select the layer mask (like we did before gradient) by clicking on it in the layers dialog. Select the intelligent scissors selection tool by clicking on the scissors icon in the tools dialog. This tool will let us select the head with enough detail. Click around the head an see the result, finally click on the starting point in order to close the curve. If you are not happy with the selection on different zones you can click on any point of the curve in order to move it or click on the curve in order to add more points. When happy with the curve, press enter to transform it to selection (since we are interested to fix only the semitransparent part, I didn't contoured all the face, just the part we need to be fixed):


After hitting enter and we got the selection, we will use the bucket fill tool in order to paint on the selected zone in white. Make sure the mask is selected, not the layer. Make sure you use white color. In my case, since the white is the background color I selected BG color fill. If you have it as foreground, select FG color fill. If you don't have it at all, select the white color by clicking on the foreground color (the black square). Also make sure that for the affected area you've selected Fill whole selection (this is not the default).

With the bucket fill tool picked, just click inside the selection we've just made around the head. Is there any non fully opaque part remaining on his head? If yes, you did something wrong, undo and start over again. Here is the result after this painting and pressing Ctrl+Shift+A for clearing the selection:


In order to clearly see what we actually did, right click on the layer mask in the layers dialog and check Show layer mask. You should see the below image. Notice the white head we've made with the bucket fill.


Now uncheck Show layer mask in order to return to out photo. We finished with the mask, we have to stick it with some glue. Right click on the highlight layer and select Apply Layer Mask. Also make visible all layers again by clicking the eyes on layers dialog. We are in this stage now:


Now we really are one step behind our great job finish. We now have a better photo but it is not really natural. We still have to make some adjustments. First of all it is not lighted enough because of that multiply (shadows layer). Also that gradient is to sharp. The good news is that we can fix these easily, using the opacity slider for shadows and highlights layers. If you do not like the effect of the shadows layer you can skip it since the beginning. But remember that it has its advantages, mostly on sky and the beach rocks. I let you experiment with the opacity sliders. My decision was to keep 25% for the shadows layer and 90% for highlights, but since I am really tired now it may not be the best decision. Can you find a better one?


Anyway here is the result:


The original was:

Do you consider this difficult? Not really, but sometimes you can achieve a good result using a third party filter, which of course is also free. We will discuss about this in the third part of this tutorial, which I promise it will be shorter than this.


Read more...

Fixing Highlights and Shadows - Part 1: Dynamic Range

In this tutorial I will present you several techniques I use in Gimp, in order to fix the lightness in my photos. In the first part we will discuss about the dynamic range and how to fix it using levels and curves tool. Most of the time this fix will be enough, but sometimes not. This is why in the second part I will present you my favorite fix for such situations in which the highlights and/or the shadows are seriously out of natural, using multiply and screen rendering modes. Finally, in the last part I will present you the Shadows and Highlights filter.

For this tutorial I used Gimp 2.6.1. You may face some small differences in the Gimp's interface if you are using a different version.

Here is the first photography we want to fix in this tutorial:



Well... there is something wrong with this photo. Can you guess what? Which aberration is most obvious to you, the dynamic range or the semaphore lights?
This funny (and real) shot was taken in London (on the left is The Big Ben). As if it were not enough that you have to drive on the left side of the road, you have to deal with such semaphore also.

But I'm sure that you were more concerned about the dynamic range, not the red/green lights. So let's take a look over the histogram in the levels tool:


In a good photo, the histogram is expanded over the hole horizontal axis. Dynamic range in photography describes the ratio between the maximum and minimum measurable light intensities (white and black, respectively). In a standard 8 bit RGB digital image, for each pixel, in each channel we can store a value between 0 an 255. As you can see from the histogram, our photo is missing quite an impressive number of values in the highlights zone (right) and also some in the shadows zone (left). This means that we do not benefit from all the value range we can use. Our lightest pixel is around 160, far away from a white point (255). On the opposite side we miss less range, but enough to reduce the quality our photo.

Since every photo's histogram is unique, there is no single way to adjust the levels for all your photos but most images look best when they utilize the full range, dark to light which can be used. This means that it is often best to extend the histogram all the way from black (0) to white (255):


To do this, move the black triangle to the right and the white one to the left until each one meet the histogram. Click Ok. Open again the levels tool and notice the differences: the histogram is expanded now over the hole range, but something strange happened. Some of the vertical lines are missing from the histogram. This is called "posterization" and means that we are missing some details due to the transformation we've made. This is the life, everything has a price, we loosed some details in order to improve the used range. This is normal and acceptable if it does not become visible in the image. Look for it in your photo after working with the histogram. It is more visible in regions of gradual color transitions, like the sky. If the posterization is visible you should reduce the stress applied to the histogram.

In our example here is the result (original photo first, adjusted one next):

The same adjustments can be made using the curves tool:


As you can see, the extremes of the curve were moved to match with the histogram. The curves tool has the advantage that it can be used also for zones inside the histogram. If you have gaps in histogram values, you can adjust this by placing 2 control points on the curve and than adjust the curve to be horizontal above that missing zone. Anyway, this anomaly is rare.

Unfortunately, the dynamic range technique does not work always. In the second part of this tutorial I will explain you how do I fix higher anomalies, using multiply and screen render modes.


Read more...

Sunday, June 28, 2009

Correct Color Cast, Using Levels and Curves

This tutorial is done in Gimp 2.6.1. If you are using a different version you may face several differences in menu locations or tools panels.

If you don't know what a color cast means please check Wikipedia or any source you want. Basically it means that the photography presents an unwanted unbalance between RBG channels (red, green and blue colors).

There are more possibilities to correct color cast but I will present here just my favorite methods, using Levels and Curves tools.

The first method, using levels, work only in case you have a photo with neutral gray points (neutral mid-tones). A perfect neutral gray point is a pixel having 50% values on each color channel.

The first part presented will be common to both approaches. This is the original image (I don not remember the link, but it's freely available from http://gimp-savvy.com):


Wow, we have some blue in this photo isn't it? In order to perform color cast corrections we need 3 points from our image: black, white and a neutral. With the second method (curves) you can use more points in order to fine tune final result.

For this photo it is relatively easy to detect 3 reasonable points, but I what to use a fine tunned way which will help you also with more complicated situations and which does not counts on the way your monitor displays the colors. In order to do this we will use the threshold tool.

We will duplicate the background layer, using the Layer menu (Layer -> Duplicate Layer), right clicking on the layer in Layers dialog and selecting Duplicate Layer, clicking the Duplicate Layer button on the layers dialog or using the shortcut: Shift + Ctrl + D.


We will use this layer to help us in selecting the black (shadow) point:
  1. Select the Background copy layer;
  2. Open the Threshod tool;
  3. Make sure the Preview is checked;
  4. Move both sliders to 0 (to the left, or enter 0 in both text boxes);
  5. Move the white slider to the right until a useful amount of white pixels are displayed in the image;
  6. Click Ok to apply and close the threshold tool.

Now, in the image window, click on the above ruler and drag down until crosses over a white zone. Now click on the left ruler and drag right until intersects the previous line over the white zone (CLICK on image below).


After that, in case we plan to use the curves tool, we will insert a sample point on the intersection. Keep Ctrl presses while clicking on any of the rules area (top or left) and drag over the intersection of the guide lines. If you do not have open the sample points dialog, you can activate it from Windows - > Dockable Dialogs -> Sample Points. Make sure the sample point indicates 255 for red, green and blue, which indicates that you really selected a white spot in the image.


At this point you can delete the copy layer on which we worked until now. As the background layer becomes selected the sample points indicates the corresponding values from this layer. I use sample points because I consider that are really helpful when making corrections using the curves tool. For levels adjustments, this points are not needed (actually better don't have them).


We will do the same operations for the white (bright) point:
  1. Duplicate the background layer;
  2. Select the Background copy layer;
  3. Open the Threshold tool;
  4. Make sure the Preview is checked;
  5. Move both sliders to 255 (to the right, or enter 255 in both text boxes);
  6. Move the black slider to the left until a useful amount of white pixels are displayed in the image (in this case are enough pixels at 255, no move is needed);
  7. Click Ok to apply and close the threshold tool;
  8. Choose a white point and drag horizontal and vertical guide lines from rules which should intersect over that point.
  9. Place a sample point (keep Ctrl pressed while clicking on the ruler, than drag the sample point over the guide lines intersection);
  10. Delete or hide the copy layer.
We need only one more point, the neutral mid-tone. This is the most difficult to be spotted in the image. Usually good candidates for this are white surfaces which are not in the light direction. We will use the threshold tool for this also but we have to do a trick before. We will use a gray layer and we will set the mode to Difference for it. This mode subtracts the pixel value of the upper layer from that of the lower layer and then takes the absolute value of the result. Since the upper layer is gray, all pixels have 128 value. If the below layer has perfect neutral points the result will be 0 (black). We do not expect however such perfect pixels, we are looking for anomalies wright? We will look for darken pixels on areas we know that are in reality white (but not under direct light exposure).
  1. Duplicate the background layer;
  2. Click on the foreground color on the toolbox window. In the color dialog enter 128 value for red, green and blue. Click Ok. Your foreground color should be gray now.
  3. Create a new layer and choose foreground color for layer fill type;
  4. In layers dialog make sure the new layer is selected and change mode to Difference.
  5. Merge down this layer. With the layer selected right click on the layer an choose Merge down, or go to Layers menu and choose Merge down;
  6. Select the layer resulted after merge;
  7. Open the Threshod tool;
  8. Make sure the Preview is checked;
  9. Move both sliders to 0 (to the left, or enter 0 in both text boxes);
  10. Move the white slider to the right until a useful amount of white pixels are displayed in the image (we need more pixels than for black points because we have anomalies);
  11. Click Ok to apply and close the threshold tool;
  12. Reduce the layer opacity as needed to distinguish the picture elements. From the white points choose one which is in a neutral area (gray or a white surface not under light). I think that bout is white right?;
  13. Choose a white point (did you noticed the front part of the boat, between the two guys? It matches out thresholded layer) and drag horizontal and vertical guide lines from rules which should intersect over that point.
  14. Place a sample point (keep Ctrl pressed while clicking on the ruler, thad drag the sample point over the guide lines intersection);
  15. Delete or hide the copy layer.


After deleting (hiding) all other layers except background, make sure the background is selected and take a look at the sample points dialog. You should have 3 points there: black (shadow), white (highlight) and mid-tone neutral.


Look at those points. Something is wrong, except for white. We have a small deviation at the black point, but the neutral one is completely out of scope. We expected almost equal values for all channels at this point. Also this values should be close to 128 (50%). It's time for as to change this mess.

Unfortunately, Gimp doesn't allow us to select a sample point with the eye-dropper. In order to get rid of this constrain, click near the sample point, keep the mouse button down and drag the dropper inside the sample point. Those guide lines will help us to select the proper pixel values because near an intersection we will receive the proper pixel, although we are a little bit out of scope with the cursor. It is really difficult to select a pixel with the right values for a sample point. In conclusion, when working with levels tool, the guiding lines will help us. When working with curves, both guiding lines and sample points are useful. We will see this later.

Since we have a neutral point available, we can use the Levels tool. We are interested in those three eye-droppers at the right of the Auto button. From left to right those droppers are for black, neutral and white points. Click on the left one, click near sample point 1, keep the mouse button down and drag the picker inside the sample point 1. Now click the most right picker and do the same for sample point 2. An finally select the middle picker do the same with sample point 3 and enjoy the result.


We were lucky, we had that magic point, but what if.... we haven't? Well... in this case the levels tool is not so useful anymore. We have to use the curves tool. With this one you can experiment with more points you think that might be of a specific color. Feel free to experiment until you are satisfied by the result (this method is called perturbation).

For this tutorial we will use only the same 3 points as for levels tool. Open the curves tool. Ctrl+Click near each sample point, then drag inside the sample point. This will create 3 control points in the curves tool for each channel.


Let's look again at those 3 sample points.

The first one should be black. OK, I admit I do not need really 0 there, but a 10 on each color should be better than what I have. The second one is perfect, truly white, no change needed. The last one is ... well... far away... What values to put here? In a perfect move, if this is really a perfect neutral point, I need 128 on each color. I'll give it a try. If you will meet point with 2 colors nearly equal than probably the 3rd one should also be the same. If you are not satisfied with result you should try different variations. Tray to move all the others colors to the value of one. Try e median one. Try to use other points also. Try all you can until satisfied.

Having this sample points values displayed all the time helps me moving than control points. Let' start with the red channel first. As I said I will try 10 for the black, I'll leave the white as it is and I will try 128 for neutral. I gave to make 2 changes in this channel: X:29 Y:10 and X:109 Y:128.


For the green channel: X:27 Y:10, X:118 Y:128.

And finally the blue channel: X:32 Y:10 and X:149 Y:128.

Yes, we finished, here is the result:
Let's review,
Original image:
Levels tool correction:
Curves tool correction:

I hope you enjoyed this tutorial and see you soon.
By the way do you not that The Gimp is completely free of cost and it runs under Linux, Mac OS X and Windows, right?

Read more...