Back to Camera Hacker

dcraw by example

dcraw is a digital camera raw conversion software written by Dave Coffin. The software has the capability of converting raw image files from 202 cameras as of this writing. For some cameras, this is the only piece of software that can read and convert the camera's raw format. Because it is distributed in C language source code, it can be compiled and executed on any operating system (DOS, Linux Mac OS, OS/2, Windows, etc). Dave Coffin has been very generous at placing "no restrictions on this code". The software is also executed on the command-line so that it is very flexible and powerful.

The only thing it really lacks is a good user manual. Because it is a free software, written by an individual, and used by many power users, the learning process has been an ad hoc trial-and-error, I-know-what-I-am-doing approach. There are no instruction on how to use it and what kind of result you would produce with this software.

Recently, I have been shooting raw images with my Nikon Coolpix 950, one of those cameras that don't have raw conversion support from the manufacturer. So I have been processing the raw files with dcraw. However, with numerous command-line options, there could be endless results generated by the dcraw software. Without a good visual example of each option, and no manual to reference to, I have a hard time keeping track of what options I should be using.

And that sparked my decision to write this user manual for dcraw. I call it the "dcraw by example" user manual, because I am going to document the software with photographs of the result, so that you can see exactly what you'd get with the different command-line options. Each option is divided up into its own section with its own description and pictorial example. At the end of each section, I also show the detailed output message from dcraw for that specific option, because sometime the output contains interesting processing details. If the details look overwhelming to you, skip it.

Comments & Discussion >>

Usage

Before we get started with descriptions and example of each option, here is the dcraw usage page, which lists all of the options. You can generate this page by typing "dcraw" on the command-line and hit enter without any arguments. However, I present it here for reference.

Raw Photo Decoder "dcraw" v8.03
by Dave Coffin, dcoffin a cybercom o net

Usage:  dcraw [options] file1 file2 ...

Valid options:
-v        Print verbose messages
-c        Write image data to standard output
-e        Extract embedded thumbnail image
-i        Identify files without decoding them
-z        Change file dates to camera timestamp
-a        Use automatic white balance
-w        Use camera white balance, if possible
-r   Set red  multiplier (default = 1.0)
-l   Set blue multiplier (default = 1.0)
-b   Set brightness      (default = 1.0)
-k   Set black point
-n        Don't clip colors
-o [0-4]  Output colorspace (raw,sRGB,Adobe,Wide,XYZ)
-d        Document Mode (no color, no interpolation)
-q [0-3]  Set the interpolation quality
-h        Half-size color image (twice as fast as "-q 0")
-f        Interpolate RGGB as four colors
-B    Apply bilateral filter to reduce noise
-j        Show Fuji Super CCD images tilted 45 degrees
-s        Use secondary pixels (Fuji Super CCD SR only)
-t [0-7]  Flip image (0 = none, 3 = 180, 5 = 90CCW, 6 = 90CW)
-2        Write 8-bit non-linear PPM (default)
-4        Write 16-bit linear PPM
-3        Write 16-bit linear PSD (Adobe Photoshop)

Comments & Discussion >>

-v Print verbose messages

When dcraw is running and processing raw images normally, it produces no output. The only time it produces output is when it encounters warnings and errors. By using the -v option, dcraw will output messages to update you on its progress along the way. Below is an example of messages it output while processing an image.

[chieh@porta raw]$ dcraw -v dscn0040.jpg
Reading metadata from dscn0041.jpg...
Loading NIKON E950 image from dscn0040.jpg...
Scaling with black=0, pre_mul[] = 75.643517 64.000000 74.529282 75.040001
Bilinear interpolation...
VNG interpolation...
Converting to sRGB colorspace...
Writing data to dscn0040.ppm...

This -v option could be combined with other options for various verbose messages. Those will be covered later in each section.

Comments & Discussion >>

-i Identify files without decoding them

The -i option helps identify a raw image file. In the example below, the -i option helped identify that "dscn0040.jpg" is a raw image produced by my Nikon Coolpix 950 digital camera. Although this image has a ".jpg" extension, it is actually a raw file. If you tried to use the -i option on an actual JPEG image, dcraw will report the "Cannot decode dscn0041.jpg" error message.

