The Gimp

2010-04-07

Since getting an iMac in the summer and not spending the many hundreds of dollars needed for a Photoshop license, I’ve been a pretty happy user of Google’s Picasa. However, it is a bit underpowered and lacks the type of features that are useful for fixing contrast, color, and sharpness issues in poorly lit, partly blown out, noisy, and otherwise problematic photos that you end up with if you are shooting with a nice pocketable compact camera, like I do. My Canon S80 is actually not that bad (great lens, easy to stuff in a pocket, fast to unpocket and aim and shoot, nice controls) but it has three major limitations:

  • When shooting automatic it tends to blow out on the highlights, meaning the sky and other bright areas in the photo are white. This means you have to manually set aperture, shutter time, and ISO to get more difficult shots. Most compacts suffer from this problem BTW.
  • The screen and histogram on it are not that useful. Basically you will end up with photos that are too dark and that do not use the full available dynamic range if you try to optimize for what’s on the screen. Instead, I’ve been relying on spot metering and measuring different spots and compensating for that using Ansel Adams style zoning and wet finger approach (okay a lot of this). Basically this works but it is tedious.
  • Like most compacts, it is useless at higher ISOs due to the noise. Basically I avoid shooting at 200 or above and usually shoot at 50 unless I can’t get the shot. This means in low light conditions, I need a really steady hand to get workable shots.

So as a result, my photos tend to need a bit of post processing to look presentable. Picasa handles the easy cases ok-ish but I know software can do better. So, after exploring the various (free) options on mac and deciding against buying Adobe Lightroom or Photoshop Elements, I ended up taking a fresh look at the Gimp.

The Gimp is as you no doubt know an open source photo/bitmap editor (as well as a really funny character in Pulp Fiction). It comes with a lot of features, a UI that is quite ‘challenging’ (some would say unusable), and some technical limitations. To start with the technical limitations: it doesn’t do anything but 8 bit color depth, which means lossy operations like editing contrast or running filters tend to lose a lot more information due to rounding errors that add up the more you edit. It doesn’t do adjustment layers and other forms of non destructive editing, which adds to the previous problems. It’s slow. Slow as in it can take minutes to do stuff like gaussian blur or sharpening on a large image that should be near real time in e.g. Photoshop . It doesn’t support popular non RGB color spaces (like LAB or CMYK, though it can be made to work with them if you need to). And it doesn’t come with a whole lot of filters and user friendly tools that are common in commercial packages. Finally the UI is the typical result of engineers putting together a UI for features they want to show off and of course not agreeing on such things as an overall UI design philosophy or any kind of conventions. It’s nasty, it’s weird in plenty of places, it’s counter intuitive and it looks quite ugly next to my pretty mac apps. But it sort of works, and you can actually configure some of its more annoying defaults to be more reasonable.

So there is a lot lacking and missing in the Gimp and plenty to whine about if you are used to commercial grade tooling.

But, the good news is (beyond it being free) that you can still get the job done in the Gimp. It does require a creative use of the features it has. Basically, the Gimp provides all the basic building blocks to do complex image manipulation but they are not integrated particularly well. There are only a handful of other applications that provide the same type of features and implementation quality. Most of those are expensive.

In isolation the building blocks that the Gimp provides are not that useful. You have to put them together to accomplish tasks, often in not so obvious ways (although for anyone with a solid background in advanced photo editing it is not that much of a challenge). Doing things in the Gimp mainly involves understanding what you want to do and how the Gimp does things. It’s really not very forgiving when you don’t understand this.

Here are some things that are generally in my work flow (not necessarily in this order) that work quite well in the Gimp. I just summarize the essentials here since you can find lengthy tutorials on each of these topics if you start Googling, also there is lots of potential for variation here and perfecting skills in particular areas:

Contrast: duplicate layer, set blend mode to value (just light, not color), use levels or curves tool on the layer to adjust the contrast. Fine tune the effect with layer transparency. This basically leaves the colors unmodified but modifies brightness and contrast. Improve black and white contrast with color balance: basically in black and white photography you can use a color filter in front of the lens to change the way light and dark effect the negative. E.g. a red filter is great for getting some nice detail in e.g. water or sky. You can achieve a similar effect with the color balance tool and a layer that has its mode set to value. This is nice for creating black and white photos but also nice for dealing with things like smog (a mostly red haze -> deemphasize the red) in color photos or getting some extra crisp skies. You can examine the individual color channels to find out which have more details and then boost the overal detail by mixing the channels in a different way. This will of course screw up the colors but you are only interested in light dark here, not color. So duplicate layer, set mode to value, and edit the layer with the color balance tool. Some basic knowledge of color theory will help you make sense of what you are doing but random fiddling with the sliders also works fine.

Local contrast: duplicate layer, use the unsharp filter to edit local contrast by setting radius to something like 50 pixels and amount to something like 0.20. Basically this will change local color contrast and change the perceived contrast in different areas by locally changing colors and lightness. If needed, restrict the layer to either value or color mode.

