필터 지우기
필터 지우기

Save matrix as image format file

조회 수: 8 (최근 30일)
Emmanuelle
Emmanuelle 2013년 2월 4일
Hi,
I have a matrix with a 61x89x6 double length. I want to save it as a tiff or another image format file. I've checked the help and I've seen that I have to use the multibandwrite comand but it doesn't work.
This is what I'm doing.
% the matrix creation after some operations
image_output(:,:,1)= yl1;
image_output(:,:,2)= yl2;
image_output(:,:,3)= yl3;
image_output(:,:,4)= yl4;
image_output(:,:,5)= yl5;
image_output(:,:,6)= yl7;
%the comand
multibandwrite(image_output,'image_output.bil','bil');
Am I doing something wrong? Really thanks in advance,
  댓글 수: 1
Jan
Jan 2013년 2월 4일
Please explain the details of "it doesn't work" instead of hoping, that we can guess whats going on. Thanks.

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

답변 (1개)

Ashish Uthama
Ashish Uthama 2013년 2월 4일
If you have a current version of MATLAB, the Tiff class provides a way to write multi sample image data.
Note: This is a direct interface to LibTIFF, if you need more help, please look up the link in the code below:
%% Write a 61x89x6 double matrix as a TIFF file
data = reshape(1:61*89*6, [ 61 89 6]);
% pref the TIFF object
t = Tiff('output.tif','w');
% http://www.mathworks.com/help/matlab/import_export/exporting-to-images.html
tags.ImageLength = size(data,1);
tags.ImageWidth = size(data,2);
tags.Photometric = Tiff.Photometric.MinIsBlack;
tags.BitsPerSample = 64;
tags.SampleFormat = Tiff.SampleFormat.IEEEFP;
tags.RowsPerStrip = 16;
tags.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky;
tags.SamplesPerPixel = 6;
unspec = Tiff.ExtraSamples.Unspecified;
tags.ExtraSamples = [ unspec, unspec, unspec, unspec, unspec];
t.setTag(tags);
disp(t);
t.write(data);
t.close();
wdata = imread('output.tif');
flag = isequal(data,wdata);
disp(flag);

카테고리

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