What is the simplest way to access the data in a raw file before demosaicing and write it to a more widely supported file format (e.g. 16 bit TIFF)? I'm looking to obtain a single channel image where each pixel corresponds to a single pixel on the sensor (regardless of what colour filter it had in front).

The not so simple way would be digging into some open source RAW processing libraries and using code from there. Is there a simpler way (e.g. a command line tool)?

  • \$\begingroup\$ Solutions requiring MATLAB/Mathematica are also useful. I tried these on NEF, which is supposed to be TIFF based, but didn't manage to extract anything else than the preview. \$\endgroup\$
    – Szabolcs
    Jul 30, 2013 at 20:39

2 Answers 2


dcraw is what you want. Probably using -o 0 which will provide raw color data and possibly -D for an unscaled grayscale image. libraw is extracted from this code and will provide lower level access to a raw file, but will need more coding.

  • \$\begingroup\$ Thanks, it's precisely what I wanted. It's part of MacPorts so it was easy to install. I used -o 0 -D -T -6 which outputs 16-bit TIFF. \$\endgroup\$
    – Szabolcs
    Jul 30, 2013 at 20:59
  • \$\begingroup\$ I was playing with detecting cosmic rays and I wanted to get access to the original data, without any (in this case) meaningless colour information or smoothing. \$\endgroup\$
    – Szabolcs
    Jul 30, 2013 at 21:11
  • \$\begingroup\$ Glad I could help, I have written a few attempts at image processing "for fun", but Adobe is almost always better at it :-) \$\endgroup\$ Jul 30, 2013 at 23:57
  • 1
    \$\begingroup\$ I don't think -o 0 does what is implied here. That defines the output color space to be the native primaries of that camera, rather than sRGB or something else. It doesn't mean no interpolation. \$\endgroup\$
    – mattdm
    Aug 10, 2015 at 1:51

You may consider trying RawDigger, it allows to export TIFFs in 16 bits without any scaling and in linear gamma if you wish. It also calculates statistics if you need it.

  • 1
    \$\begingroup\$ It's not free any more though, unfortunately, but it was a nice program when I tried it. It didn't seem to do anything more than dcraw though, other than adding a GUI. Are you one of the devs? If yes, you should make that clear in this post. \$\endgroup\$
    – Szabolcs
    Jun 1, 2014 at 21:33
  • \$\begingroup\$ Yes, I'm one of the developers, sorry if it was not clear. But I signed my post with my full name. The program does much more than dcraw, it is more accurate (for example, when it comes to black level calculations), and it allows grids, histograms, and statistics. It is easier to control, too. Quite often 30-day free trial is enough for a study of any particular sensor issue, or to verify a method. \$\endgroup\$
    – Iliah Borg
    Jun 2, 2014 at 17:43
  • 3
    \$\begingroup\$ I was just warning you: it's standard practice on SE to note if you're the developer, especially if it's not a free program. Otherwise someone might flag it as spam. (I won't do that, but since you're new here I thought it's fair to mention it.) \$\endgroup\$
    – Szabolcs
    Jun 2, 2014 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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