[chieh@porta raw]$ dcraw -i dscn0040.jpg
dscn0040.jpg is a NIKON E950 image.

The -i option can be combined with -v (verbose) option to output EXIF and other meta data contained in the image. The following is an example output:

[chieh@porta raw]$ dcraw -i -v dscn0040.jpg
Reading metadata from dscn0041.jpg...

Filename: dscn0040.jpg
Timestamp: Sat Jan 22 18:03:40 2005
Camera: NIKON E950
ISO speed: 188
Shutter: 1/3.0 sec
Aperture: f/3.0
Focal Length: 11 mm
Embedded ICC profile: no
Decodable with dcraw: yes
Full size:   2048 x 1203
Image size:  1616 x 1203
Output size: 1616 x 1203
Raw colors: 4
Filter pattern: YCGMYCGMYCGMYCGM
Daylight multipliers: 1.181930 1.000000 1.164520 1.172500

Comments & Discussion >>

-a Use automatic white balance

dcraw by default does not perform automatic white balance (AWB) on the images that it processes. It simply processes the raw image data as seen by the sensor. If you evoke the -a option, it will use its own AWB algorithm to process your images. The following is an example of the default process (left) vs. the AWB process (right).

[chieh@porta raw]$ dcraw -a -v dscn0040.jpg
Reading metadata from dscn0041.jpg...
Loading NIKON E950 image from dscn0040.jpg...
Scaling with black=0, pre_mul[] = 140.887909 64.000000 197.005325 69.470352
Bilinear interpolation...
VNG interpolation...
Converting to sRGB colorspace...
Writing data to dscn0040.ppm...

Comments & Discussion >>

-w Use camera white balance, if possible

This option does not work with the Nikon Coolpix 950 image; dcraw reports "dscn0040.jpg: Cannot use camera white balance." Instead, I will illustrate this option with an image from my Canon EOS D30 digital SLR camera.

The -w option tells dcraw to use the color balance specified by the camera. In the case of this image, the camera was set to AWB. The picture on the left was processed with no options. The picture on the right was processed with the -w option.

[chieh@porta raw]$ dcraw -v crw_0838.crw
Loading Canon EOS D30 image from crw_0838.crw...
Scaling with black=128, pre_mul[] = 33.492565 16.000000 16.895607 16.000000
AHD interpolation...
Converting to sRGB colorspace...
Writing data to crw_0838.ppm...
[chieh@porta raw]$ dcraw -w -v crw_0838.crw
Loading Canon EOS D30 image from crw_0838.crw...
Scaling with black=128, pre_mul[] = 16.000000 40.090477 194.933075 39.405720
AHD interpolation...
Converting to sRGB colorspace...
Writing data to crw_0838.ppm...

Comments & Discussion >>

-o [0-4] Output colorspace (raw,sRGB,Adobe,Wide,XYZ)

The -o option tells dcraw to output the processed raw image in different color space. If you don't specify this option, dcraw defaults to outputting the data into the sRGB color space.

-o 0 raw

The -o 0 option tells dcraw not to convert the raw data into any color space. It also outputs the image file with the ".pam" extension. I do not know how to load this file, so I can't show you an example. If you know how to display this file, please let me know.

[chieh@porta raw]$ dcraw -o 0 -v dscn0040.jpg
Reading metadata from dscn0041.jpg...
Loading NIKON E950 image from dscn0040.jpg...
Scaling with black=0, pre_mul[] = 75.643517 64.000000 74.529282 75.040001
Bilinear interpolation...
VNG interpolation...
Building histograms...
Writing data to dscn0040.pam...

Comments & Discussion >>

-o 1 sRGB

The -o 1 option tells dcraw to convert the raw data into the sRGB color space. This is also the default mode of operation, so you don't need to specify this flag.

In the future, the default mode could change. So if you are writing a batch conversion script, and you know you always want your image to be in sRGB color space, then you need to explicitly specify this flag.

Comments & Discussion >>

