skip to main content

Floating Point Dcraw + DCB, AMaZE, LMMSE, AFD, & VCD
Part 4: dcraw-float license, limitations, source code

In addition to the dcraw-float license, on this page are links to some awesome digital imaging resources, maintained by equally awesome people.

Written in 2011. Minor update in March 2015.

What dcraw-float is

dcraw-float is a floating point version of dcraw, with several other interpolation routines (DCB, AMaZE, LMMSE, AFD, & VCD) added in, and with AHD removed (my AHD code causes a segmentation fault that I have failed to track down and fix).

dcraw-float is very much a personal project, coded up to suit my own idiosyncratic workflow. dcraw-float is also a work in progress. Some of the interpolation algorithms have options to which I haven't yet provided access. There are quite a few other algorithms out there, including some great noise removal and chromatic aberration correction algorithms, that I haven't added in yet. And there are some default dcraw options that I removed in the interest of making the source code easier to modify. Depending on your own workflow, you might find dcraw-float sadly lacking in functionality.

Some of the default dcraw options that I removed (such as black frame subtraction, wavelet denoising, and the ability to use the "flip" switch), I plan to add back in. As I make changes to dcraw-float, I'll try to post the newer versions.

dcraw-float code is a modified version of the default dcraw source code. The dcraw-float source code (and also an integer version of dcraw that includes DCB and LMMSE interpolation) can be downloaded at the bottom of this page.

Most of the additional interpolation and noise removal algorithms are modified versions of the LibRaw 0.13.4 source code for the various algorithms.

I tracked down source code for some of the algorithms as supplied by the Perfect Raw project (alas no longer active), Raw Therapee (very much alive and producing wonderful stuff, but using c++ rather than c), and Manuel Llo­rens' Rawness (a must-see website for anyone interested in dcraw, with some very interesting c code), and also Paul Lee's VCD algorithm. But the LibRaw source code usually proved to be the easiest code for me to modify and incorporate into dcraw-float.

As a very important aside, I've always had huge amounts of admiration for open source software and for the people who work so hard to make open source software better. The time and angst it has taken for me to put together this tiny little bit of source code — that I'm reasonably comfortable actually works (it works for me), with hopefully a minimal number of egregiously stupid mistakes — has raised my admiration, respect, and gratitude to the open source community, to a whole new level.

What dcraw-float is not

dcraw-float is not a "project" with any commitments to support all the cameras that dcraw supports. My modified code will not work with Foveon or Fuji cameras or with the Canon 600 Point and Shoot camera. It will probably work with most Nikon and Canon dSLRs, but I've only actually tested dcraw-float on a mere handful of different model Nikon and Canon raw files. I don't know about other cameras.

Given my own workflow, I feel no personal need to add back in all of the processing options that dcraw provides. Default dcraw options that have been removed or modified include:

  1. dcraw-float is hard-coded to use the equivalent of the default dcraw command line option '-o 0' (raw color output). Therefore the user must supply a custom camera profile.

    The UFRaw website has information about and links to several Nikon and Canon camera profiles.

  2. The only white balance method that works is using '-r red green1 blue green2' to specify white balance multipliers at the command line.

    Eliminating other white balance methods, along with only using raw color output, eliminates a whole lot of convoluted dcraw c code.

  3. Although dcraw-float allows the user to specify a true power gamma for image output, it does not allow specification of a "toe-slope".

    That is, dcraw-float is hard-coded such that the default dcraw gamma toe-slope is always 0. dcraw-float applies the gamma curve at the very end of the raw file processing, just before converting the image array back to integer and writing it to disk. What you get in place of the ability to specify a toe-slope, is a choice between using a gamma-lookup-table or having the gamma applied using the much slower but more accurate full floating point math.

  4. Although you can specify whether to produce clipped or unclipped output (-H 0 and -H 1, respectively), the options to blend or rebuild highlights have been removed.

