How can I write 32-bit floating point TIFs with NaNs?
16 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Kevin Crosby
el 10 de Mayo de 2011
Comentada: Walter Roberson
el 24 de Mayo de 2019
I'm able to use IMREAD to read 32-bit floating point TIFs with NaNs for dead pixels.
After this, I do an image rotation with IMTRANSFORM with 'FillValue' of NaN (IMROTATE only fills with zeros).
Now, I'd like to save 32-bit floating point TIFs with NaNs in tact for later.
How can I do this? I've tried IMWRITE and MULTIBANDWRITE, but they don't seem to work.
I'm using MATLAB 7.11.0 (R2010b).
Thanks,
Kevin Crosby
0 comentarios
Respuesta aceptada
Walter Roberson
el 10 de Mayo de 2011
Editada: Walter Roberson
el 27 de Feb. de 2015
I suggest using the Tiff class and specifying RGB for the Photometric and specifying 32 bits per channel and writing single precision values.
This is based upon the assumption that you want the channel values themselves to be NaN, rather than setting the Alpha value to be NaN for the dead pixels.
4 comentarios
Chris Volpe
el 24 de Mayo de 2019
I've tried this, but it's converting my 32-bit float data to 8 BPP grayscale for some reason. My data is range data, specified in millimeters as a single precision float. I've tried both MinIsBlack and LinearRaw for the Photometric option, but no luck. Any thoughts?
Here's my code:
t = Tiff(fullfile(filepath, [basename '.tif']), 'w');
tagstruct.ImageLength = size(depthImage, 1);
tagstruct.ImageWidth = size(depthImage, 2);
tagstruct.Compression = Tiff.Compression.None;
tagstruct.SampleFormat = Tiff.SampleFormat.IEEEFP;
tagstruct.Photometric = Tiff.Photometric.LinearRaw;
tagstruct.BitsPerSample = 32;
tagstruct.SamplesPerPixel = 1;
tagstruct.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky;
t.setTag(tagstruct);
t.write(single(depthImage));
t.close();
Walter Roberson
el 24 de Mayo de 2019
I just re-tested the code I posted at https://www.mathworks.com/matlabcentral/answers/307519-image-file-saved-using-tiff-library-tif-appear-white-in-explorer-and-paintbrush#answer_239772 and confirm that it creates single precision on my Mac in R2019a. The only difference I can see is the Photometric.
Más respuestas (0)
Ver también
Categorías
Más información sobre Convert Image Type 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!