detect square objects in a binary image

9 views (last 30 days)
genesis
genesis on 1 Nov 2013
Commented: Image Analyst on 1 Nov 2013
i have previously used regionprops to measure the boundingbox in a binary image. but the thing is sometimes it can detect sometimes it cannot detect the square in the image. is there any more robust way to detect square and obtain its location and dimension?

Answers (2)

Jeremy
Jeremy on 1 Nov 2013
I was thinking about this recently, a hough transform could be a very robust way to find squares, if they are not rotated at all it would be fairly quick and would have no trouble with partial or overlapping squares. Are these actual squares or rectangles? I don't know your experience level, but writing a hough transform from scratch can be tough.
  2 Comments
genesis
genesis on 1 Nov 2013
they are square exactly but maybe in different orientation i would say my experience is beginner
Image Analyst
Image Analyst on 1 Nov 2013
You forgot to post your image, again.

Sign in to comment.


Image Analyst
Image Analyst on 1 Nov 2013
I would not really say that regionprops is a square detector. It characterizes and measures blobs. You need to do something in advance to create a binary image. If you did a good job, then your blob will be square and regionprops will measure it, and all blobs and tell you which are square or not square, but you have to have created the cquare binary blobs in the first place. How you do that is through image processing and what processes you need to use depend on what your square looks like. is it solid, or a perimeter that's "hollow" in the middle? Have you tried the corner() function? It all depends on what your image looks like. An algorithm that's good at detecting a bright square on a black background would not be appropriate for detecting a blue satin fabric patch on a piece of blue knit fabric the same color. You might be able to get by with simple thresholding in the first case, while in the second case you'd need a texture processing method.

Community Treasure Hunt

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

Start Hunting!