Exploring HDR processing of a single RAW image

2011-10-23 17:10:00-0700

You don't have to research HDR much to find the common questions about how best to process a single image into an HDR. Some people suggest taking the photo and running it straight through Photomatix, letting it do all the legwork. Others suggest taking the image into something like Lightroom and exporting different versions of the image with the exposures set at the different increments to mimic exposure bracketed shots.

For a long, long time I was in the first camp. The thinking says simply that by adjusting the exposure you're not adding anything to the image. It suggests that since all of the data is contained in the original image, exporting differently exposed versions of the same photo is just presenting that data in a different way. However, I have recently discovered that this assumption is wrong. Amazingly, many of my assumptions on what was happening with the data in my photographs turned out to be wrong, and overly generous. I put too much faith in the software, assuming it would do things in the most efficient way because that was the ideal way to do it. Unfortunately, the truth is that Photoshop and Photomatix do terrible things to your photographic data, and I will show you this fact here.


A few months ago I was on a boat with my wife, and as is normal in San Francisco summers the fog was rolling in past the Golden Gate Bridge. There was a lot of movement on the boat so I couldn't take a bracketed set. I didn't care though. I assumed Photomatix would let me balance these extreme lighting conditions with no sweat. The photos I took on that boat were the beginning of my discovery that I was giving Photomatix too much credit.

Here is an original photo taken on the boat with a Canon T3i at 14bpp raw:

[caption id="attachment_4459" align="aligncenter" width="300"]The untouched file, default settings. The untouched file, default settings.[/caption]

It's not immediately obvious that the The Golden Gate Bridge is in the background, but you can barely see it on the left. This type of situation is where I was hoping that Photomatix would solve my exposure balance problems. When I looked at the RAW file in Lightroom and dropped the exposure down I could see the bridge. I imported the single image into Photomatix Pro 4.1 and did a default tonemap, hoping to bring out the details that were lost in the highlights. Here's what Photomatix produced:

[caption id="attachment_4458" align="aligncenter" width="300"]Tonemapped from DNG in Photomatix using default settings Tonemapped from DNG in Photomatix using default settings[/caption]

That's interesting, but it's not exactly helpful. Specifically, you still can't see the bridge and other features that exist in the RAW data. In its place is a smooth, unrealistic, grey sludge. Clearly Photomatix has thrown away some important data that would have been very useful. At this moment I realized that the technique of exporting a single RAW image with different exposure settings in fact does allow you to create better HDR images in Photomatix because it was obvious to me at that point that Photomatix was throwing away useful data when working with data from a single RAW file.

After doing an hour or so of research on gamut and image formats, trying to get a grasp on their differences, I thought "my camera is only 14 bits per pixel, but PSD can be 16 bits per pixel, so surely it must be able to store all the extra information that Photomatix is throwing away!" I converted the DNG to a PSD, imported that into Photomatix, ran it through the default tone map settings can came out with this:

[caption id="attachment_4457" align="aligncenter" width="300"]Tonemapped in Photomatix from PSD using default settings Tonemapped in Photomatix from PSD using default settings[/caption]

Despite the fact that many of the important details are still missing, this image is better than what I got while running the DNG file straight into Photomatix. This means that Photomatix is bad at handling what is purported to be THE raw format for digital photographs from all manufacturers, the Digital Negative. DNG supports data from more RAW images formats and more types of metadata than any other format. There is a free converter with a graphical UI and a scriptable CLI interface, a freely available SDK, and it even has the ability to store the original RAW file inside of the DNG in case you simply don't trust what it's doing with your RAW data. It's remarkable that even with all of that available, Photomatix still can't transpose the 14 bit raw data into a 32 bit radiance file without losing significant amounts of data.

I also thought it was peculiar is how Photoshop itself was unable to show the extra data. When I converted the DNG into PSD, I had similar results as I did with the DNG file. This led me to do another hour or so of research, and I eventually found out what was going on.

