Recognizing shapes in (binary) matrix

Hey all,
I'm trying to find a shape in a binary image.
In order to do that i am using bwboundaries() function to identify all the shapes in the image. I get a cell with matrices (the size of X by 2), of all the objects. Each matrix represent the number of pixels in the object.
For example, lets say there are two matrices, almost the same size. One representing the shape of a line, the other the shape of a circle (not exactly a line or a circle).
My question is - can i differ the line from the circle ?
Any help appreciated.
Yair

 採用された回答

Doug Hull
Doug Hull 2013 年 6 月 10 日

0 投票

If you KNOW that you are either dealing with a line or a circle, then could you look at the MajorAxisLength and MinorAxisLength from RegionProps. Their ratios should be wildly different, yes?
Doug

3 件のコメント

Sean de Wolski
Sean de Wolski 2013 年 6 月 10 日
Also: EquivalentDiameter v. MajorAxisLength
Yair
Yair 2013 年 6 月 11 日
Thank you both.
Gonna try this now and let you know.
Yair
Yair 2013 年 6 月 12 日
Worked like a charm!
If anyone stumbles across this, you could do:
STATS1(1).MajorAxisLength / STATS2(1).MinorAxisLength;
to get the ratio of the two axis (where STATS1=regionprops(h, 'MajorAxisLength'), and STATS2 is the minor axis).

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeImage Processing Toolbox についてさらに検索

質問済み:

2013 年 6 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by