Faking HDR in Gimp

March 11, 2010
One of the images I created using this method

One of the images I created using this method

So, this is the entry that has taken me over a month to write, for multiple reasons. A reader asked if there was a way to do HDR images in Gimp, and the short answer is No. The long answer is that a lot of people have tried to fake it (there’s actually a gimp script you can find here that will do it for you), but it seems the ones I have found have either giving you a “crazy color pop” effect (which is what the script I linked to above does) or an “increase the dynamic range” effect – much like the FX-Foundry script I talked about here.

This tutorial is going to try to merge BOTH of those effects into ONE photo. If you’re only interested in one or the other, I suggest you check out the approriate script above.

This method is adapted from this method on instructables. In fact, that method is shorter and probably less confusing, but the results weren’t exactly what I think of when I think “HDR”. That being said, the first half of my tutorial is almost exactly the same as that one, so if what I’m writing below seems a bit overwhelming, you might want to try following that one a few times first.

So. First. I assume that you either have three images – one that’s exposed “properly”, one that’s underexposed and one that’s overexposed – either because you took three actual images at different exposures or because you’ve used the exposure slider in ufraw (or the RAW editor of your choice) to produce those three images (which is what I did).

Here are my three photos:

underexposed

underexposed

overexposed

overexposed

"properly" exposed

"properly" exposed

Now, I open up all three in Gimp as multiple layers in the same photo and order the layers as so:

Layers

By the way, perhaps I’m admitting something I shouldn’t here, but it took me a bit of a while to figure out how to open up multiple photos in one image in Gimp. As I mentioned above, I’m converting from RAW here using UFRaw, so each time I press “OK” in UFRaw to open it in Gimp, it creates a separate Gimp window. So I copy and paste from there into my original file in the other Gimp window. Then, the key is, you have to press the “new layer” icon at the bottom of the layer dialog box (it looks like a piece of paper). If you have your three separate images already (outside of Gimp), you can drag them from the file system into Gimp, and it will automatically create each of them as separate layers.

Anyway, notice that I have my “properly exposed” layer (which I labeled as just “exposed”) at the bottom with my underexposed image on top of that and the overexposed image at the very top. For now, let’s make the overexposed layer invisible so that we’re looking at the underexposed layer.

Remember I’ve talked about Layer Masks before – the general idea is that you add a layer mask to one of your layers, and then if you paint black on that mask, that part of the layer will be transparent and if you paint white on the mask, that part of the layer will be opaque. So, the idea here is that we want the dark parts of this layer to be transparent (we don’t want to see them – we want to see the “exposed” layer below it instead), and the lighter, exposed parts (like the sky in the upper left) to be opaque.

The way we’re going to do this is by creating a duplicate layer of the underexposed layer (I know this might not make sense at first, but keep reading, I think it’ll all come together for you in a minute). Now desaturate it (I just used the default Colors –> Desaturate). When I first did this, the sky was still pretty gray in my photo, and since I really want to see the sky from this underexposed layer, I fix this by adjusting the curves (you can do this with Levels, too – whatever you’re more comfortable with, just play with it until you get the parts of the photo that you really want from your underexposed photo to be pretty white instead of gray). This is what my black and white layer looks like:

underexposed as black and white

underexposed as black and white

Now, we want to turn that into the layer mask on the underexposed layer. So, select all of the black and white layer (by going to Select –> All or just hitting Ctrl+A), and copy it, then go back to the “under” layer and right click and Add Layer Mask (just pick whatever option it defaults to when it pops up, you’re just going to turn it into your black & white image anyway). Now, with the layer mask selected hit paste (Ctrl-V). Notice that you get this “Floating Selection” layer. Right click on it and select “Anchor Layer”:

Anchor Layer

And now it turns that into your Layer Mask! Now we don’t need that “underexposed copy” layer anymore, so you can right click on it and delete it. When you do that, you can see the results of your layer mask on the under layer. Here’s what my Layers look like now:

