Convert to .TIFF without compression
32 ビュー (過去 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?
0 件のコメント
採用された回答
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 Center および File Exchange で Image Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!