Saturday, May 19, 2012

DNG2NEF v3.0, more cameras supported, and a little fun with the M monochrom

DNG2NEF v3 adds support for more Leica cameras, in particular the M8,
M9 Monochrom and the S2.

Note: you need to have either Capture or View NX installed on the computer
where you plan to run DNG2NEF, otherwise the Nikon SDK libraries cannot 
be loaded.

Some notes, caveats and findings:

 

Leica M8

The M8 stores the raw in 8 bits per pixel, that need to be linearised
(expanded) to 14 bits to conform a valid NEF, so expect a size
increase when transforming your M8 files to NEF.

M8 sample files available at

 

Leica S2

Sample files are available at
No caveats with this model. I have not tested the latest camera firmware, should work fine.

 

M9 Monochrom

Sample files, thanks to Jonathan Slack, at
This is included only for fun and curious minds. Being the MM a
monochrome sensor, each pixel from this DNG files represents a grey
value, from black to white. The Bayer array of the color cameras, NEF
included, dedicate each pixel to read only Red, Green or Blue
values. For a better understanding, see the following diagram and
explanations, taken from the Leica website,



"With a full native resolution of 18 megapixels, the Leica M Monochrom
delivers 100% sharper images than with colour sensors. As its sensor
does not see colours, every pixel records true luminance values - as a
result, it delivers a true black-and-white image. The combination of
the brilliant imaging qualities of Leica M-Lenses and the image sensor
results in images with outstanding sharpness and natural brilliance. (sic)"


DNG2NEF does a raw copy of the binary sensor reading from the DNG to 
the NEF file. When doing this with a M9 Monochrom file, the result does
not need to have any sense, since we are attributing values to the RGB
pixels that come from monochrome readings. When Capture NX, or any RAW
developer program, reads this NEF, it will assume that it is a colour
picture and will proceed to the demosaicing and colour processing. What
weird colours is that rendering going to provide? Apples treated as
oranges?

This is a jpg out from the DNG, Adobe Camera Raw and Photoshop CS5:



This is a jpg out from the aberrant NEF file with Capture NX.



Seems to be nice, how can it be? Is not that the real image?

We need to look at the histogram. In a B/W RGB image, the three
colours will show exactly the same histogram, as their common value
implies a combined grey value.

If we look at the RGB histogram of the MM/NEF file, we can see that it
is almost identical for the three channels:















My take? Since the MM pixel sensors are so close, and they read the
same spectrum, the reading of adjacent pixels is mostly the same in a
normal image, so when copied to the RGB NEF file, they are almost a
legit RGB monochrome file with the red/green/blue values nearly
identical, and then providing a credible picture. 

If we look the NEF at 100% in Capture NX, and the DNG as open in CS 5,
I can see a sharpness advantage to the DNG, on the pixel level, but
probably nothing spectacular if you look to the complete picture.





















This curious rendering I think is just the effect of oversampling, so adjacent
monochrome pixels just happen to take the same reading.

The real value of such monochrome oversampling in normal pictures is what is
for me under question. If you want to measure the colour in a given point, there
you have all these tricks like the Bayer array, but to digitalize a B/W image is
much less demanding.

I have found some traces of colour in MM NEF files, see the DNG files
provided here,

http://www.photographyblog.com/previews/leica_m_monochrom_photos/

Where there are high frequency and contrast areas, I can see a trace of colour,
which means that the adjacent monochrome pixels do not have the same value,
for example in the earrings of this lady. The first crop comes from the B/W tiff
out of the DNG, the second from the NEF. You really need a good sight to
perceive these colours.





Which camera can give you better B/W pictures, the M9, or the M9
monochrom? The MM will be a little sharper, and have better high ISO,
but the colour information carried on the M9 RGB Bayer array seems not
to fall 100% behind in sharpness, and will provide colour masking and
selection for better post-processing. En theory, a monochrome sensor may
be a good idea, but in practice I think it does not bring sufficient advantage
over a Bayer sensor of the same resolution.

Try for your self, and enjoy.

13 comments:

  1. Hi Miguel,
    Great work, colors seems excellent. Quick note, I used my M8 files for test, in NxView, the Camera Info says Nikon D700 instead of Leica M8 and also always displays 35mm f/2. The M8 template is probably incorrect.
    Best regards, Pierre

    ReplyDelete
  2. Hello Pierre,

    Thanks for checking the tool. Regarding the aperture, you know the rangefinders do not have a clear indication of the used aperture, although some guess is calculated, with not much accuracy. I am not interested in recording this estimation, but I'll add this for the sake of completeness.

    The camera name is a funny issue. Nikon software tools only open NEF files that can be identified in their list of supported cameras and image sizes, so if you change the name the NEF will not be supported by them. The same happens with the sensor size, the NEF spec allows for an arbitrary size, but the tools only suppor the existing camera image sizes.

    Best regards,
    Miguel

    ReplyDelete
  3. Miguel, on a related note, is there any chance that you can add a feature in your SW to produce a color image by combining 4 pixels to 1 (of the M9) and generate a TIFF file?

    ReplyDelete
    Replies
    1. That is the purpose of a RAW developer, and Capture NX is a fine one. I do not plan to turn this tool into a RAW developer.

      I am already generating a jpg preview of the image, to be embedded in the NEF, that could be easily extracted if you want it. Check dcraw, it can do what you need straight out of the DNG.

      Thanks for passing by,

      Miguel

      Delete
  4. Hi Miguel,

    Interesting converter. I love using Nikon Capture NX2. AS you already know it doesn't support RAW files other than Nikon cameras. I'm considering getting the Panasonic DMC-LX7. It is similar to Leica D-LUX 6. If I understand your converter, one of the key elements is the template file. If so, it can convert any RAW files as long as there is are matching files. If that's true, do you mind sharing how someone go about creating a template file?

    Thanks,


    Luke

    ReplyDelete
  5. Hi Luke,

    The process is not so simple, the template is just a NEF file whose contents is rewritten with the DNG values, both the sensor reading and a few EXIF parameters. The trick is not so much the NEF template, but the parsing and reading of the DNG, and corresponding writing into the NEF template. You have source code here, www.bagnon.com/dng2nef/dng2nef.tcl

    I am not familiar with that Panasonic model, does it write raw files also directly in DNG?

    Regards,

    Miguel

    ReplyDelete
    Replies
    1. Hi Miguel,

      Panasonic writes in RW2. I was not able to find out if it can write DNG.

      Look like I might be inheiriting a Leica D-LUX 5. From the technical specifications PDF for the D-LUX 5, it doesn't say it writes in DNG either. It says "RAW/JPEG (based on Exif 2.3 standard)/DPOF-compatible."

      If I understand your converter correct, the DNG file has to come directly from the camera. It can't be converted by Adobe DNG Converter. Right? If that is the case, I guess I will not be able to use your converter (even if I do get the D-LUX 5)?

      Thanks,


      Luke

      Delete
  6. No, you cannot use as it is. You could use NX2, however, if you convert those files to TIFF. I do not know if the process is worth, since TIFF is not RAW anymore, and it has already been developed somehow.

    ReplyDelete
    Replies
    1. Thanks Miguel!!!

      I think I will learn to use Adobe Camera RAW instead. Will likely continue to use NX2 for some fine tuning though.

      Thanks,


      Luke

      Delete
  7. Hello there,

    I tryied to open the NEF resulted with Capture NX2, but it dent work. What can I do? I will appreciate your help.

    ReplyDelete
  8. Hello Mihai,

    Make sure you are using CNX2 v2.4.6, the last but one release.

    ReplyDelete