skip to main content

dcraw UnDnged: Modify dcraw to Use Your Own Custom Camera Profile, except the actual code has been moved to a separate, non-indexed page to accommodate a bit of Google insanity

With dcraw-unDnged you use your custom camera input profile instead of an Adobe-Dng-derived input profile. You can also change dcraw's list of available output/working spaces, and change the default dcraw command line options to better suit your workflow.

While coding up dcraw-unDnged I learned a lot about c-code, raw processing, and color management. I also learned that dcraw's color management code is a wee bit convoluted.—Elle Stone, "ye auld programmer wannabe"

Written February 2010. Updated March 2012.

Why I wrote dcraw-unDnged:

I will confess that I started writing dcraw-unDnged because of a total misunderstanding on my part: I thought it might result in smoother colors if dcraw applied my custom camera profile before outputting the processed image.

But all "applying a camera input profile" does is embed the profile in the image's metadata. So dcraw-Undnged saves the hassle of outputting raw color and then using some other program to apply the camera input profile. And dcraw-Undnged can also convert your processed raw file to the output/working color space of your choice, which saves another step in the digital darkroom workflow. But it doesn't make smoother colors.

Well, we live, we learn. And I learned a whole lot about c-code, raw processing, and color management while coding up dcraw-unDnged.

I also learned that dcraw's internal color management code is a wee bit convoluted. In fact, the main reason for keeping this article up on my website is because of the notes on dcraw's "color management convolutions". The code notes below show how I partially removed the convolutions, got rid of the D65 color spaces, and replaced the peculiar sRGB matrix at the top of the dcraw code with a D50 identity matrix.

It should be noted that the D65 sRGB matrix at the top of the dcraw c-code made perfect c-coding sense in 1997, when Dave Coffin released the first version of dcraw as his wonderful and enduring contribution to the "intellectual gift-culture". And it still makes sense today if you output your processed raw file to the sRGB working space. The convolutions are for accomodating working spaces other than sRGB.

With dcraw-unDnged you can:

  1. "un-Dng" dcraw, that is, replace the Dng-derived camera coefficients for your camera with camera coefficients derived from your own custom camera matrix input profile.
  2. Increase the precision of the camera matrix primaries by changing the data type from integer to floating. I doubt the increased precision is visually apparent, but why not — it was an easy change.
  3. Replace the D50 sRGB matrix at the top of the code with a D50 identity matrix.
  4. Replace all code using the D65 reference illuminant with code using the D50 reference illuminant. Unlike most working spaces in use today, all dcraw output spaces use D65 as the PCS reference illuminant.
  5. Change the list of built-in matrix output/working spaces to whatever you want them to be.
  6. Change some of the default command-line options to reflect the options you use of the time. For instance, I almost always output image files as 16-bit linear gamma tiffs. I've never output an 8-bit jpegs with sRGB-like gamma, which is the default dcraw default output. You can modify these same default command-line options to match what you use most of the time.

Detailed instructions for creating your own dcraw-Undnged A word about Google, or why the rest of this page has been moved to a non-indexed part of my website

Google is the tail that wags the dog, the "dog" being the internet, of course.

When Google first made its appearance as a boolean search engine, I loved it. Over time, Google has monetized itself. No surprise — if it's free, you are the product.

Google used to serve up user search histories as a product to be sold to advertisers for money. This was expected and more or less acceptable, at least to me.

Today Google is intent on training its users to be "better products", siloing user information and search results for the benefit of paying advertisers, with no regard for user privacy. I don't want to be trained to be a better product and I do value privacy, so I opted out and closed all my Google accounts.

Before closing my accounts I used Webmaster Tools to check on what Google had to say about my Nine Degrees Below website. To my horror, I found that Google thought my website was about "col" and "row", which are two dcraw c code variables. Apparently Google counts the number of times unique words appear on a website (so much for Google's purportedly intelligent algorithms that figure out what a website is really about) and I had allowed Google to index some pages that included dcraw's c code.

I can't figure out any way to convince Google that my website is about color management rather than about "col" and "row", other than removing the dcraw c code to pages that aren't indexed. So I did. The remainder of this article has been moved to dcraw UnDnged: Modify dcraw to Use Your Own Custom Camera Profile, with the actual code.