Reputation: 1044
I need to get pixel neighbors in order to get a sequence of boundary points , so my plan is to :-
How can i get pixel neighbors in MATLAB ?
Upvotes: 3
Views: 6636
Reputation: 111
You could always define a displacement vector
d = [ 1 0; -1 0; 1 1; 0 1; -1 1; 1 -1; 0 -1; -1 -1];
Then the neighbors of location loc =[i j]
are
neighbors = d+repmat(loc,[8 1]);
Hope is useful to you...
Upvotes: 7