Available to write/save/store a half precision as 16 bit TIFF? otherwise 32 bit TIFF?
Afficher commentaires plus anciens
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:
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);
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Image Data dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!