Contrast map: duplicate layer, blur at about 40 pixels, invert, destaturate, set layer to overlay. This is a great way to fix images but a high dynamic range (lots of shadow and highlight detail, histogram is sort of a V shape). Basically it pushes some of the detail to the center of the histogram, thus compressing the dynamic range. Basically it brightens dark spots and darkens bright spots. The blurring is the tricky bit since you can easily end up with some ghosting around high contrast areas. Fiddling with the pixel amount can fix things here. Also using the opacity on the layer is essential since you rarely want to go with 100% here.

Overlay to make a bland image pop: duplicate layer, set mode to overlay. This works well for photos with a low dynamic range. It basically stretches detail towards the shadow and highlights and enhances both contrast and saturation at the same time. Skies pop, grass is really green, etc. Cheap success but easy to overdo. Sort of the opposite effect of contrast map.

Multiply the sky. Duplicate layer, set mode to multiply, mask everything but the sky (try using a gradient for this or some feathered selection). This has the effect of darkening and intensifying the sky and is great for photos that were overexposed. Also works great for water (though you might want to use overlay).

Color noise: duplicate layer, set mode to color, switch to the red channel and use a combination of blur, and noise reduction filters to smooth out the noise. Selective gaussian blur works pretty well here. Repeat for the green and blue channels. Generally, most of the noise will be in the blue and red channels (because for every cluster of 4 pixels in the sensor, two are green, i.e. most of the detail is in the green channel). Basically, you are only editing the colors here, not the detail or the light so you can push it quite far without losing a lot of detail. Apply a light blur to the whole layer to smooth things out some more.

Luminosity noise: duplicate layer, set mode to value, like with color noise, work on the individual channels to get rid of noise. You will want to go easy on the blurring since this time you are actually erasing detail. Target channels in this order, red, blue, green (in order of noisiness and reverse order of amount of detail). Stop when enough of the luminosity noise is gone.

Color: duplicate layer, set blend mode to color, adjust color balance with curves, levels or color balance tool.

Saturation: duplicate layer, set mode to saturation, use the curves tool to edit saturation (try pulling the curve down). This is vastly superior to the saturation tool. You may want to work on the individual color channels, though this can have some side effects.

Dodge/burn: create a new empty layer, set mode to overlay, paint with black and white on it using 10-20% transparency. This will darken or brighten parts of the image without modifying the image. You can undo with the eraser. Smooth things with gaussian blur, etc. This is great for highlighting people’s eyes, pretty reflections, darkening shadow areas, etc.

Crop: select rectangle, copy, paste as new image, save. Kind of sucks that there is no crop tool but this works just fine.

Sharpening: A neat trick I re-discovered in the Gimp is high-pass sharpening. High pass filtering is about combining a layer with just the outline of the bits that need sharpening with the original photo. This is great for noisy photos since you can edit the layer with the outline independent from the photo, which means that you end up only sharpening the bits that need sharpening. How this works: copy visible, paste as new image, duplicate the layer in the new image, blur (10-20px should do it) the top layer, invert, blend at 50% opacity with the layer below. You should now see a gray image with some lines in there that represent the outlines of whatever is to be sharpened. This is called a high pass. Copy visible, paste as new layer in original image, set the high pass layer’s blend mode to overlay. Observe this sharpens your image, tweak the effect with opacity. If needed manually delete portions from the high pass that you don’t want sharpened. Tweak further with gaussian blur, curves, levels, unsharp mask on the high pass layer. Basically this is a very powerful way of sharpening that gives you a lot more control than normal sharpening filters. But it involves using a lot of Gimp features together. It works especially well on noisy images since you can avoid noise artifacts from being sharpened.

A lot of these effects you can further enhance by playing with the opacity and applying masks. A key decision is the order in which you do things and what to use as the base for a new layer (either visible, or just the original layer). Of course some of these effects can work against each other or may depend on each other and some effects are more lossy than others. In general, paste as new image and paste as a new layer together with layer blending modes like color, value, or overlay are useful to achieve the semi non destructive editing that you would achieve with adjustment layers in Photoshop. You can save layers in independent files and edit them separately. And of course you don’t want to lose any originals you have.

Also nice to be aware of is that most of the effects above you can accomplish in other software packages as well. In Photoshop, most of the tricks above give you quite a bit more control than the default user friendly tools (at the price of having to fiddle more). Some other tools tend to be a bit underpowered. I’ve tried to do several of these things in paint.net under windows and was always underwhelmed with the performance and quality.

Finally, there exist Gimp plugins and scripts that can do most of the effects listed above. I have very little experience with third party plugins and I am aware of the fact that there are a huge number of plugins for e.g. sharpening and noise. However, most of these plugins just do what you could be doing yourself manually, with much more control and precision. Understanding how to do this can help you use such plugins more effectively.

To be honest, my current workflow is to do as much as possible in Picasa and I only switch to the Gimp when I am really not satisfied with the results in Picasa. Picasa does an OK but not great job. But with hundreds of photos to edit, it is a quick and dirty way to get things done. Once I have a photo in the Gimp, I tend to need quite a bit of time before I am happy with the result. But the point is that quite good results can be achieved with it, if you know what to do. The above listed effects should enable you to address a wide range of issues with photos in the Gimp (or similar tools).