Showing posts with label gimp. Show all posts
Showing posts with label gimp. Show all posts

2010-11-11

How to select a region by intensity range in Gimp?

I wrote this as an answer to Photo.StackExchange question, how to select by histogram range in Gimp.

Step-by-step

  1. Make a copy of the layer (Layer → Duplicate Layer)
  2. Select the duplicate layer, apply threshold (Colors → Threshold) to select the range of intensities.
  3. In Layer → Mask → Add Layer Mask (or right click in the list of layers). Select “Grayscale copy of layer” and “Invert mask”.
  4. idem: Mask to selection.
  5. Hide or remove the layer with mask.

An example:

An original image. I want to select the circle:

Original image

Make a copy of the layer:

Duplicate layer

Apply threshold. Note that the area to be selected is black:

Threshold

Add Layer Mask using the grayscale value of the image:

Add Layer Mask

Now you've obtained an image with the mask. Everything except the black circle is transparent (we can see the bottom layer through it):

Image with the mask

Convert the mask to selection. Switch to the original layer. The circle is selected.

Mask to selection

2010-08-05

Cleaning sensor dust with Gimp

Recently I found an easy cure for dust spots on the photos. I am talking about sensor dust here. Any owner of a camera with interchangeable lenses (and more than one lens) sees out-of-focus dark spots sooner or later. It is sensor dust. For example:

Sensor dust on the shot

It is easily recognised by always appearing on the place. The dust spots are most noticeable when shooting a uniform bright object (e.g. sky) with small aperture (f/22 or smaller). And cleaning the lens will not get rid of the spots. The right way to address it is to clean the sensor. Someone else wrote about it.

Let's talk about how to remove these spots from the photos already taken. For this purpose I use Gimp and its Resynthesizer plugin. Clone brush is OK too, but cleaning more than a photo or two is tiresome. Think of Resynthesizer as an automatic clone brush. Ubuntu users may install it with gimp-resynthesizer package.

To clean dust spots, first find and select them. I usually use a free selection tool (Lasso). Press Shift to add more than one spot to selection. Select also a handful of “clean” pixels around. Which pixels are on the border of the selection matters.

Run Filters -> Map -> Resynthesize filter. Default parameters should be OK, tiling options are not necessary for our scope.

Now you have to wait a few seconds. Resynthesizer takes some time to redraw the selection. Anyway, it is faster than manual clone brush.

Finally, inspect the result. Make sure that the plugin didn't draw anything strange. Usually it is OK from the first attempt:

Sensor dust removed with Resynthesizer

Enjoy!

And if useful, then  Flattr this

Riviera

Also in Russian: Удаление пыли на матрице в Gimp.

2008-01-15

Try Exposure Blend plugin for GIMP to fake HDR

Digital cameras have relatively narrow dynamic range with respect to human eye, i.e. the difference between the brightest and the darkest grades of light the camera may capture in one shot is limited. This is the reason why some stunning scenes become badly exposed photos (with absolutely black and white areas).

There is a technique to overcome this techinical limitation of modern cameras, known as High dynamic range imaging (HDR). This technique is based on taking several pictures of exactly the same scene with different exposure levels. Then the amount of light per pixel is calculated based on all images. Finally, a combined image is produced, where information about dark areas is taken from the brigher images, and information about brighter areas is taken from the darker images. These combined images often look very good.

In GNU/Linux there is a number of Free tools which support this technique. In particular, I want to mention Cinepaint (HDR in Cinepaint tutorial) and Qtpfsgui (HDR in Qtpfsgui manual).

You just need a camera bracketing support and a tripod to start making HDR images.

However, most modern consumer-level cameras take at most 3 shots in bracketing mode, and exposure step between the shots is often limited to ±2 EV or even ±1 EV (like in my camera), which allows only slightly extend the camera's dynamic range using HDR technique.

In this case it is often easier and faster combine those three images taken with a camera using Exposure Blend plugin for GIMP (the site seems to be temporarily down, in Debian Exposure Blend plugin is part of the gimp-plugin-registry package). This is not a true HDR, but it allows to take dark details from the brighter image, and bright details from the darker image. The result is good enough, because even true HDR based on three images shot with a consumer-level camera with ±1 EV bracketing wont look much better.

In GIMP you may run the plugin from menu Xtns / Photo / Exposure Blend. Give the filenames of the three files you want to merge. All the other settings are likely OK by default.

You may get better results if your camera supports bigger bracketing step. Unfortunately, my camera does only ±1EV, which is not enough.

So I have taken a slightly different approach in the next example. I shot one image in RAW format (12 bit per color channel), and then post-processed it with UFRaw, producing three images with 0±2EV exposure correction.

Now see the results:

candle normal + candle dark + candle bright = candle blended

Just compare the original image to the composite image obtained after exposure blending (below):

Compare normal shot (above) with Exposure Blended composite image (below)

In exposure blended image the dark details are more distinct than in the original image: compare the background, the balls, the suface. Still in the bright areas there are also more details too: compare the wax of the candle. And this is with just few clicks!

I did not correct gamma, color or curves on purpose. One of the key advantages of exposure blending over HDR is that unlike in HDR in exposure blending the tone and the colors are preserved. No need to tweak tone mapping parameters. Exposure blended images always look natural.

Take a look at other Exposure Blended photos at Flickr:

Exposure Blend example 3 Exposure Blend example 4 Exposure Blend example 1 Exposure Blend example 5 Exposure Blend example 6 Exposure Blend example 2 and other photos tagged as exposureblend

P.S. I have wrote this post also in Russia, see Плагин для GIMP Exposure Blend вместо HDR