Detect different kinds of circles and ovals on the image using OpenCV and Python
Asked Answered
A

2

5

I need to detect the different shapes on the image such as ellipses and circles with a dashed-border.

Using OpenCV causes some troubles, for e.g. openCV detects not a contour but an amount of small separated lines(contours). In case of ellipse with a "dashed-border" I need it to be as single contour, not a separated objects.

What would you suggest to solve this problem?

I also need to recognize the ellipses(or circles) with solid border and ellipses(circles) with a dashed-border

Ellipse with solid border

enter image description here

Ellipse with dashed border:

enter image description here

Attachment answered 25/5, 2015 at 12:2 Comment(4)
Attach a sample image and current output with your question to get a clearer context.Dissert
can't attach as images, so I've put them on my GoogleDrive link is attached aboveAttachment
But where is the image with dashed borders?Dissert
I don't know what had happen, but now it is attached as link I am pretty new here, so some features are terrifying=) Is it OK now?Attachment
U
7

The Hough transform should not have any troubles with either dashed or solid borders, or a mix thereof. I have used it to detect dashed lines in one of my project and ellipses should not be much harder.

OpenCV by default only implements the Hough transform for circles and straight lines but there is a blog entry with code on how to adapt it for elliptical shapes.

Ulla answered 25/5, 2015 at 13:22 Comment(4)
Cool - I could nor remember the transform name, but I was right on track as I was just saying that "OpenCV should include the needed transform, but it should require some tuning to work for you"Rusticate
the main problem is that Hough transform detects all oval shapes on the image- doesn't matter are they solid or dashed. But for me the line-type has main value in case of detecting ellipses and circlesAttachment
Dead link :/ All hail to the SO rules !Fleischman
fixed the dead link :)Ulla
R
0

The better idea there is to use an specific transform to detect circle and ellipses rather than a general "find contour" call.

I am not enough acquainted with OpenCV to know if there this sort of detection is built in there - it should be.

An internet search for the more generic "image ellipse detection" shows it is not a settled matter - unlike square and rectangle detection, so whatever OpenCV already contains will have to be tunned up. (The basic idea is that the underlying algorithm creates a new n-dimensional space where every possible paramterized ellipse for the target image could be represented (with, for example, an axis for each x and y center coordinates, w and h radii, and one for rotation), and fill in hits in this matrix according to the pixels contrast in the target image).- Sebastian's answer put the correct name for this approach I could not recall: "Hough transform", and provides the needed links on how it works, and how to extend it on OpenCV.

Rusticate answered 25/5, 2015 at 13:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.