Time to be with your loved ones

Time to be with loved ones

by sat

submit your photo


Hall of Fame
View past winners from this year

Please participate in Meta
and help us grow.

Take the 2-minute tour ×
Photography Stack Exchange is a question and answer site for professional, enthusiast and amateur photographers. It's 100% free, no registration required.

What is the best way to convert on the command line a Canon raw file (CR2) into 2 or 3 differently exposed tiffs for HDR/tonmapping?

I would like to use Apple's sips, but couldn't find anything to set an exposure parameter. So now I am interested in a solution to get differently exposed tiffs from a raw file via the command line raw converter dcraw.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

If you are interested in this, I would suggest getting 'dcraw' which is a command line RAW converter. There is a Mac version for download from the site, the source code, and if you have HomeBrew installed, you can install it via 'brew install dcraw'.

The 'dcraw' program allows you to specify a variety of options including the Gamma and Exposure level settings to apply to the output file.

I've used it for this purpose before, to "convince" the HDR merge programs to make use of the information. Note it will probably take some messing around.

http://www.cybercom.net/~dcoffin/dcraw/

I use the '-b' option:

rawfile=<your raw file name>
for b in 0.25 0.50 1.00 2.00 4.00 8.00
do
   dcraw  -T -4 -v -w -W -b ${b} $rawfile
   mv ${rawfile}.tiff ${rawfile}-b${b}.tiff
done

This will create a series of TIFF images with varying levels of brightness as well as being 16bit linear Tiffs. (Gamma=1)

You can then merge these images in an HDR program to take advantage of the lightened shadows and darkened highlights.

dcraw also has a highlight recovery option:

-H [0-9]  Highlight mode (0=clip, 1=unclip, 2=blend, 3+=rebuild)

which can be applied to the raw processing.

To "assist" the HDR merge program(s), you will then also need to adjust the exposure settings in the EXIF meta embedded in the TIFF files generated. The easiest would be to change the ISO value.

So, for where b=1.0, which is the normal:

exiftool -ISO <filename where b=1.0>

This should tell you the ISO value.

For the other images, you will want to change the ISO value to reflect an effective EV change:

b8.00 = ISO * 8
b4.00 = ISO * 4
b2.00 = ISO * 2
b0.50 = ISO/2
b0.25 = ISO/4

(Someone correct me if I'm wrong on the EV/ISO values).

So let's say the ISO was 100 for b1.0:

exiftool -ISO=25 <filename where b=0.25>
exiftool -ISO=50 <filename where b=0.50>
exiftool -ISO=200 <filename where b=2.0>
exiftool -ISO=400 <filename where b=4.0>
exiftool -ISO=800 <filename where b=8.0>

This way, the images will be recognized as being part of different exposure ranges.

Note, the brightness doesn't translate directly into EV steps, but this will allow the merge program to put the images in the general ballpark of where the images would be given the change in effective brightness.

share|improve this answer
    
What command line option(s) do you use to adjust the exposure with dcraw? –  coneslayer May 22 '13 at 1:51
    
Yep, I agree dcraw is the way to go. But How? How do I get tiffs with, say, +-0EV, +1EV and -1EV? –  halloleo May 22 '13 at 8:25
    
More about dcraw: In the dcraw man page I cannot find an EV option. Do I have to use the -b option? But how does it translate into EV steps? –  halloleo May 22 '13 at 8:36
1  
Updated answer with -b options as well as exiftool examples to modify the exif data so that an HDR merge program will put the images in the correct relative brightness ranges. –  Wing Tang Wong May 22 '13 at 19:30
1  
That's exactly what I wanted to know! I'll try it out. Thanks a lot! –  halloleo May 23 '13 at 14:34
add comment

I think (I'm not sure though) there is no built-in command line tools for such task. Instead, you can use third party softwares. Allow me to introduce you to very nice ImageMagick.

It is a set of cross-platform command-line tools that allow you to do a lot. It has lots of tools and also many scripts based on it are available online. They have also a forum that can help you with what you wanna achieve.

share|improve this answer
    
Be sure you have a look at their tutorials. ImageMagick has one drawback IMHO and that is being a little complected for a simple task like exposure compensation. –  Pouya May 21 '13 at 17:48
    
Under the hood ImageMagick does use dcraw for conversion from raw to tiff. However I don't know whether Imaggick's exposure compensation options of the convert command grab the hidden details of the raw file for specifically developed tiff. I guess using dcraw directly is more promising, but I don't how to get different exposures out of dcraw. –  halloleo May 21 '13 at 21:43
    
@halloleo Gimp also comes with set of command line tools (at least on linux. I'm not sure about mac). You may or may not find something that satisfy your needs. I'm not familiar with gimp scripts so much. You can give it a try or at least do some research on that. –  Pouya May 21 '13 at 22:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.