Detect square and circle shapes on natural image

2 次查看(过去 30 天)
My goal is to identify that a full square is present in an image. If the full square is visible, then the number of circles within this square must be counted.
Currently, I binarize the image and then count the number of holes and objects in the image using bwboundaries(): [B,L,N] = bwboundaries(BW);
I have tried to identify the square using the Hough transform, but this does not detect all lines of the square due to shadowing and the lines not being perfectly straight.
The problem is that I cannot remove shadowing and background noise and accurately identify the square shape.
I have attached a sample image from which I want to detect if the full square is in view and then count the number of circles within this square.

回答(1 个)

Image Analyst
Image Analyst 2016-7-8
You'd need to post some images that you consider not a square. Otherwise maybe we can just find any boundary that contains other blobs - and this is easier.
In the meantime, see my attached shape recognition demo.

类别

Help CenterFile Exchange 中查找有关 Get Started with Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by