-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThresh_3D.m
More file actions
138 lines (127 loc) · 4.13 KB
/
Copy pathThresh_3D.m
File metadata and controls
138 lines (127 loc) · 4.13 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
function [value] = Thresh_3D( Matrix )
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
a = size(Matrix)
X = Matrix
%Thresholding in X-Y direction (X = rows Y = Columns)
for z = 50:2:60
c = X(:,:,z);
minc = min(min(c));
maxc = max(max(c));
%Preallocating the size of the vectors
b=1;
inte = (zeros([(maxc-minc)/1000, 1]));%edit denominator for finer thresholding
values = int16(zeros([(maxc-minc)/1000,1]));%edit denominator for finer thresholding
d = int16(zeros([nRows, nColumns]));
value = minc;
%Scanning through threshold values
while value < maxc
i = 1;
while i <=nRows
j=1;
while j <= nColumns
if c(i,j,1) < value % Values less than the threshold are set to zero
d(i,j)= 0;
else
d(i,j)= 1; %Everything else is set to 1
end
j=j+1;
end
i=i+1;
end
%Adding values into vectors
inte(b) = sum(sum(d));
values(b)=value;
b = b+1;
%Save new array to workspace
assignin('base','slice_edit',d);
value = value + 1000;%Edit this for finer thresholding
end
% assignin('base','intensity',inte);
% assignin('base','threshold_values',values);
%Display plot of intensity vs. threshold value
assignin('base','rows',nRows*nColumns);
assignin('base','inte',inte);
inte = inte/(double(nRows)*double(nColumns));
plot(values,inte); hold on;
xlabel('Threshold values')
ylabel('Percentage of pixels')
end
for x = 50:2:60
c = X(x,:,:);
%Preallocating the size of the vectors
b=1;
intex = zeros([(maxc-minc)/1000, 1]);%edit denominator for finer thresholding
values = int16(zeros([(maxc-minc)/1000,1]));%edit denominator for finer thresholding
dx = zeros([nColumns,nFrames]);
value = minc;
%Scanning through threshold values
while value < maxc
i = 1;
while i <=nColumns
j=1;
while j <= nFrames
if c(1,i,j) < value % Values less than the threshold are set to zero
dx(i,j)= 0;
else
dx(i,j)= 1; %Everything else is set to 1
end
j=j+1;
end
i=i+1;
end
%Adding values into vectors
intex(b) = sum(sum(dx));
values(b)=value;
b = b+1;
%Save new array to workspace
assignin('base','slice_editx',dx);
value = value + 1000;%Edit this for finer thresholding
end
% assignin('base','intensity',inte);
% assignin('base','threshold_values',values);
%Display plot of intensity vs. threshold value
intex = intex/(double(nFrames)*double(nColumns));
plot(values,intex,'red'); hold on;
end
for y = 50:2:60
c = X(:,y,:);
Preallocating the size of the vectors
b=1;
intey = zeros([(maxc-minc)/1000, 1]);%edit denominator for finer thresholding
values = int16(zeros([(maxc-minc)/1000,1]));%edit denominator for finer thresholding
dy = zeros([nRows,nFrames]);
value = 250;
Scanning through threshold values
while value < 300
i = 1;
while i <=nRows
j=1;
while j <= nFrames
if c(i,1,j) < value % Values less than the threshold are set to zero
dy(i,j)= 0;
else
dy(i,j)= 1; %Everything else is set to 1
end
j=j+1;
end
i=i+1;
end
Adding values into vectors
intey(b) = sum(sum(dy));
values(b)=value;
b = b+1;
Save new array to workspace
assignin('base','slice_editx',dx);
value = value + 1000;%Edit this for finer thresholding
end
assignin('base','intensity',inte);
assignin('base','threshold_values',values);
%Display plot of intensity vs. threshold value
intey = intey/(double(nFrames)*double(nColumns));
plot(values,intey,'green');
legend('X-Y Plane','X-Z Plane','Y-Z Plane')
end
figure
imshow(dy)
end