When I read my DNG file into MATLAB, why does the data all appears as zeroes?
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 16 Apr. 2018
Bearbeitet: MathWorks Support Team
am 2 Sep. 2022
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?
Akzeptierte Antwort
MathWorks Support Team
am 2 Sep. 2022
Bearbeitet: MathWorks Support Team
am 2 Sep. 2022
The issue is likely caused by the DNG file being compressed.
You can use a tool such as the
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Data finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!