-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathReadTifStack.m
More file actions
30 lines (28 loc) · 947 Bytes
/
ReadTifStack.m
File metadata and controls
30 lines (28 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function Stack = ReadTifStack(FileTif)
InfoImage = imfinfo(FileTif);
NumberImages = length(InfoImage);
TifLink = Tiff(FileTif, 'r');
for i = 1:NumberImages
TifLink.setDirectory(i);
Stack(:,:,i) = TifLink.read();
end
TifLink.close();
end
%Another faster tiff stack loader
%InfoImage = imfinfo(FileTif);
%mImage = InfoImage(1).Width;
%nImage = InfoImage(1).Height;
%FinalImage=zeros(nImage,mImage,NumberImages,'uint16');
%FileID = tifflib('open',FileTif,'r');
%rps = tifflib('getField',FileID,Tiff.TagID.RowsPerStrip);
%for i=1:NumberImages
% tifflib('setDirectory',FileID,i);
% Go through each strip of data.
% rps = min(rps,nImage);
% for r = 1:rps:nImage
% row_inds = r:min(nImage,r+rps-1);
% stripNum = tifflib('computeStrip',FileID,r);
% FinalImage(row_inds,:,i) = tifflib('readEncodedStrip',FileID,stripNum);
% end
%end
%tifflib('close',FileID);