Files
fold_slice/+io/save_tiff_image.m
2026-08-07 15:56:42 +09:00

22 lines
568 B
Matlab

function [] = save_tiff_image(I, path)
% Wrapper function for saving 16-bit .tiff image
% Written by YJ
% ** I: 2D image
% ** path: file path
tagstruct.ImageLength = size(I,1);
tagstruct.ImageWidth = size(I,2);
tagstruct.Photometric = Tiff.Photometric.MinIsBlack;
tagstruct.BitsPerSample = 16;
tagstruct.SamplesPerPixel = 1;
tagstruct.RowsPerStrip = 16;
tagstruct.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky;
tagstruct.Software = 'MATLAB';
t = Tiff(path,'w');
t.setTag(tagstruct)
t.write(uint16(mat2gray(I)*2^16));
t.close();
end