-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloadColoredThresholdSequence.m
More file actions
43 lines (37 loc) · 1.81 KB
/
Copy pathloadColoredThresholdSequence.m
File metadata and controls
43 lines (37 loc) · 1.81 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
%% ---------------------- loadColoredImageSequence -------------------------------
% 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).
%
% 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 = loadColoredThresholdSequence(folder, prefix ,firstIndex, filetype,x0,y0,xdim,ydim,zdim,sigfigs)
addpath('C:\Users\Avik Mondal\Documents\Carlson Lab\Bone Project MATLAB code');
imagefiles = dir(char(strcat(folder,"*.", filetype)));
%nfiles = size(imagefiles,1);
%sampleimage = imread(char(strcat(folder, prefix,formattedFirstIndex,".", filetype)));
filename = strcat(folder,prefix);
%startingIndex = 80;
filetypeSuffix = strcat(".",filetype);
%sample = strcat(filename, int2str(200), filetype);
%imageMatrix = [];
immat = zeros(ydim,xdim, 0);
for i = firstIndex:firstIndex+zdim-1
formattedIndex = sprintf(horzcat('%0',num2str(sigfigs),'.0f'),i);
%disp(formattedIndex);
path_to_slice = char(strcat(filename, formattedIndex, filetypeSuffix));
newSlice = imread(path_to_slice);
immat = cat(3,immat, newSlice(y0:y0+ydim-1, x0:x0+xdim-1));
end