Layers

… and here’s what my image looks like now, (as a reference, that’s the original “exposed” version below it for comparison – notice the difference in the sky in the upper left):

With the underexposed layer mask

With the underexposed layer mask

"properly" exposed

"properly" exposed

Now let’s concentrate on the overexposed layer and make it visible again. We want to do the opposite with this layer as we did with the underexposed layer. We’ll start off by duplicating the layer and desaturating it, which looks like this:

Overexposed as black and white

Desaturation of the overexposed layer

Now, if we were to turn that into a mask, the overexposed sky would be visible, instead of the nicely-exposed area on the right. That’s not what we want! In fact, that’s the opposite of what we want. So, everything that’s white we want to turn black and everything black, we want to turn white. Luckily, there’s a menu item that does just that. Go to Colors –> Invert and now it looks like this:

Inverted!

Inverted!

Now, we’ll turn that into a layer mask just for the overexposed layer just like we did the underexposed layer mask: Copy layer, create layer mask on overexposed layer, paste, anchor layer, then delete the black and white layer. Now our photo looks like this (compared with “exposed” again – notice how there’s more detail in the door area on the right):

Both under- and over-exposed layers have masks

Both under- and over-exposed layers have masks

"properly" exposed

"properly" exposed

Well, more of the photo is exposed properly now, I guess, but it still doesn’t “pop” like I want it to. Note: This is where my tutorial differs from the instructables one. This is also where I start having trouble describing what I’m doing, so if you’re not following along, PLEASE ask questions. So, I’m going to create a duplicate layer of both the underexposed and overexposed layers. So now my layers look like this:

more duplicate layers!  Oh my!

If you’re doing this yourself at this point, you might notice that the photo changes appearance when you do this – I’m not posting that change in look here, since that’s not my final goal here, I want to play with those duplicate layers first. I’m going to change the blend mode of the underexposed copy layer (so, of the two underexposed layer, the one on top) to Burn and the blend mode of the overexposed copy layer (the layer on the very top) to Dodge. Now, start playing with the opacity of all four layers (all but the “exposed” layer, that is). I can’t give you some magic formula here, because I’ve done this a couple times on a number of different photos and I like something different each time. But I will tell that for THIS photo my layers (from top to bottom) are at:

  • overexposed copy – dodge – 100%
  • overexposed – normal – 75%
  • underexposed copy – burn – 100%
  • underexposed – normal – 75%

And now my photo looks like this:

After adding the Dodge and Burn layers and adjusting opacity

After adding the Dodge and Burn layers and adjusting opacity

I’m still not completely happy with it, but it’s getting closer. Now I make a new layer from visible (found under the Layer menu) and make sure it’s at the top of all my layers:

New from Visible

First I go to Colors –> Hue-Saturation and bump up the saturation, and then I sharpen the photo and I end up with this as my final Fake HDR Photo:

My interpretation of fake HDR

My interpretation of fake HDR

I really don’t know what you guys are going to think of this, because honestly? I don’t like it! Which is probably another reason it’s taken me so long to write this entry. I confess: I don’t like most HDR photos! I think it’s one of those things that a lot of people like, and a lot of people don’t like, but whether you like it or not, it exists, and it’s popular, and so it can’t be ignored, which is why I really did my best to duplicate it the best I could here. When I think HDR, I think of the following things: No overexposed or underexposed areas of the photo, bright colors that pop, and a somewhat cartoon-y feel to them. And I guess the photo you see above has all of those things?

I tried this tutorial on a few other photos. Sometimes it turned out pretty good (like the photo you saw at the top of this entry – I actually really like that photo)

Sometimes it turned out really bad:

Yeah, this is kinda scary looking, actually.

Yeah, this is kinda scary looking, actually.

I think it was all the thin branches in that one that really threw the whole thing off.

