フィルターのクリア

Detecting 8 connected neighborhood of a object in image

9 ビュー (過去 30 日間)
Dimitris M
Dimitris M 2013 年 3 月 1 日
Hello
I need to find robust method for detecting the 8-connected neighbor of a rectangle-like object in an image.
I was considering something like dilation on the image but this does not seems to detect all the adjacent pixels in every case (considering change of shape) so know I am looking for another approach.
If you have any idea please let me know !
Regards

回答 (2 件)

Matt J
Matt J 2013 年 3 月 1 日
編集済み: Matt J 2013 年 3 月 1 日
You mean you have a binary image and you want to detect pixels with 8 neighbours that are "1"? If so,
kernel=[1 1 1; 1 0 1; 1 1 1]/8;
idx = conv(image,kernel,'same')>=.998; %.998 is a tolerance close to 1
and then if you want to, you can convert idx to subscript indices
[I,J]=find(idx);
  2 件のコメント
Dimitris M
Dimitris M 2013 年 3 月 1 日
Hello
I tried your algorithm but it doesn't seem to work. From what I have seen the conv() function requires vectors as input and the "image" and "kernel" are 2-D arrays !
Is there a way to work this out ?
Thanks again for the feedback
Matt J
Matt J 2013 年 3 月 1 日
編集済み: Matt J 2013 年 3 月 1 日
Sorry, I meant conv2.
idx = conv2(image,kernel,'same')>=.998;

サインインしてコメントする。


Image Analyst
Image Analyst 2013 年 3 月 1 日
Dmitris:
This is done with bwhitmiss() in the Image Processing Toolbox. Go here to Steve's blog to see examples: http://blogs.mathworks.com/steve/2011/07/08/binary-image-hit-miss-operator/. You just need to look at 4 cases, where the center pixel is true and a single corner is true. All of the other possible 252 cases will be 4 connected or not connected at all.

カテゴリ

Help Center および File ExchangeImage Segmentation and Analysis についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by