All D-SLRs and a lot of “Prosumer”-Compact cameras have a “RAW-Mode”. Unfortunately, the image files have a proprietary file format and the manufacturers would like the user to use their software in order to convert from RAW to an image file format like JPEG or TIFF. To get access to the data within the RAW-files, we use an open source software called dcraw by Dave Coffin.
Dave's mission: “Write and maintain an ANSI C program that decodes any raw image from any digital camera on any computer running any operating system.”
He does a great job on this, but as he only publishes source code in “C” (no executables) and without graphical user interface (command line only), we give some help here.
GET IT RUNNING
You can go to the dcraw website (https://www.dechifro.org/dcraw/dcraw.1.html) and download the source code. On a Mac, it is relatively easy to compile the dcraw.c file. In “Terminal.app”, just type:
gcc -o dcraw -O4 dcraw.c -lm -DNO_JPEG -DNO_LCMS -DNO_JASPER
(Snow Leopard and older)
llvm-gcc -o dcraw dcraw.c -lm -DNO_JPEG -DNO_LCMS -DNO_JASPER
HOW TO USE IT
If you run dcraw without any option, you will get a short description of the syntax and the most important parameters. If you like it more detailed, have a look here: https://www.dechifro.org/dcraw/dcraw.1.html
Here some samples and the resulting image:
If you do not use any option, the image will be processed with the default settings. The result is a .ppm file with 8bit data.
<dcraw> -q 3 -o 1 -6 -g 2.4 12.92 -w -T <ImageFileName>
WWith these options, you will get a more or less fully processed and optimized image. It will be demosaiced with the AHD algorithm (-q 3), the output color space is sRGB (-o 1), 16bit bitdepth (-6), sRGB tonal curve (-g 2.4 12.92). The image is whitebalanced using the camera data (-w) and all this will be stored in a TIFF file.
<dcraw> -q 3 -o 1 -W -6 -g 2.4 12.92 -w -T <ImageFileName>
The result is similar to the previous, but with the “-w” Option, the histogram of the image is ignored and no tonal correction is applied. This can be useful if the image does not contain any highlights or you want to measure on the image.
<dcraw> -q 3 -o 0 -W -6 -g 1 1 -w -T <ImageFileName>
With this options, the output image is linear (-g 1 1) in its response to the incoming light.
<dcraw> -q 3 -o 0 -6 -g 1 1 -w -T <ImageFileName>
The resulting image is linear and a tonal correction has been applied, based on the image histogram.
<dcraw> -D -W -6 -g 1 1 -T <ImageFileName>
The document-mode: The output is as close to the sensor output as possible. The image is still not demosaiced, and it has not been leveled. As we have a 16bit output and the sensor data is normally 12bit or 14bit, the image is very dark. This can be a good starting point to do your own image pipeline.
<dcraw> -D -6 -g 1 1 -T <ImageFileName>
The same as the previous, but the image has been leveled. It still has its Bayer pattern.