Search code examples
matlabdng

Reading CFA of a DNG image in matlab generates all-zero image


I wrote the matlab code as https://blogs.mathworks.com/steve/2011/03/08/tips-for-reading-a-camera-raw-file-into-matlab/ mentioned to read the Color Filter Array of my DNG file, the code is as below:

Info=imfinfo('xxx.dng');
tiffHandle=Tiff(('xxx.dng'),'r');
offsets=TiffHandle.getTag('SubIFD');
setSubDirectory(TiffHandle,offsets(1));
CFA=double(read(TiffHandle));

The resultant CFA is an all-zero matrix that plotted as an pure black image. I wonder how to solve this problem and read the bayer array of the DNG image? Thanks in advance!


Solution

  • The current answer to this question is you should change the backward version of your DNG image to 1.3 instead of 1.4 and turn on "Uncompressed" option in Adobe DNG Converter, or use -dng1.3 -u in command line, then the cfa array can be normally read.