When I read my DNG file into MATLAB, why does the data all appears as zeroes?
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 16 Avr 2018
Modifié(e) : MathWorks Support Team
le 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?
Réponse acceptée
MathWorks Support Team
le 2 Sep 2022
Modifié(e) : MathWorks Support Team
le 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Image Data dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!