save/write and load/read stack image files in Matlab

Write:

imageData = ones([100 100 10]);
tifFile = ‘ImageStack.tif’;
for i = 1:10
imwrite( imageData (:,:,i), tifFile,’WriteMode’,’append’);
end

Load:

tifFile = ‘ImageStack.tif’;
infoImage = imfinfo(tifFile);
w = InfoImage(1).Width;
h = InfoImage(1).Height;
planeNo = length(InfoImage);
imageData = zeros(h,w,planeNo,’uint16′);
for i = 1:planeNo
imageData(:,:,i) = imread(tifFile,’Index’,i);
end

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: