Archive for the ‘Whatever’ Category

Making HDR (“High Dynamic Range”) images in Photoshop — the way I do it

Sunday, August 1st, 2010

First, some links:
HDR according to Wikipedia

Here’s some of my attempts at HDR

OK, then. I’ve been asked to share some of my thoughts and tips on using Photoshop to create HDR images. So I will.

Why HDR?

All cameras are limited in the range of values that they can capture in one exposure. Ansel Adams made his bones by getting a really nice spread of tones (from black to white) in his prints using the ‘Zone’ system. The main idea was to avoid having large areas of your image that go completely black or white. The goal, expressed in a simplistic way, was to have information everywhere you looked in the picture — to avoid flattened black or white areas.

The hard part in achieving this is that when you pick an exposure level for a photo, your camera will probably end up getting one end of the black-to-white range wrong. Set the exposure correctly for the shadowy areas, and the lighter areas will be over-exposed; set the exposure to capture the details of the brighter areas and the shadows end up looking all blobbed up and black. It’s hard, but Ansel Adams got really good at getting a really nice spread of grays without blobby blacks and blown-out whites.

So did Eadweard Muybridge, but he cheated. Muybridge wouldn’t worry about getting the exposure on the sky right when he shot landscapes, because he didn’t need to: he had a drawer filled with beautiful negatives of nice sky-shots filled with detailed clouds, and he just double-exposed his prints with the sky shots he had laying around. That fixed his blown-out sky problem. This trick made him a lot of money long before he achieved lasting (and, in my book, deserved) fame by perfecting stop-motion photography.

In his defense, Muybridge would’ve used the modern HDR techniques outlined below if he could, but it was really hard to do the double-exposure trick with negatives that weren’t all sky. If I recall correctly, he tried it, and it didn’t work out.

While it is probably possible to get nearly-Ansel Adams-quality exposures out of modern digital cameras, few of us have the patience (or, let’s admit it, the skill) to manage it. So we cheat.

(Relatively) Easy HDR with digital cameras

Every digital camera I’ve owned (going back, now, to 1999) has done an acceptable job of calculating a pretty good exposure automatically, but all of them (from a Fuji FinePix 1300 to a Nikon D50) usually pick an exposure that leaves muddy shadows or blown out highlights — sometimes both in the same picture. Time (read: Improved technology) has improved things, but even today few digital pictures end up ‘perfectly’ exposed.

Happily, though, as quickly as a modern camera can calculate a decent exposure, it can calculate a related under- and over-exposure. This is called ‘bracketing’, and your camera probably offers it as an option.

What your camera will do if you turn this on is take more than the ‘best’ calculated exposure; it’ll throw in others just above or below the calculated ‘best’. For this discussion, we’ll assume you’ve set up your camera to include an under-exposed pic and an over-exposed one. (There are other ways to use bracketing, but you’re on your own for those, champ.)

My guess is that the camera makers included this feature, originally, so that you could compare the three images and pick the one that best suited your intention when you were shooting. What we’re talking about with HDR, though, is taking the best parts of each of the three and combining them into one image (I’ll try to be careful here and not call the results of HDR ‘pictures’).

Side note: I own a D100 that I picked up used (and cheap) as a back-up camera, and it doesn’t seem to bracket as ‘widely’ as I can make the D50 bracket; I think Nikon, when they made the D100, was still thinking that bracketing was for taking three different, but still ‘OK’, pictures. My D100 pics don’t seem to HDR as nicely as my D50 ones do. YMMV

Techniques

So: at this point you should have three pictures that are as near to identically framed as you could manage, but that are spread out in exposure (from ‘ouch, way too bright’ to ‘ugh, muddy and dark’ with a pretty normal looking one in between). Photoshop (the only image editing software I’m going to reference, ’cause it really is good and you should probably be able to lay your hands on it somehow) has a menu item located at File->Automate called ‘Merge to HDR…’ You could go there and then select the three pictures you have and then go along for the ride. Try it. That’s where I got started, but I ended up unhappy with the results; I didn’t feel that Photoshop was making the same decisions I would have, and I wanted more control.

If Photoshop’s ‘Merge to HDR…’ makes you happy, use it. It’ll save you all the work I’m going to outline in the rest of this post (it’ll even save you the trouble of reading it).

Back yet? Let’s try another technique.

First, though, let’s review our goals. We, typically, want to take the middle picture (which should be pretty good, but probably has some blown-out highlights and some muddy shadows) and add the nice bits from the other two photos to it. And we don’t want the results to look horribly fake. Photoshop has some tools that will help us.

The main one is Layers, which will let us stack our three picture on top of each other in one image. That’ll be the starting point. I get there by selecting the three pictures in Adobe Bridge and then choosing Tools->Photoshop->Load Files into Photoshop Layers… Skipping Bridge, you can open all three picture in Photoshop and paste two of them on top of the third. Either way, you’ll end up seeing only the top one on your screen, but if you open Photoshop’s ‘Layers’ Window (accessible in the ‘Windows’ menu) you’ll see a Layer for each picture.

Since we’re going to be seeing parts of all three layers in the finished image, it’s important that they all line up with each other. There is a chance that you held your camera so still that the pictures all line up perfectly, but mine never do. I select all three layers in the Layer window and then go to Photoshop’s Edit menu and choose ‘Auto-Align Layers…’ In the resulting dialog, I choose the ‘Auto’ projection option and hit OK.

If that works, your image will be lined up much more nicely than I can ever seem to manage when I try to adjust the alignment by hand.

Staying in the Layers window, you can re-arrange the layers so that the ‘middle’ picture is at the bottom. The idea here is to leave the ‘too dark’ and the ‘wow, that’s over-exposed’ layers above the ‘meh’ middle picture, but to delete the bad parts of them so the good parts of the ‘meh’ layer show through.

That leaves us needing to delete the ‘bad’ parts of the light and dark versions of the image. I do this using Photoshop’s Select->Color Range… option. What this option does is automatically select all the pixels in the current Layer that match whatever is set as the Foreground Color, but with a controllable amount of ‘fuzziness’.