Anyway, if you try this tutorial, let me know what you think – I won’t be offended if you hate it, I promise. If you like HDR photos – do you think this is an ok interpretation of it?

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.


Tags: ,
Filed under: Photo Editing
  • Hello,

    Your excellent blog inspired me to share my fake HDR procedure:

    I use the "Fake HDR Effect adaptive" and "Fake HDR Effect enhance" scripts found here:
    http://registry.gimp.org/no...

    Both of the scripts as such are quite useless, or maybe I just can't use them. Fake HDR adaptive gives a grazy contrast pop. Fake HDR enhance in turn results a grazy saturation/color pop.
    I use the scripts with following procedure:

    1. Open the original picture and if needed, tune it with levels, curves, duplicate overlay/screen layers or whatever method you prefer.
    2. Duplicate the original picture (Ctrl-D)
    3. Run Fake HDR adaptive for the duplicate (default settings); copy the result and put it as a layer above the original picture
    4. Reset/undo the duplicate to its original state; now run Fake HDR enhance for it (default settings); copy the result and paste it as the topmost layer in the original picture. The duplicate picture is not needed after this step.
    5. Now you should have three layers in the original picture: Fake HDR enhace layer at top, Fake HDR adaptive layer in the middle and the original picture at the bottom layer.
    6. Change top layer mode to saturation and tune opacity down to taste (usually 10-40 is enough for me).
    7. Middle layer might work best as normal, overlay, hard light, soft light or even screen; give it a try. In any case, opacity should usually be considerably less than 100.
    8. Basically, that's it. You can also try to add more adaptive/enhance layers with screen/overlay/etc. modes. Try also using grayscale copy (inverted or straight) of layer as a layer mask for the layers created with the scripts.

    Here is a quick sample of the method:

    Before, almost straight from camera (actually two pics stitched together and not from camera but "camera", ie. pics taken with mobile phone):
    http://files.myopera.com/pa...

    After:
    http://www.flickr.com/photo...

    If someone wants to try it, I think that one or the other of the scripts calls for this plugin, which you need to install also:
    http://photocomix-resources...

  • What is HDR?!?

    I googled it after reading this entry, because I really did not know, and I see that it means High Dynamic Range. Which is still not thoroughly helpful to me. Further reading reveals to me that it means something along the lines of super colorful, highly processed photos. So I got the answer I was looking for, but I thought maybe some other beginner like me wasn't so sure of what the heck you were talking about either, and might benefit from a little explanation.

  • @Jafael
    A short description of HDR would be this.
    By combining images with different levels of exposure, you bring out as much of the shadow and highlight details in the image as you can. Unfortunately, the monitors cant properly display all the colours that do come out in this process. For this you have to "Tone Map" the resultant combined HDR (by using other software) which will map the colours in the image to those that can be shown on your screen.

    The highly colourful images that you are talking about is usually people going overboard during the tone mapping. The process of creating a nice HDR can result in images that show you more detail than a normal image would. For example, the inside of a church, where there are lots of shadows and highlights together. or it can bring out a reflection that may not be readily visible in the normal image.

    Hope this helps.

  • I'm afraid covering that would be far outside of my expertise or the point of this entry. Though, you're right, I probably should have included a link to a good explanation. If I find one, I'll post it.

  • Brandon

    It is a personal preference thing I guess. I liked the effect of your process. And it is something that is easy enough to do.

    I really like HDR photos...for instance, I thought the pictures found at the link that Shotslot put up were great. To me they have a depth, and mood that makes them very interesting. I however do not think of them as "photographs", but more as digital art that started with a digital photo base.

    One tip to shorten your process...
    You can right click your layers in the layer list and choose add new layer, then choose the "Grayscale copy of layer" option in the options window that opens. This would save a few steps. And for the layer mask that gets inverted, just right click that layer, choose "View Layer Mask", Colors -> Invert, and finally, uncheck the show layer mask option.

  • Great tips, thanks!

blog comments powered by Disqus