-
Notifications
You must be signed in to change notification settings - Fork 1
/
DL_ImageStrat.m
147 lines (111 loc) · 2.82 KB
/
DL_ImageStrat.m
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
137
138
139
140
141
142
143
144
145
146
147
function [RGB1, out] = DL_ImageStrat(IM2);
%DL_ImageStrat.m
% 'geo-plot' plotter for clustered data, and to create ( and save) imagew
% WAL3
% Dec 2018; Last revision: 12-Dec-2020
% User inputs
Draw_Line = 0; % flag to draw a line across a damaged section
% Make an intensity matched overlay:
figure();
RGB1 = XMASS_tish(IM2(:,:,1),IM2(:,:,2),IM2(:,:,3));
if Draw_Line ==1;
% get cross-section ( through UI input)
disp('Make a cross-section selection!');
[x,y] = ginput(2);
hold on;
plot(x,y,'LineWidth',5,'Color',[1 1 1]);
% make like 'thick'
m = ((y(2)-y(1))/(x(2)-x(1))); % slope ( rise/run)
counter = 1;
% plot on top
I = getimage(gca);
for i = 1: 20; % change x and y by on
% solve for y = mx+b
y1(counter) = (round(m*(x(1)))+1*i);% increase 'b' by one...
x1(counter) = (round(y1(1)/m));
y1(counter) = -y1(counter);
counter = counter+1;
y1(counter) = (round(m*(x(2)))+1*i);
x1(counter) = (round(y1(2)/m));
y1(counter) = -y1(counter);
counter = 1;
temp = squeeze(improfile(I,x,y,1000));
if i ==1;
dat(:,:,i) = temp;
else
dat(:,:,i) = temp(1:size(dat,1),:);
end
end
dat2 = mean(dat,3);
smth = 300; % smoothing factor
figure();
hold on;
plot(smooth(dat2(:,1),smth),'r')
plot(smooth(dat2(:,2),smth),'g')
plot(smooth(dat2(:,3),smth),'b')
end
smooth_param = 10;% how much to spatially smooth
for i = 1:3;
C(:,:,i) =imgaussfilt(RGB1(:,:,i),smooth_param,'padding','circular');
end
% First, look at Blue vs Green
matA = C(:,:,2) - C(:,:,3);
figure();
subplot(3,1,1)
imshow(RGB1);
subplot(3,1,2)
h = imshow(RGB1);
alpha = (matA+0.2);
BW1 = imbinarize(matA);
alpha(alpha<0.25) = 0;
set(h, 'AlphaData', BW1);
subplot(3,1,3)
h2 = imshow(RGB1);
alpha = -(matA)+0.2;
alpha(alpha<0.3) = 0;
BW2 = imbinarize(alpha);
set(h2, 'AlphaData', alpha);
% Plot boundires
B = bwboundaries(BW1);
figure();
imagesc(RGB1);
hold on;
for i = 1:size(B,1)
plot(B{i}(:,2),B{i}(:,1),'LineWidth',2,'Color',[1 1 1])
end
title('blue and green overlap');
% next, Green vs Red...
clear matA
matA = C(:,:,1) - C(:,:,2);
figure();
subplot(3,1,1)
imshow(RGB1);
subplot(3,1,2)
h = imshow(RGB1);
alpha = (matA+0.2);
BW1 = imbinarize(matA);
alpha(alpha<0.25) = 0;
set(h, 'AlphaData', BW1);
out.R = BW1;
subplot(3,1,3)
h2 = imshow(RGB1);
alpha = -(matA)+0.2;
alpha(alpha<0.3) = 0;
BW2 = imbinarize(alpha);
set(h2, 'AlphaData', alpha);
out.B = BW2;
% get ouptupts
for i = 1: 3
out.All(:,:,i) = imbinarize(C(:,:,i));
end
% Plot boundires
B2 = bwboundaries(BW1);
figure();
imagesc(RGB1);
hold on;
for i = 1:size(B2,1)
plot(B2{i}(:,2),B2{i}(:,1),'LineWidth',2,'Color',[1 1 1])
end
title('red and green overlap')
out.B = B;
out.B2 = B2;