Click here to Skip to main content
13,141,821 members (61,175 online)
Rate this:
Please Sign up or sign in to vote.
Finding circle's edges:

Here are the two sample images I have posted and I need an algorithm to find the edges of these circles. Is it possible to develop one generic circle algorithm, that could find all possible circles in all scenarios like the ones below?

  1. Circle may in different color ( White , Black , Gray , Red)

  2. Background color may be different

  3. Different in its size

Image 1:[^]

Image 2:[^]

Image 3:[^]

Image 4:[^]

Please suggest some idea to write an algorithm that should work out on above circles.

Thanks in advance!
Posted 31-May-12 19:16pm
Updated 1-Jun-12 0:22am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

A couple of things spring to mind for such a task.
  • Create a copy of the image and convert to grey-scale
  • Run an edge-detect filter on it (this will highlight the differences in contrast at feature boundaries
  • I vaguely recall reading of an adaption to the Hough transform that allows circles to be detected, rather than the most common straight-line

Yup, Circular Hough Transform appears to be the way to go. Plug that into google, make a pot of coffee and let the 'fun' and games begin!

Hough Transform Circles[^]
Pixel86 1-Jun-12 2:26am
Hello enhzflep, The input image itself is 8 bit gray scale image and if i want to detect edge i need more contrast edges ( i enhanced the image ( Histogram equalization ) but the image still looks weird - even we could not see in our human eye )
Here you can find my enhanced images :
enhzflep 1-Jun-12 6:37am
Sorry, must've drifted off for a snooze! I'm not so sure that Histogram equalization will be needed - heck! You may-well not even need anything apart from the Circular Hough Transform itself.

Here's the kind of thing I mean by edge detection filter:

And an example of an interactive circular transform applet:

Perhaps OpenCV has something that would do the trick. Don't know, never used it.
BupeChombaDerrick 2-Jun-12 14:03pm
The only problem is that Hough Transform might not work on distorted circles or not perfectly circular object.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

This requires some more preprocessing steps. Not easy to describe in a quick answer. it is more like a full image processing project. What you have to do in my opinion is:

* apply a pepper and salt filter to get rid of the structure (median filter)

* apply a 2D edge finder (Canny for example)

* either go with a Hough Transform (possibly it will deliver better results if you can put in some assumption about the radius of the cirles)

* or assume an approximate circle location, apply radial 1D edge finders from there and apply a common circle finder algorithm to calculate the exact center

None of these steps are really trivial and it takes quite a bit of image processing know-how to solve that problem. Sorry, if that discourages you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170915.1 | Last Updated 1 Jun 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100