save images as tif 32 bits by using imwrite

59 views (last 30 days)
I'm trying to save my images as tif 32 bits but I got this Error:
Cannot write uint32 data to a TIFF file
this is my code:
for K=1:10
Id{k} = waverec2(t_C,L,'sym8');
filename= ['C:\Path \Id_number_' num2str(k) '.tif'];
I need to save my images as tif 32 bits :/ have you any idea?
Thank you in advance

Accepted Answer

Andreas Goser
Andreas Goser on 7 Feb 2014
There is something in recent release called TIFF Class. Can you tell me if this meets your needs? Documentation here.
  1 Comment
Soum on 7 Feb 2014
Edited: Soum on 7 Feb 2014
Thanks Mr.Andreas But tif or Tiff unit32 still not working I want the output my images as 32 bits :/ what can I do? Cannot write uint32 data to a TIFF file

Sign in to comment.

More Answers (1)

Ashish Uthama
Ashish Uthama on 7 Feb 2014
Soum, did you click on the documentation link? Andreas was talking about the Tiff class, which is a different interface than IMWRITE.
Here is how you can use the Tiff class:
% Start with:
data = uint32(magic(10));
This is a direct interface to libtiff
t = Tiff('myfile.tif','w');
% Setup tags
% Lots of info here:
tagstruct.ImageLength = size(data,1);
tagstruct.ImageWidth = size(data,2);
tagstruct.Photometric = Tiff.Photometric.MinIsBlack;
tagstruct.BitsPerSample = 32;
tagstruct.SamplesPerPixel = 1;
tagstruct.RowsPerStrip = 16;
tagstruct.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky;
tagstruct.Software = 'MATLAB';
d = imread('myfile.tif');

Community Treasure Hunt

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

Start Hunting!