Check neighbour pixels Matlab
I have a vector A of size 640x1. where the value of each cell A(i,1)
varies from row to row, for example A(1,1) =[], while A(2,1)=[1] and
A(3,1)=[1,2,3]. There is another matrix B of size 480x640, where the
row_index (i) of vector A corresponds to the col_index of matrix B. While
the cell value of each row in vector A corresponds to the row_index in
matrix B. For example, A(2,1)=[1] this means col_2 row_1 in matrix B,
while A(3,1)=[1,2,3] means col_3 rows 1,2&3 in matrix B. What I'm trying
to do is to for each non-zero value in matrix B that are referenced from
vector A, I want to check whether there are at least 4 other neighbours
that are also referenced from vector A. The number neighbours of each
value are determined by a value N. For example, this is a part of matrix B
where all the zeros"just to clarify, as in fact they may be non-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
As shown, because N=3, all these zeros are pixel X's neighbors. So if more
than 4 neighbor pixels are found in vector A then do something e.g G=1 if
not then G=0; So if anyone could please advise. And please let me know if
any more clarification is needed.
No comments:
Post a Comment