필터 지우기
필터 지우기

save images as tif 32 bits by using imwrite

조회 수: 28 (최근 30일)
Soum
Soum 2014년 2월 7일
답변: Ashish Uthama 2014년 2월 7일
Hi;
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'];
Id{k}=uint32(Id{k});
imwrite(Id{k},filename);
end
I need to save my images as tif 32 bits :/ have you any idea?
Thank you in advance

채택된 답변

Andreas Goser
Andreas Goser 2014년 2월 7일
There is something in recent release called TIFF Class. Can you tell me if this meets your needs? Documentation here.
  댓글 수: 1
Soum
Soum 2014년 2월 7일
편집: Soum 2014년 2월 7일
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

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Ashish Uthama
Ashish Uthama 2014년 2월 7일
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:
% http://www.mathworks.com/help/matlab/import_export/exporting-to-images.html#br_c_iz-1
data = uint32(magic(10));
This is a direct interface to libtiff
t = Tiff('myfile.tif','w');
% Setup tags
% Lots of info here:
% http://www.mathworks.com/help/matlab/ref/tiffclass.html
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';
t.setTag(tagstruct)
t.write(data);
t.close();
d = imread('myfile.tif');
disp(class(d));
assert(isequal(d,data))

카테고리

Help CenterFile Exchange에서 Image Data에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by