RAW data is storing information about all of the light that came into the camera and hit the sensor. This data includes parts of the image that are outside the perceptive range of your eyes at any, shall we say, iris exposure setting. That is, when the iris of your eye opens and closes, it allows you to see brighter or dimmer things, but you cannot see the whole range of luminance at once. Your eyes are limited to a medium to low dynamic range, thus the need for HDR and tone-mapping to display all of the information. RAW images store data that is beyond the limits of the whitest white and the blackest black that you can see in a properly exposed RAW photograph. Photomatix also has several formats in its arsenal that are also supposed to do that, and they very well may do so, but that's beyond the scope of this article. PSD does not store this extra data. Tiff doesn't either. JPG certainly does not. These image formats are storing color values between white and black. White is the brightest point that your eyes can see and can be displayed, and no information past that point is stored. Black is the darkest area your eyes can see, and no information beyond that point is stored. These formats are rasterized.

On a side note, this explains why you can't gain anything if you were allowed to convert rasterized image like PSD or JPG into a DNG file. Since you're not gaining any extra data when you attempt to convert a rasterized file to a RAW file, you might as well just use a TIFF or PSD, and in fact the DNG Converter will not let you create a DNG from anything but a RAW file format.

What's interesting to me is that professional photo editing resources toss this rather important detail out all the time and put PSD and DNG on the same level. Matt Kloskowski from Adobe constantly gets hassled at Lightroom Killer Tips for going back and forth between Lightroom, an app with a purely RAW format based workflow, and Photoshop, which works with rasterized data which truncates lots of important information from both extremes of the radiance spectrum. Professionals like Matt are, in essence, teaching us techniques that are severely sub-optimal and disregarding this data loss issue entirely.

Moreover, Professional applications like Adobe Photoshop and Photomatix Pro are also silently truncating important data at both ends of the radiance spectrum when they are supposed to be doing exactly the opposite. Photomatix has one primary purpose, to compress images that have a wide radiance down into images of narrow radiance so our eyes can see the features beyond our visual perception. Nobody who uses this app expects it to simply throw away the parts of the image that can't be seen. If we needed that, we'd shoot in JPG or TIFF and use shadow/highlight in Photoshop.

So, after all of this thinking and researching, I did a final experiment. I used Lightroom to create three versions of the same image and merged them in Photomatix Pro as if I had taken an exposure bracketed set. The three images are -4EV, 0EV, +4EV. Only the exposure was changed, and the watermark wasn't included in the test.

[caption id="attachment_4460" align="aligncenter" width="300"]Adjusted in LR to -4EV Adjusted in LR to -4EV[/caption]

[caption id="attachment_4459" align="aligncenter" width="300"]Default settings in LR, 0EV Default settings in LR, 0EV[/caption]

[caption id="attachment_4461" align="aligncenter" width="300"]Adjusted in LR to +4EV Adjusted in LR to +4EV[/caption]

I merged these in Photomatix and used the same default tone-mapping settings as the previous photos.

[caption id="attachment_4456" align="aligncenter" width="300"]Tonemapped from PSD's at -4EV, 0EV and +4EV in Photomatix using default setings Tonemapped from PSD's at -4EV, 0EV and +4EV in Photomatix using default setings[/caption]

In this final set you can see the extent of the information that was being thrown out by Photoshop and Photomatix. Specifically, the entire Golden Gate Bridge was captured by the camera, but was invisible to both applications using their standard import methods.

And with that, I am now on the side of the people who recommend exporting exposure bracketed versions of a single exposure when using Photomatix to tonemap a single image. Science, logic and truth prevail, revealing to everybody the Golden Gate Bridge.

By Daniel , Category: photographology

Tags: analysis / journal / lightroom / photography / photomatix / photoshop / experiment / raw /

Other articles

Quick flickr tip about shutter actuation count

2010-11-14 20:11:00-0800

If you want to see how many photos your camera has taken, take a photo and upload it to Flickr, then look at the EXIF data. The "Image Number" field is the number of shutter actuations of the camera body that took the photo. This is a useful piece of ...

