Introduction: HDR Photos With the GIMP
A tutorial on making High Dynamic Range photos using the GIMP or similar software.
This instructable is aimed at a range of people, so you can skip to the bits relevant to you with the information below. I apologise for the verbosity of the main instructions, but I figure you can skip parts you already understand, and I may as well put in the detail for people who don't.
If you don't know what High Dynamic Range (HDR) is or how it works, read on.
If you are comfortable with the concept of HDR and want to know how to do it in photo editing software, go to step 3
If you are familiar with the process of making HDR images and just want details of how to do it in the GIMP, go to step 4
If you are familiar with the interface of the GIMP and just want a quick set of instructions on how to make HDR (for instance if the theory bores you and you just want to make some HDR images), go to the recap stage in step 10. The details of each step are in... the relevant step.
If you know the theory, how to make HDR images and are familiar with using the GIMP.. I'm not sure why you are reading this, but hello anyway. My pitiful attempts (I'm relatively new to HDR and the GIMP) are in the later steps, perhaps you could give me some pointers? :D
Lastly, if you find this instructable helpful (or even not particularly) and have constructive suggestions for how I could improve it, let me know and I'll edit it.
Step 1: Theory- Photographic
What is dynamic range?
A camera, like the human eye, has a light sensor that captures the image. The sensor has a limited sensitivity to light, so under any given conditions there is a range of light levels that the camera can differentiate between. It doesn't matter if you are looking at the sun or two suns, your camera will throw up its little electronic hands and say "that is white". Similarly, unless you have a very flash camera or night vision, looking a dark grey bat in some slightly darker grey surroundings at night time, your camera will say "that is black". The difference in light level between the darkest levels your camera can distinguish between and the lightest it can distinguish is called the dynamic range- for a regular digital camera it is about 100 to 1, for the human eye it is in the range of millions to one.
The "dynamic" part is because the range can be altered, by opening or closing the camera iris (aperture), opening the shutter for a longer or shorter period (exposure), and how much the camera amplifies the signal on the light sensor (ISO). The ability to change the camera's range of light sensitivity is what we will exploit to create HDR images.
The dynamic range of a camera is not great, and not a patch on human vision. Things that you would see as dark, the camera will tend to see as a black silhouette. Things that you see as bright, the camera will tend to "wash out" and see as white. This means that taking photos of subjects with a high range of light levels, for instance a nice sunset, is very difficult with a regular camera and a single exposure. In making HDR photos, we exploit the ability to move the camera's dynamic range over the entire range of light levels.
By taking a shorter exposure or closing the aperture, the camera will underexpose. This means that the dark parts of the scene will silhouette and the light parts will be recorded well. Taking a longer exposure or opening the aperture, the camera will overexpose, meaning the light parts of the scene will wash out to white, but the shadows of the scene (that were black in the underexposed photo) will come out well. Composite HDR refers to a range of techniques to take the best parts of both of these photos and combine them in a photo that captures more of the range of light levels in the scene.
Step 2: Theory- Layered Image Editing
How do we do it?
HDR is where layered image editing programs such as GIMP or Photoshop are very useful. Using a technique called layer masks, we stack the photos with different exposures, rather like a stack of acetate sheets, and make the parts we don't want transparent so the best parts show through the stack. Photoshop/GIMP are doubly useful for this because we can make them do the hard work of actually making the layer masks.
When stacking layers in an image editing program, it is necessary to specify how transparent you want each part of the image to be. Rather than have to do this by hand, image editing software lets you do this by providing a second greyscale image that specifies how transparent each part should be. White parts of the layer mask make the corresponding part of that layer opaque, so they show up on the finished image, and black parts make that part transparent so the lower layers show up. A couple of clever tricks in the software let you generate the layer mask from the original in a few clicks, rather than laboriously paint the entire layer mask by hand.
Step 3: Take Your Stock Photos
For this step you will need:
- A digital camera with the ability to set aperture/shutter speed, to control the exposure
- A good sturdy tripod- this will save you a lot of trouble later
For the image editing, you will just need access to a computer with the GIMP, Photoshop or a similar layered image editing program. The specifics of this instructable will focus on the GIMP- Photoshop is very similar, but I can't speak for other software.
Find your subject- ideally it will have a high range of lighting, and not be moving too quickly- if the photos don't match up your finished image will look a little odd. Keeping this in mind, I took my photos of some trees that were blowing in the wind.
Compose your shot, and take several photos at a range of different exposures. The basic requirements for this process are one exposed as best you can, one about 1 stop overexposed (+1EV) and one about 1 stop underexposed (-1EV). If your camera has an EV meter, you can experiment with what works best, but if it doesn't just take enough to get one where the shadows expose properly and one where the highlights expose properly. Ideally, take the photos with a remote shutter release to avoid jogging the tripod- if you do this you shouldn't have to line the photos up at all later.
Step 4: Open the "middle" Image
Unsurprisingly, this usually involves File -> Open... and selecting your middle image. I suggest renaming your photos from the usual "P100327.jpg" your camera may call them to "middle", "dark", "light" etc. or something similar before you start.
Step 5: Add Dark Layer
Open the dark image in a new window. Copy the contents, then go back to your original image (from now I will refer to this as the composite, and the other photos as the stock). Create a new layer, with Layer -> New Layer, rename it something sensible like "Dark layer"- the initial colour settings are unimportant. Paste the dark stock into it, and hit Anchor. You should now have the middle image on the background layer, and a new layer with the dark stock in it above that- the window holding the composite image will now show just the dark layer.
Step 6: Make the Dark Layer Mask
Now go back to the dark stock image. Desaturate the image (convert to greyscale) with Layer -> Colors -> Desaturate. This forms the basis of your layer mask- the white parts will be opaque in the composite, and the dark parts transparent, meaning the composite will just take the correctly exposed parts of the dark stock image.
If the image is mostly black and dark grey like this one, you will want to brighten it up a little. Go to Layers -> Colors -> Curves... and you should see a histogram with a diagonal line across it. The "lump" in the middle of the histogram shows the brightness levels of the grey parts in the layer mask image. Drag the middle of the curve upwards so the part above the spike on the histogram is near the top of the window. Your image should now be a lot brighter. This part is not an exact science- the more you raise the curve, the more the composite will draw from the dark stock image, so the more pronounced the HDR effect will be. Experiment to find the best values for your photos.
Step 7: Apply the Dark Layer Mask
Copy the contents of the dark layer mask image. Go back to the composite, and open the layers window (Ctrl-L or Dialogs -> Layers). Right-click on the dark layer, and select Add Layer Mask- the initial settings are unimportant. Now everything that you do to the dark layer will happen to the layer mask. Grab the paintbrush, select white or black and paint a little on the image- you should see where you paint show one or other of the photos in the composite. Now paste the layer mask onto the dark layer (select the dark layer and Edit -> Paste). Anchor the pasted layer down.
The composite image should now have less silhouette in it and appear a little more "vibrant". To see the effect the layer is having, check and uncheck the visibility eye next to the layer- you should see the dark parts of the image change, but the lighter parts be unchanged. If the effect is too pronounced or too subtle, go back to the dark stock image, undo the curves operation and redo it to a different extent, and repaste the layer mask until you are satisfied with the result.
Step 8: The Light Layer
This process is almost exactly the same as adding the dark layer but with a few notable exceptions. Open the light stock image, paste it into a new layer in the composite and desaturate the stock image as before.
Now, the desaturated image is not quite ready for being used as a layer mask. Remember the white parts make the image opaque, and black makes it transparent. If you used this as a layer mask, it would use the bright parts of the bright image and the dark parts of the dark image- the exact opposite of what we want. To rectify this, invert the greyscale image (Layer -> Colors -> Invert). If your image needs brightening, do the curves operation as before- mine didn't, so I skipped this step.
Copy the bright layer mask image, create a layer mask on the light layer and paste the bright layer mask image into it as before. This should make the brighter parts of the composite image mroe vibrant- it usually has the effect of making daytime sky more vivid blue, increasing the colour gradient and decreasing wash-out.
Step 9: Your First HDR Image!
You now have your first complete composite HDR image! Save the image (preferably a layered copy as well as a flattened JPEG), and compare it against the original "middle" stock image- it should have less silhouette and wash-out, and more vivid colours. Often subtle HDR images look like paintings, because the painter's eyes have a much higher dynamic range than the camera so they will paint more like a HDR image. More extreme images often have a slightly dreamlike or "hyper-real" quality.
Experiment with different settings, taking a wider range of exposures for your stock photos, or using more than three layers. All the techniques described here can be extended to five or more images- just remember to invert the layer masks for layers brighter than the middle image, and use the curves tool to normalise your layer masks.
Step 10: Recap- Steps for Creating Brightness-mapped HDR
- Take stock photos- one exposed normally, one 1 stop underexposed, one 1 stop overexposed, from a tripod.
- Open middle image as background
- Open dark image, copy, paste into new layer in composite image, rename layer "Dark"
- Desaturate dark image
- Adjust curves on dark image to set levels
- Create a layer mask on Dark layer, copy monochrome dark stock image, paste in to layer mask and anchor
- Do the same for the light image- open, copy, paste into new layer, rename layer "Light", desaturate original stock image
- Invert colours in stock image, adjust curves if necessary
- Create layer mask on Light layer, paste inverted greyscale light image into it, anchor
- Save image
Step 11: Hold On.. "brightness Mapped"?
Astute readers may have noticed the previous step was labeled "for brightness-mapped HDR". There are other techniques for achieving a similar effect, which I will outline, but the process is broadly the same other than creating the layer mask image.
Tone mapping refers to another method for creating layer masks. While the previous instructions used the brightness of the stock image to create the layer mask, another school of thought says that the interesting parts of a stock image are those with the greatest local contrast. To make a tone-mapped HDR image, once you have desaturated the stock image, choose Filters -> Edge-detect -> Edge... and select Sobel. This will create a new image where the edges in the stock photo are highlighted in white, the uniform areas are filled in black.
This image is again not yet suitable for use as a layer mask- the edge-detected mask has too much "ripple" in it, and if used for a layer mask will create a very patchy image. To smooth out the edge map, go to Filters -> Blur -> Gaussian Blur. Now you will need to put in the rough width of the ripples in the edge-detected mask. This will vary depending on the size of your stock photo- I shrunk mine to 572*428 (because I was editing them on a 500MHz PIII over a remote desktop connection.. it was traumatic), so 5 pixels was fine, but full-res 6 megapixel shots may require a larger radius. You are aiming for the ripply areas to be blurred to a more-or-less uniform grey, but not to smear the white areas out too much- again, experiment.
Once you are satisfied, copy the edge-detect map to use as a layer mask as before. Note that as this picks out areas of high detail, you don't need to invert the maps from your bright layers before using them as layer masks.
Brightness mapping tends to create a subtler effect, slightly increasing the colour in the image for a natural feel, whereas pure tone-mapping often gives a more dreamlike or psychedelic quality. Once I figure out how to combine a brightness map with a tone map to get a little of both, I'll edit it in here.
Step 12: Man, That Was a Lot of Text
Paste the bright and dark stock images into the composite as separate layers. After desaturating the stock images, perform an edge detect (Filters -> Edge-detect -> Edge... -> Sobel), then a Gaussian blur to remove the rippliness of the edge-detect (Filters -> Blur -> Gaussian Blur). Use this image as your layer mask as before.
8 years ago on Introduction
Amazing tutorial. Thank you for this
8 years ago on Introduction
Thanks a lot for this tutorial. I still need to think about why it works, but I was able to get great results by making copies of a ho-hum image and using GIMP to adjust the exposure levels (to artificially create over-exposed and under-exposed shots). I used the layers and masks just like you said, and it worked really well. It will be an extremely useful addition to my skill set. Take care.
9 years ago on Step 12
Hello. I know how to make a mix of brightness mapping and tone mapping like you said.
For each bright or dark image, make a tone mapped mask and a brightness mapped one. Then make the tone map 50% transparent and merge it on top of the other map. Use this as your mask and repeat.
I actually haven't tried it yet, but I'm pretty sure it'll work.
9 years ago on Step 10
Wow!! Awesome and so easy! Thank you! After playing with this a few times, the 2.8.10 version of Gimp offers quite a few shortcuts, namely when you create the layer masks, it's now combined into a single step. There is no more need to desaturate or desaturate / invert first. Right click the layer, create layer mask, and just select the grayscale copy of layer and either check / uncheck the Invert Mask checkbox. Here's the compiled steps:
Steps to convert Images to HDR using
the gimp 2.8.10
image and paste it as a new layer on top of the base. You can do
that with the Edit \ Paste As \ New Layer option, or create a new
layer from the layers toolbar, paste the image, then anchor it down.
Rename this layer...
click on the dark layer and Add Layer Mask. Initialize Layer Mask
to: Grayscale copy of layer.
it as a new layer above the dark layer. Rename this layer.
right click on the dark layer and Add Layer Mask. Initialize Layer
Mask to: Grayscale copy of layer. One additional option is needed
though, to check the Invert Mask box. This will make the grayscale
mask a negative.
And, if you want to edit the curves of those grayscale masks, just right click the layer and make sure Edit Layer Mask is checked. Select that layer and have at it... :-)
9 years ago on Step 6
in Gimp 2.8.4 "Colors" is in a separate menu. Instead of Layer -> Colors -> Desaturate, it's Colors -> Desaturate.
10 years ago on Introduction
I don't want to be rude or mean but gosh this was confusing! It took me 4 hours, perhaps I'm just a dummy with this stuff and unfortunately my finished photo is rather lackluster, nearly the same.
11 years ago on Step 8
This tutorial is completely unclear from step to step, in particular from step 8 to 9 where there seems to be a step missing!
11 years ago on Step 6
For those having issues using GIMP see this MOD of Gimp .. it makes it more like Photoshop's interface....
"GIMPshop is a modification of the free/open source GNU Image Manipulation Program (GIMP), intended to replicate the feel of Adobe Photoshop. Its primary purpose is to make users of Photoshop feel comfortable using GIMP. It shares all GIMP's advantages, including the long feature list and customisability, while addressing some common criticisms regarding the program's interface: GIMPshop modifies the menu structure to closely match Photoshop's, adjusts the program's terminology to match Adobe's, and, in the Windows version, uses a plugin called 'Deweirdifier' to combine the application's numerous windows in a similar manner to the MDI system used by most Windows graphics packages. While GIMPshop does not support Photoshop plugins, all GIMP's own plugins, filters, brushes, etc. remain available. Host Unlimited Domains on 1 Account Due to the changes to the interface, many Photoshop tutorials can be followed in GIMPshop unchanged, and most others can be adapted for GIMPshop users with minimal effort."
14 years ago on Introduction
Well, now that I have tried this technique with GIMP on many photos I have set up for this, I am disappointed. The final image looked roughly the same, although some dark and light spots had changed, and I can see the exact changes from the layer masks. I have no idea if this is truly HDR or not, but certainly none of the final images I ended up with were anything much better than what I started with. Even in your example image, the picture is still very poor, although you now have some really bright spots around one tree. When I search around or HDR photos, they all look amazingly vibrant and surreal, and this effect is no where to be found on my photos or your example. It doesn't help that there are no other comments from people ere who have tried it. Has anyone else tried this? It would be good to find out if I am just doing something wrong, or if this instructable is not really making an HDR image. Thanks Andy
Reply 14 years ago on Introduction
As far as I know, most of the HDR pictures posted in the web are made using software or plugins that use edge detection and do a lot of fairly involved maths and very complex manipulation that is out of the scope of using the GIMP by hand. Your HDR will only be as good as the stock images- are they taken from a stable point so they all line up, and with a large enough range of exposures? You want as large a range of exposures as you can reasonably take, but +1EV to -1EV from the best balanced exposure is a minimum. My examples weren't great because they were hurriedly hacked together on a very, very old and underpowered PC, and involve moving trees taken at long intervals because I hadn't worked out bracketing on my camera at that point. The bright spots are an unavoidable consequence of parts of the subject moving between shots, so parts of the image that were tree in one shot are sky in another, which messes up the layering. If you want the very vibrant surreal pictures like the ones on the Flickr HDR pool etc., I suggest you download some HDR software or experiment with tone mapping as described above. I do state in the Instructable that this is a subtle effect, better for evening out the range of exposures in a photo than creating an artistic or surreal feel. Other than that I'm not sure what to suggest, but if you linked me to your source images and the finished image I could hazard a guess at ways to improve it?
Reply 14 years ago on Introduction
Ok, so I messed around with it more and figured out some other issues with the pictures I am using. I need to try a new set up I think. The light seemed great for a regular shot today, so I took 3 different angles for attempts with this HDR, but one was too hard to line up, and another was just too poor color to start with. But I'll try to paste the image of before/after of the one I had the best luck with. Problems: 1) It is incredibly hard to line up pixels. I tried using HDRAlignmentTool which does a reasonably good job at getting the photos in line, but only handles 3 shots to a screen. I then put in the layers and their masks, and found that images were still 1-3 pixels off which creates odd gray ghosting all over the place. So I manually moved them until it appeared to line up. Still though, when I zoom in to a far edge, I can see ghosted outlines (rotational translation maybe?) 2) The color curves were just plain bad to start with. Without changing anything on them, I end up with very gray images. I think crummy parts just added up in the layers to make blobs of gray. I went to colors > curves and pulled the right side lower, the left side higher (not technical I know, but this was after playing around with many configurations and it seemed best). This helped a lot in removing the gray blobs and making the overall color much better. 3) The color in the final image is better, but I think due to the small 1-2 pixel translations the sharpness decreased for the HDR image. Even with a tripod, a program to line up photos, and manually trying to move them, it seems almost impossible to get them exact to the pixel. Maybe a remote on the camera would help, but I don't know if my camera can change shutter speed by remote (I have a Canon Powershot S5 IS). Anyway, the sky added real texture, the underside of the kiosk is visible, and the grass is more vibrant. The tree edges and the gravel in the road are blurrier though.
Reply 11 years ago on Introduction
Try using a 2-3 second delay with your tripod that way the vibrations from you hitting the shutter button have time to die down before your exposure.
Reply 14 years ago on Introduction
Having looked into HDR on the net for a bit, I have discovered this plugin for GIMP which seems to automate a lot of the process and I think would come up with better results than doing it manually.
There are instructions on the site- seems to include more options for tweaking as well. It's quite a powerful tool from what I can make out after 5 minutes of playing about!
I was looking at this tut to see if I could create a faux-HDR image from a single photo. I'll give it a go now!
Reply 14 years ago on Introduction
This plugin is amazing, thanks for sharing it!
Reply 14 years ago on Introduction
Geekguyandy, it looks from that sample like you've got the technique right. For a dramatic effect you will need a large spread of exposures (at least 4 EV stops). My approach to lining up the images was to set one to 50% opacity and line up a spot in the centre of the image, then if the corners are out there must be a rotation, and a little trial and error with small-angle rotations should even it out a little.
Your camera will probably not have remote shutter speed control but it may well have bracketing- you set it to take a range of exposures and it takes them one after the other from one button press or remote click. Have a play with your camera to see if you can find bracketing, because it's a great improvement over adjusting the exposure by hand, meaning you jog the camera between each shot.
ScaryDave: I'll look into that plugin, it looks like it's doing pretty much the same as my technique but automating it. Call me a purist but I like the ability to tweak the curves on my images and layer masks myself.. but I will download the plugin and play with it to see if it makes the process quicker.
Reply 14 years ago on Introduction
Agreed, PKM, I like to have control too. However, the plugin does seem to be doing some other stuff to the images like applying gaussian blurs- not that that's too hard anyway.
The other sweet feature is the exposure alignment which is probably the only reason for using this plugin rather than doing it manually.
Thanks for the guide by the way- was very helpful =]
14 years ago on Step 6
I am amazed how much stuff one has to wiggle through just to get to be making a HDR image!! Or" To just to make a Colour Photo to be partly Black and White. Trying to follow some of these instructions are just plain difficult. This is mainly because it is often assumed that one knows where to look for what button or icon to press when an insttructions says; Paste image on to layer" Ok" Sounds simple. But wait! Now show me where to go to do this and what sequence to follow instead of just written basic intructions. They are ok if you know the Gimp program. What about the ones who are trying to make sense as to where everything is and what sequence to follow! Gimp is obviously a fairly loaded Software with all sorts of goodies. Just not user friendly. No wonder it is Free! I have a paid version i use to do HDR images with and it works great. Easy to follow and simple! It aslo has all the funtions one needs to make great HDR images. I was curious to see how Gimp would be for me. I'll stick to my paid Program. As i always say" Keep it simple. The world is complex enough as it is. Cheers" I have a HDR
Reply 13 years ago on Step 6
No wonder it is Free!
Yeah, cause professional-grade, feature-rich programs that took years of volunteer time to develop are obviously worthless!
Reply 13 years ago on Introduction
Like linux, drupal, php and almost all programming languages?
Gimp might be free but it only needs a skilful OP to produce good work.
Reply 11 years ago on Step 6
"Skillful OP" is someone who takes time to learn to use any programe. I believe GIMP is a masterful piece of software, made an enthusiastic community, and most of the beau tiful creativity comes from tenacious people.
If you're used to eat only steaks, you will never understand the healthy fish for your diet.