Check the surroundings neighbors of a certain cell in matrix Matlab
I have a matrix A size 480x640, for each pixel I want to check its
neighbours. The neighbours of the pixel arr determined by a value N. For
example this is a part of matrix A where all the zeros are the neighbours
of pixel X when N=3:
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 X 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
so as shown, because N=3 then all these zeros are considered the pixel X
neighbours. The problem is if X will be located before the index N=3 as
shown here the neighbours will be pixels having the one values:
X 1 1 1 0 0 0
1 1 1 1 0 0 0
1 1 1 1 0 0 0
1 1 1 1 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
So If anyone could advise how can I handle this?
No comments:
Post a Comment