-o 2 Adobe 1998 RGB

The -o 2 option tells dcraw to convert the raw image into the Adobe 1998 RGB color space. The image on the left is an example of the sRGB color space. The image on the right is an example of the Adobe 1998 RGB color space.

[chieh@porta raw]$ dcraw -o 2 -v dscn0040.jpg
Reading metadata from dscn0041.jpg...
Loading NIKON E950 image from dscn0040.jpg...
Scaling with black=0, pre_mul[] = 75.643517 64.000000 74.529282 75.040001
Bilinear interpolation...
VNG interpolation...
Converting to Adobe 1998 RGB colorspace...
Writing data to dscn0040.ppm...

Comments & Discussion >>

-o 3 Wide Gamut D65

The -o 3 option tells dcraw to convert the raw image into the Wide Gamut D65 color space. The image on the left is an example of the sRGB color space. The image on the right is an example of the Wide Gamut D65 color space.

[chieh@porta raw]$ dcraw -o 3 -v dscn0040.jpg
Reading metadata from dscn0041.jpg...
Loading NIKON E950 image from dscn0040.jpg...
Scaling with black=0, pre_mul[] = 75.643517 64.000000 74.529282 75.040001
Bilinear interpolation...
VNG interpolation...
Converting to Wide Gamut D65 colorspace...
Writing data to dscn0040.ppm...

Comments & Discussion >>

-o 4 XYZ

The -o 4 option tells dcraw to convert the raw image into the XYZ color space. The image on the left is an example of the sRGB color space. The image on the right is an example of the XYZ color space.

[chieh@porta raw]$ dcraw -o 4 -v dscn0040.jpg
Reading metadata from dscn0041.jpg...
Loading NIKON E950 image from dscn0040.jpg...
Scaling with black=0, pre_mul[] = 75.643517 64.000000 74.529282 75.040001
Bilinear interpolation...
VNG interpolation...
Converting to XYZ colorspace...
Writing data to dscn0040.ppm...

Comments & Discussion >>

-d Document Mode (no color, no interpolation)

The -d option tells dcraw to output the image from raw data without interpolating color. The output is a gray scale image. This form of processing is faster because the process bypasses the bilinear interpolation and the VNG interpolation that are done in a normal color process. dcraw also produces a file with the ".pgm" extension, rather than the normal ".ppm" extension.

The picture on the left is a default sRGB output. The image on the right is the Document Mode output. The shrunken image on the right doesn't show the raw texture of the image, so the third image below shows a cropped version of the image at 1:1 ratio. Note the half-tone like texture.

[chieh@porta raw]$ dcraw -d -v dscn0040.jpg
Reading metadata from dscn0041.jpg...
Loading NIKON E950 image from dscn0040.jpg...
Scaling with black=0, pre_mul[] = 75.643517 64.000000 74.529282 75.040001
Converting to sRGB colorspace...
Writing data to dscn0040.pgm...

Comments & Discussion >>

Text

The Documentation Mode is supposed to work well with text. So to see how it would perform, I took a picture of the introduction page of "Making Reverse Macro Adapters" from my Hacking Digital Cameras book. I then process the exact same image with the -a (AWB) option and the -d (Document Mode) option. The results are shown in the pictures below.

The picture on the left is processed with the AWB option. The picture on the right is processed with the Document Mode option.

The picture on the left is an 1:1 ratio image of the text processed with the AWB option. The picture on the right is an 1:1 ratio image of the text processed with the Document Mode option.

Comments & Discussion >>

Related Links

Discussion

Articles
Hacks | Reviews | Tips
Tools | Help

Discussions
Forums | Latest | RSS

References
Library | Links | News
Search | Shop | Wiki

Hacking Digital Cameras
Fun for Photographers


Get Our

Memecoins!




Gifts By Price
$10000-above
$5000-$9999
$2000-$4999
$1000-$1999
$500-$999
$200-$499
$100-$199
$50-$99
$25-$49
$0-$24
Gift Certificate

Amazon Associate

Copyright © 2006 by Chieh Cheng. All Rights Reserved.