Showing posts with label post-processing. Show all posts
Showing posts with label post-processing. Show all posts

Tuesday, 14 April 2009

Advanced Tone-mapping with GIMP

Most compact photo-cameras cannot handle contrast scenes properly. Here a plugin for GIMP (GNU Image Manipulation Program - a popular open-source alternative for PhotoShop, available for Windows, Linux and Mac OS), called Advanced Tone Mapping comes to the rescue. The script processes a single image, unlike High Dynamic Range technique, which requires at least two shots, increasing its local contrast and reducing total one. In a plain language it makes dark parts of the image lighter and bright parts darker. Obviously, the picture should not be overexposed, because nothing can get any information from the white sky, as it is completely lost.

Let start with the example.



I took this photo at South Head, the Kaipara Harbour entrance, not far from Auckland, New Zealand. In order to preserve the sky I set up exposure compensation to -2/3, so the whole picture became too dark. The sand is dark indeed, as it contains black volcanic ash, but pieces of broken sandstone on the foreground should be same colour like the background cliff.

One disadvantage of the script is that it takes a while to process a picture and there is no preview available, so nobody can tell you what values should be set as the parameters (four ones in total). Thus the idea of the explained technique is to over-process the picture, then to reduce the effect to get the desired result. So I opened the picture in GIMP, clicked Filters - Enchance - Advanced Tone Mapping and set the parameters as follows:
  • Gauss. Blur: 10% - the default value
  • Opacity of blurred layer - 100 or near
  • Opacity of merged layer - 100 or near
  • Copies of merged layer - 3
The result is shown below.



I definitely got what I wanted, but the result is far from ideal. The colours are un-real, and halos are strong and clearly visible. This new image appeared as a second layer above the original image, and this is very handy, as what I have to do now is just to change some parameters of this new layer.

So I switched to the Channels, Paths, Undo, Layers - ... dialog and selected Layers tab. The new layer is called tmapd: with some numbers, it should be already selected. I changed the layer mode to Value (the last in the list) and adjusted its opacity until I considered the result as satisfactory; the final opacity value for this image was about 60%. This is the interactive process and the changes are reflected on the image (almost :) immediately.



As you can see the clouds became more impressive, the background is now brighter; there is still some halo above the forest, but it is not so obvious.

This technique increases the noise level, especially in brighter parts of the image. This is because they contain less information, higher local contrast means small variations of brightness becomes more visible; it usually affects the blue sky. One can try to improve this by applying another plugin - GREYCstoration to the resulting and flattened image.

Tuesday, 22 July 2008

Playing with HDRI

High Dynamic Range Images (HDRI - Wikipedia article) became very popular recently, and I also experimented with this technique. I don't personally like unrealistic pictures you can often see in the Internet, if you search for "HDR" or "HDRI", so I usually try to preserve natural look.

To make a HDR image one has to make at least two shots of the same scene with different exposure. Many cameras have "auto-bracketing" mode, what makes this part of work quite simple. My camera (Panasonic Lumix DMC-FZ5 - DPreview) can take three shots with maximum -1EV and +1EV exposure range from the base settings. Below is the cuts from three original photos I made with such auto-bracketing. The scene is Anchor Bay at Tawharanui Regional Park, some 80 km north from Auckland, New Zealand.



ISO: 80
Shutter speed: 1/500, 1/250, 1/125
Aperture: f/4.0
Focal length: 6.0 mm (36 mm for 35 mm film)
Metering mode: Matrix
Tripod and polarizing filter.

Polarizing filter reduced reflections from water surfaces and brightness of the sky.

I cut off a small piece from original photos, which includes both very bright (clouds) and darkest parts (black rocks) of the scene. The source files were in JPEG format, as this is the only format my camera allows for auto-bracketing mode.

I loaded all three files into Qtpfsgui (http://qtpfsgui.sourceforge.net/) and created a HDR image using default program settings. Saved the result as Tawharanui.hdr and clicked Tonemap the HDR. This is the most creative and time-consuming part of work with Qtpfsgui, and the goal is to get TWO tone-mapped LDR (8 bits per channel) images: one is as good as possible and another is produced by the Fattal algorithm to improve the first (thanks to Angela Lobefaro for her post to this blog). Qtpfsgui provides 8 different algorithms for tone-mapping; I found Drago, Durand and both Reinhard are mostly suitable for first, realistic looking image, while Fattal or Mantiuk are better for "impressionist" image, aimed to pop-up first one.

In this particular case the first image was made by Reinhard'05 with the following parameters:
pregamma: 1
brightness: -10
chromatic adaptation: 1.26
light adaptation: 0.5



The second image was by Fattal with:
pregamma: 1
alpha: 0.1
beta: 0.8
saturation:1
noise reduction: 0.04
These parameters are actually default ones, except noise reduction; this was carefully adjusted to keep as many details as possible.



Obviously, both images must have the same size and should be saved on the hard drive.

Then I launched GIMP (GNU Image Manipulation Program - http://www.gimp.org/) and opened both of the images here. First steps are simple: make the "Fattal" image active, Select All (Ctrl+A) and Copy (Ctrl+C). Then switch to another image and Paste (Ctrl+V); then go to Layer -> New Layer (Shift+Ctrl+N). Now go to Channels, Paths, Undo, Layers dialog and click on layers tab (Ctrl+L). You will see two layers; Pasted Layer which holds "Fattal" image, is active and actually hides another layer (Background with "Reinhard" image) beneath. Change its Mode to Overlay and shift Opacity down to 70...30 until you think your picture is good enough. That's all.

This is not the best way, because depending on your pictures you can get better results, playing with these settings - try other layer modes like Hard Light, Soft Light, Darken or Lighten Only, Burn or Value with different Opacity settings. You can also adjust your images before blending layers.

For my picture I performed the following actions:
1. Made Background layer invisible (clicked on the eye icon on the Layers dialog)
2. Went to Colors -> Levels and moved the central slider to 0.75; this made my "impressionist" layer darker and "richer"
3. Turned back on visibility of the Background layer, still keeping Pasted Layer as selected (active)
4. Changed layer mode to Value and adjusted opacity to about 0.50
5. Cropped
6. Saved As...