Automatic circle detection is an important element of many image processing algorithms. Traditionally the Hough transform has been used to find circular objects in images but more modern approaches that make use of heuristic optimisation techniques have been developed. These are often used in large complex images where the presence of noise or limited computational resources make the Hough transform impractical. Previous research on the use of the Harmony Search (HS) in circle detection showed that HS is an attractive alternative to many of the modern circle detectors based on heuristic optimisers like genetic algorithms and simulated annealing. We propose improvements to this work that enables our algorithm to robustly find multiple circles in larger data sets and still work on realistic images that are heavily corrupted by noisy edges.
Circle detection is a key element in the larger field of automatic extraction and identification of geometric shapes from digital images. The ability to identify and extract shapes from images has many applications in industry and agriculture. This is because simple geometric shapes are common in man-made environments and are often used in symbols that only have meaning when properly identified.
Circle and ellipse are particularly common shapes to identify due to their application in biological cell tracking, automated mechanical parts inspection, and biometrics (iris detection). Circle detection is traditionally done using the circle Hough transform (CHT) [
With the dramatic increase in computational power, more researchers have begun investigating metaheuristic optimisation algorithms as possible approaches to more robust and accurate circle detection. These algorithms are often biologically inspired like the genetic algorithm and the particle swarm optimisation algorithm. They are usually computationally expensive but have the advantage of not making any assumptions about the objective function or the amount and type of noise that may be present. This usually implies more robust and accurate performance on noisy or ambiguous data.
Both genetic algorithms and particle swarm optimisation algorithms have been successfully used in circle detection along with other metaheuristics like simulated annealing and bacterial foraging optimisation algorithm [
Harmony Search is a musical improvisation-inspired metaheuristic optimisation method originally developed for the design of pipeline network systems and published in 2001 [
In this section, we introduce circle detection in digital images and give an overview of the circle Hough transform (CHT). Being the most popular method of circle detection, the CHT gives us a starting point to investigate circle detection methods with specific focus on their limitations and accuracy under challenging conditions.
We pay specific attention to circle detection methods that interpret the problem as a fitness function that has to be optimised and that make use of metaheuristics to solve the optimisation problem. We then introduce Harmony Search (HS) as a heuristic optimiser and mention some of the variants of the original algorithm that attempt to address the limitations of traditional HS.
As previously mentioned, the classical way to do circle detection is using the circular Hough transform. This method assumes that the edge pixels of the image have already been identified using one of the many edge detection methods, for example, the Canny edge detector [
Consider a circle in 2D space represented by the equation
Though this simple approach is somewhat robust to noise and occlusion, the main limitation is in the computational and space requirements. As the 3D accumulator matrix grows cubically with the size of the image, the memory required to store this matrix and the time spent creating it quickly become prohibitive. This is especially true when circle location accuracy demands that the parameter space be quantised into accumulator cells that are as small as possible or when the space needs to be enlarged to beyond the size of the image to allow for partial circle detection that may have centres that fall outside the image bounds. In Figure
An example of the CHT detecting multiple circles in an image. The largest and second-largest maxima in the accumulator matrix is labelled as
In order to address some of the limitations of the CHT, researchers have extended and adapted the CHT in various ways to improve the accuracy but mainly to improve the performance and improve the large memory requirements that classical CHT has. Some examples of CHT extensions include the randomised Hough transform [
More recently researchers have also begun to apply evolutionary algorithms to circle detection. Examples include genetic algorithm based approaches [
The (HS) algorithm was inspired by the way musicians collectively and cooperatively improve harmonies in certain genres of music, especially Jazz [
Consider the analogy of a Jazz trio during an improvisation session. Each member of the trio plays a note on their instrument selected from a limited range of notes which may be different for each member. Together the three notes form a harmony that may or may not be pleasing to the audience (or the trio itself). For the sake of this analogy, the aim of the trio is to find the 3-note harmony that is most pleasing to the audience.
In our analogy, the 3-note harmony is the solution to an optimisation problem of finding the most pleasing harmony as judged by the audience. The search space of possible solutions is 3-dimensional in this case and is bounded by the notes playable by each musician. For example, if each musician could only choose from 5 different notes, the search of all possible solutions would only contain
Improvisation of new harmonies is an iterative process involving each member of the trio choosing a note to play based on what resulted in pleasing harmonies during previous iterations. In this way, the improvisation process uses a memory of good solutions that is constantly updated and improved with new entries as better harmonies are discovered. The improvisation process continues until either a harmony of sufficiently high quality is produced or the maximum number of iterations has been reached.
This HS analogy is summarised as follows. The performance of HS is controlled by four parameters: the harmony memory size (HMS), the harmony memory consideration rate (HMCR), the fret width (FW), and the maximum iterations (NI). The HMS is the number of
an upper bound (UB) and lower bound (LB) for each dimension of the from a uniform distribution is also required. ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (
Algorithm
The main contribution of this work is based on applying a variation of HS to the circle detection problem. This approach was pioneered by Cuevas et al. and their work forms the basis of our proposed algorithm [
In their work, Cuevas et al. describe circles in an image by the well-known second-degree equation introduced in Section
The Canny edge detector is used to extract the edge map.
Detection of circles in the image is interpreted as an optimisation problem with each edge pixel in the edge map considered to be part of the search space of possible solutions. A candidate solution, that is, a circle in the image, is represented as three distinct edge points since 3 points on a plane are required to define a unique circle. Candidate solutions are scored using a fitness function defined as the number of pixels in the edge map that support the circle described by the 3 points in the candidate solution. The more edge pixels that lie on the circle described by the candidate solution, the higher its fitness.
Once the circle detection problem is defined as optimisation of a finite search space and an appropriate fitness function is provided to compare candidate solutions, HS can be used to find the best solution in the search space. Since the search space is simply a vector of all the edge pixels, candidate solutions can be coded in the HM as three indices into the vector of edge points. Let
All that remains to be defined is the fitness function. Let
With the circle centre and radius calculated, we can generate a list of pixels that lie on the perimeter of that circle
In this implementation, the detector will only find one circle but Cuevas et al. expand this idea to allow for multiple circle detection by removing any circles found from the edge map and then iteratively rerunning the HS optimiser until no more circles can be found of sufficient quality or until some threshold has been reached. For further details as well as experimental results from this circle detector, the reader is referred to the original publication by Cuevas et al. [
Before describing the proposed algorithm that forms the main contribution of this work, it is valuable to investigate the size and shape of the search space that HS optimises over. HS was designed to be robust enough to optimise over almost any kind of search space even those that are highly discontinuous, multimodal, and not differentiable. However, like most heuristic optimisers, HS relies to some extent on the existence of a
Illustrating local minima and basins of attraction in the Ackley function.
Even on a small 1-megapixel image, the number of edge points can easily be in in the order of 10,000. Since any three of these points can potentially form a circle, the size of the search space that HS optimises over is
Consider the way that a solution vector is defined from the list of edge pixels. Instead of storing the pixel location in, for example, Cartesian coordinates, a solution vector is three indices into the list of edge pixels which inherently discards the relative distance information between pixels. This decision was made for practical reasons since a more complicated encoding of the solution would mean that the HS improvisation step would need to be adapted so that improvisation based on previous good solutions would still likely result in better ones. However, one result of this encoding is that edge pixels that are far from each other (large difference between index values) in the list of edge pixels may be close together on the image plane in a Euclidean sense. This means that edge pixels that are neighbours and therefore likely belong to the same circle are not neighbours in the search space. Consider the example of Figure
Edge pixels can be close together on the image plane and belong to the same circle but may be far apart in the list of edge pixels that define the search space.
Part of the edge list from an example image is displayed as an edge map in Figure
This is a serious problem for the HS algorithm as it means that a basin of attraction in the search space will not necessarily contain the edge pixels required to find the circle that it may represent. Also, small changes to a solution in the HM (pitch adjustment in HS) may cause edge pixels from a completely different part of the image to be included in a new improvisation that should be based on an already discovered circle.
In small images (few edge pixels), this limitation in the encoding of the HM may simply cause slow convergence while still resulting in correct identified circle. However, in our experiments, this approach fails on large complex images that contain many thousands of edge pixels and potentially dozens of circles that we aim to identify. The edge map in Figure
This complex edge map was constructed from a
We propose two main changes to the approach discussed in the previous section. Firstly, the size of the search space needs to be limited and it needs to be organised so that basins of attraction surround most local optima and that neighbouring solutions are likely to belong to the same circle. Secondly, instead of using the standard HS algorithm, we use one of the modern variants (see Section
In order to both limit the size of the search space and improve the shape, we sort the list of edge pixels into connected components and focus our search around a single neighbourhood of edge pixels that are 8-connected neighbours on the image plane. Pixels are 8-connected when they touch horizontally, vertically, or diagonally on the image plane. We call these connected collections of edge pixels
The edge map shown here has been organised into connected neighbourhoods called ribbons.
Because we use the Canny edge detector to build our edge map, the edges that are connected are already grouped during the hysteresis thresholding step (see [
We also split long ribbons into smaller ones so that multiple circles may be found on long connected edges. Given that our search space now only consists of short simple ribbons, we can simplify the search space further by defining the circle as only two points and implying the location of the third. Given two points on a single ribbon, we make the assumption that these points represent the start and end points of a circle arc that forms part of the ribbon. The third point required to identify the circle is implied as being half way between the start and end point on the ribbon. This significantly reduces the size of the search space and simplifies the optimisation problem by changing the 3-dimensional problem into a 2-dimensional one.
In addition to the previous modification of the search space, we optionally normalise the fitness function slightly to favour larger circles. Normally the fitness function is normalised by dividing the number of edge pixels that fall on the candidate circle by the circle circumference as defined in (
The minimum and maximum circles sizes are user parameters that allow the algorithm to focus only on a specific range of circle sizes and help to filter out circles that could be considered as false positives. In our alternate definition of the fitness function, we normalise by the circumference of the maximum circle size so that
In addition to simplifying the search space, we also propose the use of a modern variant of HS that is specifically designed to be more robust when the search space is discrete and discontinuous, for example, labelling problems and integer optimisation. The CHS algorithm is based on HS and was designed to solve the labelling problem associated with the blind deconvolution problem of binary images [
Our proposed detection method can be summarised with the following steps: Use the Canny edge detector to extract the edge map from the source image and sort the edges into connected components called ribbons. Filter out ribbons that are too short and split ribbons that are too long to both limit the search space and ensure that multiple circles on long continuous edges are not missed. Use the adapted CHS algorithm to find the best candidate circle on each ribbon in the filtered list.
We tested our method using both synthetic images and images captured using normal consumer grade cameras of real objects. Using synthetic images, we can generate scenes with an arbitrary amount of noise and can partially occlude any matches by an arbitrary amount. This allows us to test the robustness and accuracy of the algorithm in a more quantitative way rather than using images captured from real scenes. Conversely, the nonsynthetic images are more realistic and allow us to show potential results in practical applications.
In Figure
We use this synthetic test image to test the robustness of the proposed circle detector under various conditions. The red circles in (b) indicate the solutions found by the detector.
This is the edge map of the synthetic image of Figure
In Figure
Gaussian noise is added to the synthetic test images.
It is worth noting that, even with 40% Gaussian noise added, most of the circles are still identified correctly. Part of the reason for this robustness is the relatively low quality threshold which is indicative of found circles (see (
We used a selection of images from the Caltech Computer Vision Group archive [
Various test images that highlight different aspects of the circle detector. Figures (b), (c), and (d) come from the image archive of the Computer Vision Group at Caltech [
Figure
Our original intention with this work was to address some limitations of the original work done by Cuevas et al. [
In this example, the circle detector is used to count fruit in order to estimate yield.
Another example of our circle detector used to count fruit.
In another practical example, the aim is to count cells or other microscopic particles in an image captured from a microscope. In this example (Figure
In this example, the circle detector is used to count cells in an image captured from a microscope.
Based on the original research by Cuevas et al. [
We showed through various examples that our approach leads to accurate results that are robust to noise as well as incomplete or imperfect circles. We also highlighted some practical applications that demonstrate our detector’s ability to find thousands of circles in images that will be challenging to find multiple circles using the approach used by Cuevas et al. [
The main aim of this paper is to build on the research done by Cuevas et al. [
Another less complex improvement involves regularising the fitness function of (
The fitness function could also be improved by taking into account the gradient of the edges when deciding which edges would be considered evidence for a particular candidate circle. One would expect that an edge that forms part of a real circle would have a similar gradient as the candidate circle at the point of overlap and if the gradient differs by too much the edge can safely be rejected as evidence of a circle.
The author declares that there are no conflicts of interest regarding the publication of this paper.
This work was partially funded through a grant from the New Zealand Ministry of Business Innovation and Employment under the research grant, Optimum N Nitrogen Sensing and Management (Contract no. CONT29854BITR_LVL).