-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfun_RIDGE_WEEDING.m
79 lines (70 loc) · 1.65 KB
/
fun_RIDGE_WEEDING.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
function [LOC_RIDGE_TRIM, LOC_BIF_TRIM] = fun_RIDGE_WEEDING(BIN0, LOC_RIDGE, LOC_BIF)
% Kannan Karthik
% Aug 31, 2018
L = bwlabeln(BIN0);
%figure;
MAX = max(L(:));
%imshow(uint8(255*L/MAX));
LOC_RIDGE_TRIM = LOC_RIDGE;
LOC_BIF_TRIM = LOC_BIF;
for i = 1:length(LOC_RIDGE),
A = LOC_RIDGE{i};
LRIDGE(i) = L(A(1), A(2));
end
for i = 1:length(LOC_BIF),
A = LOC_BIF{i};
LBIF(i) = L(A(1), A(2));
end
SET_RIDGE_WEED = [];
SET_BIF_WEED = [];
for i = 1:length(LOC_RIDGE),
for j = 1:length(LOC_BIF),
A = LOC_RIDGE{i};
B = LOC_BIF{j};
LABA = L(A(1), A(2));
LABB = L(B(1), B(2));
DAB = norm(A-B);
T = 5;
if DAB < T && LABA == LABB,
LOC_RIDGE_TRIM{i} = [];
end
end
end
SET_RIDGE_WEED2 = [];
for i = 1:length(LOC_RIDGE),
for j = i+1:length(LOC_RIDGE),
A = LOC_RIDGE{i};
B = LOC_RIDGE{j};
LABA = L(A(1), A(2));
LABB = L(B(1), B(2));
DAB = norm(A-B);
T = 5;
if DAB < T && LABA == LABB,
LOC_RIDGE_TRIM{j} = [];
end
end
end
% SET_RIDGE_WEED_FINAL = union(SET_RIDGE_WEED, SET_RIDGE_WEED2);
% c = 1;
% for i = 1:length(LOC_RIDGE),
% BT = SET_RIDGE_WEED_FINAL == i;
% TEST = sum(BT);
% if TEST == 0,
% LOC_RIDGE_TRIM{c} = LOC_RIDGE{i};
% c = c+1;
% end
% end
%
%
% c = 1;
% for i = 1:length(LOC_BIF),
% BT = SET_BIF_WEED == i;
% TEST = sum(BT);
% if TEST == 0,
% LOC_BIF_TRIM{c} = LOC_BIF{i};
% c = c+1;
% end
% end
LOC_BIF_TRIM = LOC_BIF_TRIM(~cellfun('isempty',LOC_BIF_TRIM));
LOC_RIDGE_TRIM = LOC_RIDGE_TRIM(~cellfun('isempty',LOC_RIDGE_TRIM));
end