开发者

Identify Shapes with Matlab

I created some MATLAB code, that find somes shapes in an image using regionpros and bwbounaries functions.

I have:

STATS = regionprops(L, 'all');

and from STATS I could easily find all my shapes Area and Perimeter. My problem is the following: I want to find the "square" shapes and I do in all shapes the following calculation 16 * area / (perimeter * perimeter), if this value is near one then I "may" have a开发者_JAVA百科 square. But other shapes too like circles or rectangles are near one too. (Also some squares could be rotated in the image).

Is there a better way to distinguish the shapes (like circles, triangles ...)?


Matlab has a function

procrustes(X,Y)

which will compute distance between two shapes based on the types of transformations it would take to move the points defined by X onto the points defined by Y. For many shape classification tasks, minimizing this distance is a useful way of categorizing noisy instances of shapes. If your problem has 'perfect' shapes, this should work extremely well. Just have Y fixed as a perfect square, and any time that the linear transformation from X to Y is a pure scaling, then you know X is also a square. You could do some simple logical checking to select only shapes satisfying this sort of property.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