By Daniel, Category: photographology

Continue reading …

Update from normalcy SF

2010-11-12 19:11:00-0800

Since I haven't been traveling, it's been a long time since I've actually written on my blog. Right now I'm sitting on my front steps in Chinatown, SF, sipping on cognac and waiting for my wife to come home with the key to our front door ...

By Daniel, Category: blog

Continue reading …

One year and 4 days later

2010-06-18 01:06:00-0700

WarzauWynn posted a photo:

One year and 4 days later

One year and four days after I asked Tien to marry me, Tien passed her visa interview and our dreams were allowed to continue becoming reality.

By WarzauWynn, Category: 365-32

Continue reading …

Saigon, Consulate, Hospitals and Hotels

2010-06-10 23:06:00-0700

A lot of the days in Binh Hoa blur together with very little highlights. Most of the time is spent playing Wii, PvZ and Marble Mixer, going out for coffee and tea, and laying around in the heat drinking fresh fruit juice. This is how most of the time was ...

By Daniel, Category: blog

Continue reading …

From Hanoi to Binh Hoa

2010-06-08 23:06:00-0700

Because our flight had been changed and was no leaving that night, we had another day to kill, so we took no care to wake up early on June 2nd. Tien was craving bao cake so we went and got that for breakfast, and of course coffee. While we were ...

By Daniel, Category: blog

Continue reading …

Extra time in Hanoi

2010-06-01 23:06:00-0700

Since we had bought our tickets for June 2nd, June 1st was an open day to do anything. We spent the morning being lazy but eventually made it out to enjoy the city. 32::AM::143We found no shortage of camera shops, which was great because a lot of them had vintage ...

By Daniel, Category: blog

Continue reading …

Returning from Cat Ba Island

2010-05-31 23:05:00-0700

After the previous days excursions, May 31 was a somewhat sore day. I actually wasn't as sore as I was expecting though, which was nice. Tien and I were thinking about finding more things to do on Cat Ba Island, but instead we decided to head home. We chose ...

By Daniel, Category: 365-32

Continue reading …

Geocaching on Cat Ba Island

2010-05-30 23:05:00-0700

May 30th was another rainy morning on Cat Ba Island. My hair was getting longer than I liked so I decided to shave my head, but when I went to use my electric razor the battery was practically dead. To top it off, I soon found out I had killed ...

By Daniel, Category: blog

Continue reading …

A Trip to Cat Ba Island

2010-05-29 23:05:00-0700

On the morning of May 28th our alarm failed to go off, or at least we didn't hear it, but I somehow managed to wake up about 15 minutes before our bus arrived. We hurriedly packed and got downstairs with just a few minutes to spare. Tien tried to ...

By Daniel, Category: 365-32

Continue reading …

Tien's first day in Hanoi

2010-05-27 23:05:00-0700

On the morning of May 27 we woke up, rented a motorbike and immediately got lost in old town Hanoi. We got really lost too, and didn't find our way back to the lake for about an hour or two. When we finally did we stopped for breakfast. I ...

By Daniel, Category: 365-32

Continue reading …

Consular BS, Interview Date, Traveling to Hanoi

2010-05-26 23:05:00-0700

On May 24th Tien and I woke up with a plan to head to Saigon. We booked a bus for 3pm and spent the morning playing more Wii and PvZ. We played PvZ all the way until the bus to Saigon was right outside Thu's house honking its horn ...

By Daniel, Category: 365-32

Continue reading …

A family gathering, video games

2010-05-23 23:05:00-0700

On May 22, Tien's uncle rented a bus and a bunch of us drove over to where Tien's cousin has just built a house. Many members of Tien's family were gathering to remember the anniversary of the death of Tien's grandmother. We grabbed breakfast in LX ...

By Daniel, Category: blog

Continue reading …

Adventures on Phu Quoc and the trip home

2010-05-21 23:05:00-0700

On May 20 Tien and I woke up on the island of Phu Quoc, went downstairs for breakfast and then took the moto out to have a look around the town. We bought a proper swimsuit for her, some sunscreen, and tried to find me a helmet, which is a ...

By Daniel, Category: 365-32

Continue reading …

Heading to Phu Quoc

2010-05-19 23:05:00-0700

The morning of May 18 we woke up with no power and again made plans again to go to Ha Tien beach. We went to LX to have lunch and surf the net and check out the bus station schedule.

We passed a white man with a white trimmed beard ...

By Daniel, Category: blog

Continue reading …

Lazing around Binh Hoa

2010-05-17 23:05:00-0700

On May 14 Tien and I went to the market for breakfast. Her family had moved their shop one door down to the entryway where the food stalls are. Hanging in their shop was a shirt that said "Chicago holiday in member recruitment we require oral interview."

We had a ...

By Daniel, Category: blog

Continue reading …

Hanging in Saigon, choosing Binh Hoa over Nha Trang

2010-05-13 23:05:00-0700

On May 12 Tien and I got an early breakfast and decided to walk down to the river. It looked nicer on the map than it actually was, due to construction and heavy traffic, but it was nice all the same. We ran into an Australian couple and asked them ...

By Daniel, Category: blog

Continue reading …

From Taipei to Saigon, and more importantly, to Tien

2010-05-11 23:05:00-0700

On the flight to Saigon I sat next to a nice Vietnamese man from Canada who was going home to visit family. We didn't talk a whole lot, but he did mention that Saigon is different every time he goes back, always expanding and always building. He'd grown ...

By Daniel, Category: 365-32

Continue reading …

Back to Vietnam in 2010

2010-05-10 23:05:00-0700

Friday, May 7th was my last day working my contract at GWOS. I had thought my contract ended a week earlier, and had bought a plane ticket for that timeframe. That detail was an oversight on my part, and it cost me nearly the price of a plane ticket just ...

By Daniel, Category: 365-32

Continue reading …

Preparing for my third Asia trip

2010-05-04 22:05:00-0700

Time spent on San Francisco trainsRight now I'm on the L-Taraval on my way to the sunset. Rob is in new York looking for a place to live and I'm crashing at his place while he's gone.

I just finished a crazy, long day at work with network config, server upgrades, Linux ...

By Daniel, Category: blog

Continue reading …

Catching up from Vietnam to Telegraph Hill

2010-04-17 19:04:00-0700

The View from The RoofMuch has happened since last time I wrote. I'm currently living at 425 Green Street on Telegraph Hill, but will be returning to Vietnam to be with Tien in two weeks. Before I get into the present and future, I should probably dive into what's been going on ...

By Daniel, Category: 365-32

Continue reading …

New Focus

2010-02-01 19:02:00-0800

It's a month into 2010 and my focus in life is moving away from the dazzle of travel back to the grind. Along with it, I'm moving the focus of this blog away from travel and into what I had originally planned for it, primarily photography and its ...

By Daniel, Category: blog

Continue reading …

My last day in Binh Hoa

2010-01-08 00:01:00-0800

On Nov 22nd we woke up in the familiar Ruby Star, pretty much a third home by this time. My stomach was a little bit upset, probably from the meds, but it was better than the alternative.

The last time we were in town I had seen a building I ...

By Daniel, Category: blog

Continue reading …

Leaving Vietnam in 2009

2009-11-24 23:11:00-0800

Nov 24th was my last day in Vietnam in 2009. My stomach was a little upset, probably from some meds I was still taking for my lingering strep throat, which echoed from my last trip home to the USA.

Tien's sisters had prepared some gifts for my family and ...

By Daniel, Category: blog

Continue reading …

Strep Throat in Nha Trang, Back to Saigon by Train

2009-11-21 23:11:00-0800

Friday, Nov 20th, I woke early to a very rainy and stormy morning. Having less than a week left I decided to go ahead and figure out my plan for when I arrived back in America. Some of my friends were online since it was evening in the USA, and ...

By Daniel, Category: blog

Continue reading …