When I read my DNG file into MATLAB, why does the data all appears as zeroes?
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 16 de Abr. de 2018
Editada: MathWorks Support Team
el 2 de Sept. de 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?
Respuesta aceptada
MathWorks Support Team
el 2 de Sept. de 2022
Editada: MathWorks Support Team
el 2 de Sept. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Image Data en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!