Convert to .TIFF without compression

26 次查看(过去 30 天)
I have a 240x200 double matrix with range 0-1. I want to export it as a .TIFF while preserving original values, but when I do, the values are re-scaled to integers [0-255]. It currently looks like this:
imwrite(image, filename, 'tiff', 'Compression', 'none');
How can I preserve the original values?

采纳的回答

Udit06
Udit06 2023-8-28
Hi Chris,
You can use the following code to save the image in the .tiff format without scaling. The code snippet uses the MATLAB’s Tiff object, you can refer https://www.mathworks.com/help/matlab/ref/tiff.html for more details.
% filename: the name with which you want to save the file
% image: 240*200 double matrix with range 0-1
t = Tiff(filename, 'w');
tagstruct.ImageLength = size(image, 1);
tagstruct.ImageWidth = size(image, 2);
tagstruct.Photometric = Tiff.Photometric.MinIsBlack;
tagstruct.BitsPerSample = 64; % 64-bit floating-point
tagstruct.SamplesPerPixel = 1;
tagstruct.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky;
tagstruct.SampleFormat = Tiff.SampleFormat.IEEEFP;
tagstruct.Compression = Tiff.Compression.None;
t.setTag(tagstruct);
t.write(image);
t.close();
I hope this helps.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by