When I read my DNG file into MATLAB, why does the data all appears as zeroes?

32 ビュー (過去 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?

採用された回答

MathWorks Support Team
MathWorks Support Team 2018 年 4 月 16 日
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:
<https://blogs.mathworks.com/steve/2011/03/08/tips-for-reading-a-camera-raw-file-into-matlab/>
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.

その他の回答 (0 件)

製品


リリース

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by