Available to write/save/store a half precision as 16 bit TIFF? otherwise 32 bit TIFF?
I found that half precision can express floating point number in 16 bit. Can I write/save/store a half precision as 16 bit TIFF? otherwise 32 bit TIFF? In my trials, the TIFF writing with 16 bit allows int16 and uint16 only, and int32, uint32, single for the TIFF writing with 32 bit only.
This is related to question below:
https://kr.mathworks.com/matlabcentral/answers/1633680-available-that-tiff-image-of-16-bit-unsigned-integer-has-smaxsamplevalue-of-ieee-floating-point-numb?s_tid=srchtitle
clc; clear all; close all;
Img = imread(‘cameraman.tif’);
ImgS = single(Img);
ImgN = ImgS/(max(ImgS,[],"all")+1);
figure; imagesc(ImgN); axis image; colormap(‘gray’); colorbar;
ImgH = half(ImgN);
t = Tiff(‘myimageHalf.tif’,’w’);
tagstruct.ImageLength = size(ImgH,1);
tagstruct.ImageWidth = size(ImgH,2);
tagstruct.Photometric = Tiff.Photometric.MinIsBlack;
tagstruct.BitsPerSample = 16;
tagstruct.SamplesPerPixel = 1;
tagstruct.SampleFormat = 1;
tagstruct.SMaxSampleValue = double(max(ImgH,[],"all"));
tagstruct.SMinSampleValue = double(min(ImgH,[],"all"));
tagstruct.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky;
tagstruct.Software = ‘MATLAB’;
setTag(t,tagstruct)
write(t,ImgH);
close(t);I found that half precision can express floating point number in 16 bit. Can I write/save/store a half precision as 16 bit TIFF? otherwise 32 bit TIFF? In my trials, the TIFF writing with 16 bit allows int16 and uint16 only, and int32, uint32, single for the TIFF writing with 32 bit only.
This is related to question below:
https://kr.mathworks.com/matlabcentral/answers/1633680-available-that-tiff-image-of-16-bit-unsigned-integer-has-smaxsamplevalue-of-ieee-floating-point-numb?s_tid=srchtitle
clc; clear all; close all;
Img = imread(‘cameraman.tif’);
ImgS = single(Img);
ImgN = ImgS/(max(ImgS,[],"all")+1);
figure; imagesc(ImgN); axis image; colormap(‘gray’); colorbar;
ImgH = half(ImgN);
t = Tiff(‘myimageHalf.tif’,’w’);
tagstruct.ImageLength = size(ImgH,1);
tagstruct.ImageWidth = size(ImgH,2);
tagstruct.Photometric = Tiff.Photometric.MinIsBlack;
tagstruct.BitsPerSample = 16;
tagstruct.SamplesPerPixel = 1;
tagstruct.SampleFormat = 1;
tagstruct.SMaxSampleValue = double(max(ImgH,[],"all"));
tagstruct.SMinSampleValue = double(min(ImgH,[],"all"));
tagstruct.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky;
tagstruct.Software = ‘MATLAB’;
setTag(t,tagstruct)
write(t,ImgH);
close(t); I found that half precision can express floating point number in 16 bit. Can I write/save/store a half precision as 16 bit TIFF? otherwise 32 bit TIFF? In my trials, the TIFF writing with 16 bit allows int16 and uint16 only, and int32, uint32, single for the TIFF writing with 32 bit only.
This is related to question below:
https://kr.mathworks.com/matlabcentral/answers/1633680-available-that-tiff-image-of-16-bit-unsigned-integer-has-smaxsamplevalue-of-ieee-floating-point-numb?s_tid=srchtitle
clc; clear all; close all;
Img = imread(‘cameraman.tif’);
ImgS = single(Img);
ImgN = ImgS/(max(ImgS,[],"all")+1);
figure; imagesc(ImgN); axis image; colormap(‘gray’); colorbar;
ImgH = half(ImgN);
t = Tiff(‘myimageHalf.tif’,’w’);
tagstruct.ImageLength = size(ImgH,1);
tagstruct.ImageWidth = size(ImgH,2);
tagstruct.Photometric = Tiff.Photometric.MinIsBlack;
tagstruct.BitsPerSample = 16;
tagstruct.SamplesPerPixel = 1;
tagstruct.SampleFormat = 1;
tagstruct.SMaxSampleValue = double(max(ImgH,[],"all"));
tagstruct.SMinSampleValue = double(min(ImgH,[],"all"));
tagstruct.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky;
tagstruct.Software = ‘MATLAB’;
setTag(t,tagstruct)
write(t,ImgH);
close(t); half, half precision, precision, tiff MATLAB Answers — New Questions