-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoadTiff.m
More file actions
46 lines (41 loc) · 1.54 KB
/
LoadTiff.m
File metadata and controls
46 lines (41 loc) · 1.54 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
function ImageStack = LoadTiff(Tiff_Directory)
% <Documentation>
% LoadTiff()
% Load multi-page .tif files and save into a 3D image stack (Rows, Columns, Frames)
% Created by: jsl5865
%
% Syntax:
% ImageStack = LoadTiff(Tiff_Directory)
%
% Description:
% This function reads all pages of a multi-page .tif file. This function can be called
% with a known file directory as the input or can be called without an input. In
% the case of no input, a file selection window will open for the user to choose
% the .tif file to be loaded.
%
% Input:
% Tiff_Directory - String or character entry. This is the full path directory to the
% .tif file.
% Output:
% ImageStack - 3D numeric array containing the pixel intensity values for the loaded
% .tif file. Saved as a 3D vector: Rows, Columns, Frames.
%
% <End Documentation>
arguments
Tiff_Directory {mustBeTextScalar} = ""
end
if Tiff_Directory == ""
File = FileLookup("tif","SingleFile");
Tiff = File.Path;
else
Tiff = Tiff_Directory;
end
TiffInfo = imfinfo(Tiff);
Frames = numel(TiffInfo);
Rows = TiffInfo(1).Height;
Columns = TiffInfo(1).Width;
ImageStack = zeros(Rows, Columns, Frames, "like", imread(Tiff, 1));
for i = 1:Frames
ImageStack(:,:,i) = imread(Tiff, i);
end
end