필터 지우기
필터 지우기

How to save a series of images (.tiff) as a stack

조회 수: 114 (최근 30일)
AbioEngineer
AbioEngineer 2021년 1월 4일
댓글: Janek Peters 2021년 5월 28일
I can use imwrite() to save color images as tiff but I would like to have them in a single file like the one attached here. In ImageJ I can see all these images by panning a scrollbar at the bottom. How can I export 5 tiff images into a tiff image stack like this directly from matlab?
Example of a tiff image stack can be downloaded below
Edit:
When I use the Tiff class Tiff('path to file above') I get:
TIFF File: 'C:\blablablablablabla'
Mode: 'r'
Current Image Directory: 1
Number Of Strips: 1
SubFileType: Tiff.SubFileType.Default
Photometric: Tiff.Photometric.RGB
ImageLength: 800
ImageWidth: 800
RowsPerStrip: 800
BitsPerSample: 8
Compression: Tiff.Compression.None
SampleFormat: Tiff.SampleFormat.UInt
SamplesPerPixel: 3
PlanarConfiguration: Tiff.PlanarConfiguration.Chunky
ImageDescription: ImageJ=1.52p
images=5
slices=5
unit=micron
loop=false
Orientation: Tiff.Orientation.TopLeft

채택된 답변

AbioEngineer
AbioEngineer 2021년 1월 4일
t=Tiff('Stacked.tiff','w');
tagstruct.ImageLength = y1; % image height
tagstruct.ImageWidth = x1; % image width
tagstruct.Photometric = Tiff.Photometric.RGB; % https://de.mathworks.com/help/matlab/ref/tiff.html
tagstruct.BitsPerSample = 8;
tagstruct.SamplesPerPixel = 3;
tagstruct.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky; % groups rgb values into a single pixel instead of saving each channel separately for a tiff image
tagstruct.Software = 'MATLAB';
setTag(t,tagstruct)
write(t,squeeze(im2uint8(Imagelayer1)));
writeDirectory(t);
setTag(t,tagstruct)
write(t,squeeze(im2uint8(Imagelayer2))) %%%appends the next layer to the same file t
% do this for as many as you need, or put it in a loop if you can
close(t) %%% this is necessary otherwise you won't be able to open it in imageJ etc to double check, unless you close matlab
  댓글 수: 1
Janek Peters
Janek Peters 2021년 5월 28일
This is great, thanks a lot for providing the answer!

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by