Advertisement
Guest User

Untitled

a guest
Dec 20th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 0.77 KB | None | 0 0
  1. function [edges] = nonMaxSupress(G, labels)
  2.   G = padarray(G, [1, 1], 'both');
  3.   labels = padarray(labels, [1, 1], 'both');
  4.   [R, C] = size(G);
  5.   edges = zeros(size(G));
  6.   for i = 2:R - 1
  7.     for j = 2:C - 1
  8.       label = labels(i, j);
  9.       if (label == 0 && G(i, j) > G(i, j - 1) && G(i, j) > G(i, j + 1))
  10.         edges(i, j) = G(i, j);
  11.       endif
  12.      
  13.       if (label == 1 && G(i, j) > G(i + 1, j - 1) && G(i, j) > G(i - 1, j + 1))
  14.         edges(i, j) = G(i, j);
  15.       endif
  16.      
  17.       if (label == 2 && G(i, j) > G(i + 1, j) && G(i, j) > G(i - 1, j))
  18.         edges(i, j) = G(i, j);
  19.       endif
  20.      
  21.       if (label == 3 && G(i, j) > G(i - 1, j - 1) && G(i, j) > G(i + 1, j + 1))
  22.         edges(i, j) = G(i, j);
  23.       endif
  24.     endfor
  25.   endfor
  26. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement