When I read my DNG file into MATLAB, why does the data all appears as zeroes?
28 ビュー (過去 30 日間)
I have a DNG file that I would like to read into MATLAB. Currently, I am using the following code to do so:
fileIm = 'myFile.dng';
t = Tiff(fileIm, 'r');
rawData = t.read();
sum(rawData(:)) % All values are zero
Why is all of the data in 'rawData' zeroes, when the file clearly has data if you open it outside of MATLAB?
The issue is likely caused by the DNG file being compressed.
You can use a tool such as the Adobe DNG Converter to convert the image to a DNG without compression. Once the image is converted, MATLAB will be able to read the data.
The following blog post contains additional information on reading DNG files into MATLAB, that you may find useful:
As the above blog notes, MATLAB needs the DNG files to not be compressed in order to read them correctly.
If you can choose to save the files as non-compressed DNGs when they are captured, that would be easiest. However, if you are not able to control compression when the image is taken, you will need to run the images through a software similar to the above linked Adobe converter to de-compress the images, and then load the de-compressed images into MATLAB.