-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloadThresholdSequence.m
More file actions
39 lines (34 loc) · 1.66 KB
/
loadThresholdSequence.m
File metadata and controls
39 lines (34 loc) · 1.66 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
%% ---------------------- loadBinVOISequence -------------------------------
% Avik Mondal
%
% Aim:
% - a function that more efficiently allows me to load in my image files
% (rather than making a new load images script every time I need to do it).
%(I MADE THIS FUNCTION TO SUIT THE NAMING CONVENTION THAT CHANTAL USES)
%
% Parameters:
% string folder - folder containing the files you plan to read in
% string prefix - string containing the beginning of the file you are
% trying to open (sans the numbering)
% int firstIndex - the "number" of the first file in your sequence
% string filetype - the filetype of your file
% int x0 - the x-coordinate of the point at which you begin reading in
% your image
% int y0 - the y-coordinate of the point at which you begin reading in your
% image
% int xdim,ydim,zdim - the dimensions of the matrix the function will generate
%--------------------------------------------------------------------------
function immat = loadThresholdSequence(folder, prefix ,firstIndex, filetype,x0,y0,xdim,ydim,zdim)
addpath('C:\Users\avik2\Documents\CarlsonLab\Bone Project MATLAB code');
imagefiles = dir(char(strcat(folder,"*.", filetype)));
filename = strcat(folder,prefix);
filetypeSuffix = strcat(".",filetype);
%imageMatrix = [];
immat = logical(zeros(ydim,xdim, 0));
for i = firstIndex:firstIndex+zdim-1
formattedIndex = sprintf('%04.0f',i);
%disp(formattedIndex);
path_to_slice = char(strcat(filename, formattedIndex, filetypeSuffix));
newSlice = logical(imbinarize(imread(path_to_slice)));
immat = cat(3,immat, newSlice(y0:y0+ydim-1, x0:x0+xdim-1));
end