Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [edges] = nonMaxSupress(G, labels)
- G = padarray(G, [1, 1], 'both');
- labels = padarray(labels, [1, 1], 'both');
- [R, C] = size(G);
- edges = zeros(size(G));
- for i = 2:R - 1
- for j = 2:C - 1
- label = labels(i, j);
- if (label == 0 && G(i, j) > G(i, j - 1) && G(i, j) > G(i, j + 1))
- edges(i, j) = G(i, j);
- endif
- if (label == 1 && G(i, j) > G(i + 1, j - 1) && G(i, j) > G(i - 1, j + 1))
- edges(i, j) = G(i, j);
- endif
- if (label == 2 && G(i, j) > G(i + 1, j) && G(i, j) > G(i - 1, j))
- edges(i, j) = G(i, j);
- endif
- if (label == 3 && G(i, j) > G(i - 1, j - 1) && G(i, j) > G(i + 1, j + 1))
- edges(i, j) = G(i, j);
- endif
- endfor
- endfor
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement