Matrix of eight nearest neighbors
古いコメントを表示
Hi all,
This matrix
neigb=[-1 0; 1 0; 0 -1; 0 1];
represents the four nearest neighbors.
How is the matrix of eight neighbors?
回答 (3 件)
Titus Edelhofer
2012 年 1 月 6 日
0 投票
Hi Marlene,
this should not be that difficult, I guess? One of the next four neighbors you would get by adding the line [-1 -1] to your variable neigb.
Titus
Image Analyst
2012 年 1 月 6 日
I don't understand that in an image processing context. In image processing a four-connected structuring element would look like
0 1 0
1 x 1
0 1 0
while an 8-connected one would be
1 1 1
1 x 1
1 1 1
You gave
-1 0
1 0
0 -1
0 1
4 件のコメント
Titus Edelhofer
2012 年 1 月 6 日
I understand this as follows: -1 0 means one to the left on the same y (this would correspond to index (2,1) of your first matrix).
Image Analyst
2012 年 1 月 6 日
I know it's used in the form I listed in all of the image processing routines in the Image Processing Toolbox. Where is the form you and Marlene used?
Titus Edelhofer
2012 年 1 月 6 日
I know this from numerical analysis, when you implement e.g. finite differences (in 1D the central difference is f(x+h)-f(x-h), so it would be the neighbors [-1; 1]. The discrete laplacian uses (often) the four neighbors Marlene used, i.e., f(x+h, y+h), f(x+h, y-h), f(x-h, y+h), f(x-h, y-h). Starting from x=[x,y] you add the neighbors matrix.
Sean de Wolski
2012 年 1 月 6 日
Yes it's a five point stencil:
http://en.wikipedia.org/wiki/Five-point_stencil
Marlene
2012 年 1 月 13 日
1 件のコメント
Titus Edelhofer
2012 年 1 月 13 日
Yepp, that's what I thought it should be when writing my answer above ... ;-).
カテゴリ
ヘルプ センター および File Exchange で Nearest Neighbors についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!