Why did I remove so many dcraw processing options? I'm not an experienced c code programmer. The first thing I did when I decided to make a floating point version of dcraw was to eliminate as many lines of code from the default dcraw c code as possible. Default dcraw code has over 9,000 lines of code, most of which is for identifying and decoding cameras I don't own and/or for processing options I never use. The reduced dcraw code that I actually worked with — supporting only one camera and only the bare minimum of processing options — only had around 1,200 lines of code: much easier to work with. (For what it's worth, the dcraw-float code that you can download from this page has well over 10,00 lines of code, even with a lot of the regular dcraw code removed).

Pulling the modified code back over to a more fully functional floating point dcraw, supporting more than just one camera, was actually pretty easy to do (much easier than writing up these web pages!). But any dcraw option that required more coding to be made floating point, got removed. (In most cases, I left the actual functions in place as "placeholders" and simply removed the code inside the functions and/or commented out lines of code referring to removed command-line functions or to empty placeholder functions; the restricted Foveon code was completely removed, placeholders and all).


  1. dcraw-float is a floating point version of dcraw 9.07 (2011/04/01). dcraw-dcb-integer is basically dcraw 9.07 with the DCB and LMMSE, both from the LibRaw Project, added in. All of Dave Coffin's licensing restrictions (included in the dcraw-float source code), and also the LibRaw licensing restrictions and the licensing restrictions specified by the original authors of the various algorithms, all still apply.
  2. I've included substantial portions of code from the LibRaw project, version 0.13.4, much of which in turn came from yet other projects. All of the pre-existing licensing restrictions on the various interpolation and denoising algorithms that I've incorporated into dcraw-float and dcraw-dcb-integer still apply (these other licensing restrictions are included in the dcraw-float and dcraw-dcb-integer source code, along with the actual algorithms).
  3. To the extent compatible with all of the pre-existing licensing restrictions, AND ONLY TO THAT EXTENT, my own code, code modifications and code comments are copyright 2011 by Elle Stone, and released under the GNU GPL Version 2 or later as free software. See version 2 and version 3 of the GNU General Public License for more details.
  4. The dcraw-float and dcraw-dcb-integer source code is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.

My intent in paragraphs (1), (2), and (3) above is to underscore the existence of and continued application of all the pre-existing copyrights that apply to the various code sections in dcraw-float and dcraw-dcb-integer. If anyone more familiar with how to properly license modifications of existing open source code wants to improve upon how I've tried to acknowledge and include all the pre-existing applicable licensing restrictions, please contact me.

Download the source code

Caution: Use the dcraw-float and the dcraw-dcb-integer source code at your own risk! I make no guarantees. Both programs work really well on my 64-bit computer running Ubuntu Maverick (and dcraw-float is now my raw-rendering program of choice). Valgrind finds no errors in either compiled executable. Your mileage may vary.

Compile the source code

My apologies to people who don't know how to compile source code or don't run Linux. I know it's frustrating to want to try something and not have the wherewithal to do so (that's precisely why I wrote dcraw-float, so I could try floating point processing). But I don't have the knowledge or the wherewithal to compile software for use on operating systems or hardware other than my own.

Once you've installed all the requisite compilation software on your computer (starting with gcc if you run Linux, but honestly I don't know what else you might need), compiling dcraw (and dcraw-float) is very easy. Here's the command line for compiling the dcraw-float source code under Linux:

gcc -o dcraw-float -O4 dcraw-float.c -lm -ljpeg

If you've downloaded a more recent copy of the dcraw source code than what was available in 2011, the revised command line for compiling is on the dcraw website.

The "-ljpeg" part is necessary for at least some Kodak cameras (and the code won't compile without it, unless you further modify the code), but I don't know if dcraw-float actually works with these cameras. The usual command line for compiling dcraw adds "-llcms", but as dcraw-float isn't doing any color conversion, the "-llcms" can be left off.

To compile dcraw-dcb-integer, add "-llcms" to the above command, and change the input and output file names.

If you've never compiled anything from source, just to let you know, the first time I compiled dcraw from source I was astonished at the long list of warnings that got printed to screen. Turns out those warnings are normal and mostly harmless. You usually only have to worry if you get an actual error message.

Run the compiled executable

You can run the compiled "dcraw-float" by typing at the command line:

./dcraw-float options file

See Part 2: How to use dcraw-float for details. dcraw-dcb-integer runs just like regular dcraw, except with additional interpolation options.