I'm using "-4 -D -T" to transform a 14 bit raw image (.nef) to a linear unprocessed tiff image. Is it the correct command? Does the command differ for 12 bit or 16 bit image?

  • It seems that it doesn't matter, you get 4 times bigger pixel values (which is sensible: 2^14 / 2^12 = 4). – faf Mar 24 '16 at 17:41
  • guillermoluijk.com/tutorial/dcraw/index_en.htm The above link shows that -D is for 12, 14 and 16 bits. -4 produces a 16 bit tiff. – faf Mar 24 '16 at 17:50

I have written a bad answer and deleted it, here is another attempt.

-4 -D -T preserves RAW numbers and writes them to 16 bit file while using only one fourth of values for 14 bit images and only one sixteenth of values for 12 bit images. You will never see white if you use -D, only gray.

It is intended to be used this way, it is not incorrect for any bit depth.

BUT: if you want DcRaw to use all available bit depth in output file, you may try replacing -4 -D -T with -d -T -6 -W -g 1 1 -r 4 4 4 4 for 14 bit input or with -d -T -6 -W -g 1 1 -r 16 16 16 16 for 12 bit input.

This gives normal brightness (if you use gamma 1 profile), I tried it.

ADDED: there are two things which should be dealt with: black level and NEF lossy compression (if it is selected). If you use -D, you will at least cancel black level and possibly gamma-correction too. If you use -d, you may exprect better results.

More about this in this paper.

| improve this answer | |
  • Thanks for the answer. I just need to get a linear pixel value proportional to the number of incident photons. – faf Mar 24 '16 at 17:53
  • 1
    @faf: then you are fine with -D. – Euri Pinhollow Mar 24 '16 at 17:55

I use

dcraw -o 0 -D -T -4

This preserves the 12- or 14-bit integer pixel values exactly as they were recorded in the raw file, without any processing or rescaling. (Thanks to Patrick Hurley)

I saw it in your other questions that ultimately you import the data to Mathematica. In Mathematica you can import a raw file directly as

Import["something.nef", "RawData"]

Here's the documentation page: http://reference.wolfram.com/language/ref/format/Raw.html The feature requires Mathematica 10.1 or later.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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