使用imwrite保存tif 32位图像

Ahm*_*med 3 matlab image-processing

我试图将我的图像保存为tif 32位,但我收到此错误:

Cannot write uint32 data to a TIFF file
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

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 
Run Code Online (Sandbox Code Playgroud)

我需要将我的图像保存为tif 32位.任何的想法?

使用Ashish的方法进行编辑(见下文)

for k=1:10

        Id{k} = waverec2(t_C,L,'sym8');
        filename= ['C:\Path \Id_number_' num2str(k) '.tif'];
        t = Tiff('filename','a')
    Id{k}=uint32(Id{k});
    t.write(Id{k});
end
Run Code Online (Sandbox Code Playgroud)

但在Matlab下我得到了这个错误:

Error using tifflib
Unable to retrieve ImageLength.

    Error in Tiff/getTag (line 784)
                        tagValue = tifflib('getField',obj.FileID,Tiff.TagID.(tagId));

    Error in Tiff/writeAllStrips (line 1660)
                h = obj.getTag('ImageLength');

    Error in Tiff/write (line 1228)
                    obj.writeAllStrips(varargin{:});
Run Code Online (Sandbox Code Playgroud)

Ash*_*ama 6

MATLAB可以:

%
% Start with:
% http://www.mathworks.com/help/matlab/import_export/exporting-to-images.html#br_c_iz-1

data = uint32(magic(10));


%% -------------------------------------
%  Modify these variables to reuse this section: (enclosed by ----s)
%     - outputFileName  (filename in your question)
%     - data            (Id{k} in your question)
%


outputFileName = 'myfile.tif';
% This is a direct interface to libtiff
t = Tiff(outputFileName,'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))
Run Code Online (Sandbox Code Playgroud)