Let’s review the steps we’re going to take in English before I lay out the step-by-step Photoshop routine; understanding the process in English will help you keep track of where you are, and to figure out what went wrong when you misstep:

  • The over-exposed Layer, which does have interesting information in its darkest areas, needs everything but its darkest parts deleted.
  • The under-exposed Layer, which does have interesting information in its lightest areas, needs everything but its lightest parts deleted
  • The starting point for all this pixel deleting is a three-layered image with the middle exposure at the bottom (and all of the Layers Auto-aligned). If you aren’t there right now, go ahead and catch back up. Additionally, these steps are based on having the lightest (over-exposed) Layer on top, so go ahead and drag it to the top (if it isn’t already there). (It doesn’t really matter to the outcome which Layer is on top, but I’m only going to describe it in one order, sorry.)

    The steps:

    In the Layers Window, make the middle Layer invisible and select the top layer.

    In the Tools palate, make sure that the Foreground color is set to pure black.

    Use the menu item Select->Color Range… to bring up its dialog window.

    Select Localized Color Clusters (or not, but I’ve enjoyed the results when I do).

    Adjust the Fuzziness to Max (200). (Or less, but that’s for when you get a sense for how Fuzziness works.)

    Hit ‘OK’. That will return you to the Layer with a bunch of selection-indicating lines buzzing at you. You can’t really tell by how it looks, but all of the darkest areas (the interesting ones in this Layer)) are now selected. We need to:

    Use the menu item Select->Inverse to get everything but the darkest areas.

    Hit the Delete key. Voilà!

    A side note: If you overlooked the ‘hide the middle Layer’ step, the deleting will reveal the too-dark Layer that’s underneath; don’t panic. Just go ahead and hide the middle Layer now.

    Before we move on to ‘fixing’ the dark Layer, let’s pause and play with what you’ve done. First, hide the selection-indicating lines (turn ‘Extras’ off in the View menu, or just hit Command-H). That’ll make it easier to evaluate what happened. In the Layers Window, show can alternately hide and show the over-exposed Layer to get a before-and-after comparison. If the results look more-or-less OK, we’ll move on. If you want to re-do the deletion with different settings, undo (Command-Z) the deletion, Deselect (Command-D), and try the Select->Color Range…/invert selection/delete steps again.

    OK? Back to steps.

    In the Layers Window, make the middle Layer visible, the top Layer invisible, and select the middle layer.

    In the Tools palate, make sure that the Foreground color is set to pure black.

    Make the previous selection go away by hitting Command-D (or choosing Select->Deselect).

    Use the menu item Select->Color Range… to bring up its dialog window.

    Select Localized Color Clusters (or not, but I’ve enjoyed the results when I do).

    Adjust the Fuzziness to Max (200). (Or less, but that’s for when you get a sense for how Fuzziness works.)

    Hit ‘OK’. That will return you to the Layer with a bunch of selection-indicating lines buzzing at you. You can’t really tell by how it looks, but all of the lightest areas are now selected. We need to:

    Use the menu item Select->Inverse to get everything but the lightest areas.

    Hit the Delete key. Yes, that was mostly copy-and-paste from the top (over-exposed) Layer’s instructions, but the differences are important. I often do the light-Layer steps on the dark Layer (and/or vice-versa) by accident and have to undo them. No worries, we haven’t saved anything yet. (Funny side-note: I just typed them backwards and had to re-do the typing.)

    Go ahead and make all three Layers visible again. The rote stuff is done.

    While the image is still in three Layers, you can adjust the Levels (or Curves), contrast, sharpness and even the Transparency of each Layer individually to get the image looking the way you want. After that, you can use the menu that pops up from the Layers Window to flatten the image. Then you can make your final, global, changes.

    There is a pretty good chance that your Layers got skewed a little in the alignment step, so you’ll probably have to crop the image a little to tidy it up.

    You’re basically done. Congratulations. Me? I do one more step: I copy the HDR and paste it on top of the original middle exposure, crop and flatten that, and use ‘Save As…’ to make the final image. That’s just an easy way to preserve (one third of) the EXIF information along with the HDR.

    Enjoy.

    If (cursing) rabbits had (little) guns

    Wednesday, July 28th, 2010

    …and dogs were (still) stupid enough to chase them:

    “Woof woof” this, motherfucker! [BLAM! BLAM!]

    Craig Ferguson is a funny, funny man.

    Daniel Schorr passes

    Friday, July 23rd, 2010

    NPR obituary here. The fact that he was still working at 93 made me feel like he’d be around forever.

    I did not know that

    Wednesday, June 2nd, 2010

    The famous ‘Gee Bee‘ racing airplane from the early thirties earned its reputation as a killer by crashing spectacularly on December 5, 1931 (and on film) during a speed record attempt at what was then the Wayne County Airport. That’s DTW to you and me.

    Random update

    Saturday, May 29th, 2010

    I’ll start by mentioning the places I didn’t go this week: Honolulu, HI and Canton, OH (thereby connecting those two iconic American cities for, perhaps, the very first time).
    Canton and Honolulu share something: they both have newspapers that are combining. Happily, I won’t be having much to do with either project for now.

    I didn’t have to go to Hawaii because those folks have their shit together enough to figure out how to merge papers using their current software on their own. I didn’t have to go to Canton because they’re so far behind that there wouldn’t be enough work for me to do. Either way, cool with me.

    I’m planning on going to visit Centennial tomorrow. It’d be nice to get her in the water soon (meaning in a week or so), but, well, we’ll see. There isn’t much in the way of dropping her really, just a little paint touch-up. There is one project that I’d like to complete while she’s on dry ground, though.

    4650449807_14feb341f5_m.jpgThere is a roughly square hole that goes right through the boat, the one that the engine pokes out through. At a glance it looks like a clever solution to the problem of fitting a motor, but reflection exposes an annoying flaw. To elaborate, the hole the motor sticks out through functions as a speed brake; it interrupts the smooth flow of water from stem to stern.

    I am pretty sure that this is a big cause of my tacking woes. I have a sheet of copper on the way that I’m going to fashion into a fairing that will smooth over this opening. We’ll see.

    Also:

    Thursday, May 20th, 2010

    I just watched another Avatar ad. Wow. That looks like the worst movie since Titanic. Maybe even worse than Titanic. Wow.

    Who knew.

    Friday, April 30th, 2010

    Apparently Microsoft™ thinks that humor is a core competency. Can I please have some sort of certificate now?

    Hat tip to the incomparable @hodgman.

    Turns out that sunshine might help me out ‘where the sun don’t shine’

    Wednesday, April 21st, 2010

    Vitamin D, which I can get for free (along with a bitchin’ tan) from sunlight, might keep my butthole from killing me. My love of being contrary may add some years (amount of years yet to be determined) to my life.

    Yeah, Krugman again:

    Tuesday, April 20th, 2010

    To break through that, you need hard-hitting campaigns and simple slogans. And I have a sinking feeling that once again, the Obama team is going straight for the capillaries. Let’s hope they prove me wrong.

    Maybe just go read it, but, still, “straight for the capillaries” is Nobel-worthy.

    Model railroading

    Saturday, April 17th, 2010

    I wonder if there are many model railroaders who have ended up really good at painting tiny graffiti.

    Gah.

    Sunday, April 11th, 2010

    Tiger just three-putted from five feet. Oh, well.

    Then he eagles the next hole. This guy is killing me.

    Not Phil, please not Phil. Doesn’t my booing count for anything?

    C’mon, Phil, use the driver on 18. That club never lets you down.

    Three wood? Pussy.

    Jizza, an unlikely Human Beatbox

    Friday, August 7th, 2009

    As some of you may already know, I’m a huge fan of the BBC show Top Gear. You may also know that I’m a fan of the site Jalopnik.com.

    That all comes together in a video they linked that features Jeremy (‘Jizza’) Clarkson clips mixed into an electronica video.

    If you’re into that kind of thing, I conveniently (for you) ripped an MP3 of it for your clicking pleasure. Enjoy.

    Prepped for soda-blasting (I hope)

    Monday, June 1st, 2009

    3585544009_09297ba252_m.jpg We made it back to the Centennial last weekend. We got the leeboards off and set up on sawhorses in anticipation of the soda-blasting happening on Tuesday. Thursday looks more likely now, what with rain forecast until then.

    The four new sawhorses are from Harbor Freight. They seem very sturdy, and were only $15 each, but each one had 26 bolts, 26 nuts, and 8 wood screws that had to dealt with. That got old fast.

    The leeboards weren’t that bad to deal with. They are pretty heavy, and the hardware was a little balky. That said, leeboards have to be tons less of a hassle than a centerboard.

    All the paint, topsides and bottom, is now in hand or on the way. Things should get underway Saturday morning, sharpish. Anyone who wants to help with the painting can contact me or leave a message here.

    Also -

    Wednesday, May 20th, 2009

    LeBron James makes playing professional basketball look like fun. I haven’t seen that in like, forever.

    Addenda: “Chuck just pulled your hamstring”

    I bring you fire

    Wednesday, May 6th, 2009

    3507612696_3df2a28a32_m.jpgI fueled up the Primus No.523 and gave it a go. And it worked great with no fancy repair work. The pressure pump could probably use an overhaul, but it did the business. I’m quite pleased.

    I wasn’t organized enough to do a BTU test last night, but I’ll get to it. It seemed to be putting out quite a bit of heat, though.

    Primus No.523

    Monday, May 4th, 2009

    3501244357_415f019c0b_m.jpg This beauty arrived from Australia today. I think it might be pre-war, but there isn’t much info to go on. I got it on eBay from Australia (at a pretty reasonable price, too).

    Professor Paul Krugman wins the Nobel Prize

    Monday, October 13th, 2008

    AP story here.

    This makes me very happy (and not just because Krugman is the only Nobel winner I’ve actually read before he won).

    Now he’ll have to be introduced on the TeeVee as “Nobel Prize winner Paul Krugman,” which has a much nicer ring than “shrill lefty economist and blogger Paul Krugman” (or words to that effect).

    His not-at-all shrill (and more ‘reasonable liberal’ than ‘lefty’) blog can be found here, and his Monday and Friday New York Times columns can be found here (you may have to register, but there’s no charge now like there used to be. A charge I paid happily, BTW).

    Epic

    Friday, September 26th, 2008

    epic.jpg

    Amusing

    Wednesday, September 10th, 2008

    Periscope, an app from Freeverse, can upload timed iSight pics to my .Mac site. Check it out.

    My foot is mostly healed

    Saturday, June 7th, 2008

    I got new x-rays on Tuesday, and the doc said I was done with the boot. No running or jumping for another six weeks? No problem there.

    I wore an Aircast™ plastic cast for almost six weeks, and I guess it was OK. It squeezed my toes, so I couldn’t wear it as tight as I thought I was supposed to, but the doc said that it didn’t need to be very tight (pretty much just wearing it does the thing). Another note the techs didn’t share with me (but that I learned on wikipedia): your feet swell when you sleep, so don’t pump up the air part of the Aircast™ too tight before going to bed.

    The crutches (pictured in the previous post) were awful, so I bought myself a pair of these forearm-style crutches. Totally worth it.