IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

detects circles in image using Hough algorithm More...

IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::attr::HoughCircles2dPptiesPtr ipsdk::imaproc::fd::houghCircles2d (const image::ImageConstPtr &pInImg, const ipsdk::imaproc::attr::HoughCirclesRadiusRangeConstPtr &pRadiusRange)
 wrapper function for detection of circles in image using Hough algorithm This wrapper must be used with mono slice (sizeZ=sizeC=sizeT=1) input images More...
 
IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::attr::HoughCircles2dPptiesPtr ipsdk::imaproc::fd::houghCircles2d (const image::ImageConstPtr &pInImg, const ipsdk::imaproc::attr::HoughCirclesRadiusRangeConstPtr &pRadiusRange, const ipsdk::imaproc::attr::eCircleIntensityType &eCircleIntensityType, const ipUInt32 nbMaxPtsPerCircle, const ipsdk::imaproc::attr::AccumIntensityThresholdConstPtr &pAccumIntensityThreshold, const ipsdk::imaproc::attr::RemoveTooCloseCirclesParamsConstPtr &pRemoveTooCloseCirclesParams)
 wrapper function for detection of circles in image using Hough algorithm This wrapper must be used with mono slice (sizeZ=sizeC=sizeT=1) input images More...
 
IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::attr::HoughCircles2dPptiesPtr ipsdk::imaproc::fd::houghCircles2d (const image::ImageConstPtr &pInGxImg, const image::ImageConstPtr &pInGyImg, const ipsdk::imaproc::attr::HoughCirclesRadiusRangeConstPtr &pRadiusRange)
 wrapper function for detection of circles in image using Hough algorithm This wrapper must be used with mono slice (sizeZ=sizeC=sizeT=1) input images More...
 
IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::attr::HoughCircles2dPptiesPtr ipsdk::imaproc::fd::houghCircles2d (const image::ImageConstPtr &pInGxImg, const image::ImageConstPtr &pInGyImg, const ipsdk::imaproc::attr::HoughCirclesRadiusRangeConstPtr &pRadiusRange, const ipsdk::imaproc::attr::eHoughCircles2dAlgoMethod &method, const ipsdk::imaproc::attr::eCircleIntensityType &eCircleIntensityType, const ipReal64 maxAngleWithGradDir, const ipUInt32 nbMaxPtsPerCircle, const ipsdk::imaproc::attr::AccumIntensityThresholdConstPtr &pAccumIntensityThreshold, const ipsdk::imaproc::attr::RemoveTooCloseCirclesParamsConstPtr &pRemoveTooCloseCirclesParams, const image::ImagePtr &pOutImg1, const image::ImagePtr &pOutImg2)
 wrapper function for detection of circles in image using Hough algorithm This wrapper must be used with mono slice (sizeZ=sizeC=sizeT=1) input images More...
 
IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::attr::PlanIndexedHoughCircles2dPptiesPtr ipsdk::imaproc::fd::multiSlice_houghCircles2d (const image::ImageConstPtr &pInImg, const attr::HoughCirclesRadiusRangeConstPtr &pRadiusRange)
 multi slice version of wrapper function for detection of circles in image using Hough algorithm This wrapper can be used with multi slices input images More...
 
IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::attr::PlanIndexedHoughCircles2dPptiesPtr ipsdk::imaproc::fd::multiSlice_houghCircles2d (const image::ImageConstPtr &pInImg, const attr::HoughCirclesRadiusRangeConstPtr &pRadiusRange, const attr::eCircleIntensityType &eCircleIntensityType, const ipUInt32 nbMaxPtsPerCircle, const attr::AccumIntensityThresholdConstPtr &pAccumIntensityThreshold, const attr::RemoveTooCloseCirclesParamsConstPtr &pRemoveTooCloseCirclesParams)
 multi slice version of wrapper function for detection of circles in image using Hough algorithm This wrapper can be used with multi slices input images More...
 
IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::attr::PlanIndexedHoughCircles2dPptiesPtr ipsdk::imaproc::fd::multiSlice_houghCircles2d (const image::ImageConstPtr &pInGxImg, const image::ImageConstPtr &pInGyImg, const attr::HoughCirclesRadiusRangeConstPtr &pRadiusRange)
 multi slice version of wrapper function for detection of circles in image using Hough algorithm This wrapper can be used with multi slices input images More...
 
IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::attr::PlanIndexedHoughCircles2dPptiesPtr ipsdk::imaproc::fd::multiSlice_houghCircles2d (const image::ImageConstPtr &pInGxImg, const image::ImageConstPtr &pInGyImg, const attr::HoughCirclesRadiusRangeConstPtr &pRadiusRange, const attr::eHoughCircles2dAlgoMethod &method, const attr::eCircleIntensityType &eCircleIntensityType, const ipReal64 maxAngleWithGradDir, const ipUInt32 nbMaxPtsPerCircle, const attr::AccumIntensityThresholdConstPtr &pAccumIntensityThreshold, const attr::RemoveTooCloseCirclesParamsConstPtr &pRemoveTooCloseCirclesParams, const image::ImagePtr &pOutImg1, const image::ImagePtr &pOutImg2)
 multi slice version of wrapper function for detection of circles in image using Hough algorithm This wrapper can be used with multi slices input images More...
 

Detailed Description

detects circles in image using Hough algorithm

This algorithm uses a variant of the Standard Circle Hough Transform to detect circles in a 2d grey levels image (or in a sequence of 2d grey levels images). Below is shown an example of application of Hough circles detector on an image of coins (circles detected by the algorithm are drawn in red on the right image; used range of radii equals to [10, 20]; all other input parameters are left to their default values):

houghCircles2d.png

1- Background: the Standard Circle Hough Transform

Standard Circle Hough Transform was inspired from Standard Line Hough Transform ([1]). Considering the user wants to detect circles with radii between minRadius and maxRadius, it works as follows:

a- pre-process the image by applying an edge extraction (Canny edge extraction, for instance)

b- create a 3D parameter space (also called accumulator matrix, or Hough space, or voting space). The 2 first dimensions correspond to the positions of the centers of the circles, and the 3rd dimension corresponds to the radii of the circles. Initialize the content of this 3D image with zeros.

c- for each pixel $(x_e, y_e)$ of the edge(s) detected in the input image in a), and for each radius $r$ in $[minRadius;maxRadius]$, increment pixels of coordinates $(x, y, r)$ in the 3D parameter space that satisfy the equation $(x-x_e)^2+(y-y_e)^2=r^2$.

d- extract local maxima in the 3D parameter space; they should correspond to the circles present in the original image

This algorithm has several limitations; in particular:

2- Modifications of the Standard Circle Hough Transform for our implementation

The current implementation makes use of modifications described in [2]. Here is a recall of the main modifications from the standard version:

3- Steps of the current implementation:

The current implementation executes the following steps:

a- compute the gradient images if necessary, respectively along x and y axis

b- compute the Hough image (or images, if the "phase coded" method has been chosen)

c- extract the circles centers from the Hough image(s). The way to proceed depends on the selected method:

d- compute the radius associated to each detected circle:

e- for each couple of too close circles, remove the one with the lower accumulation intensity in Hough image

4- How to use the input parameters of the algorithm

As a general rule, more the user will restrict the search parameters, the faster the algorithm will execute and the more accurate the result will be. Here are some details for each parameter:

nbMaxPtsPerCircle_example.png

5- Limitations of the current implementation:

As only one radius is associated to each circle center position, the current implementation does not allow to detect concentric circles.

References

[1] Hough transform. (2015, June 17). In Wikipedia, The Free Encyclopedia. Retrieved 15:42, June 29, 2015, from https://en.wikipedia.org/w/index.php?title=Hough_transform&oldid=667291656
[2] T.J. Atherton and D.J. Kerbyson, Size invariant circle detection, Image and Vision Computing 17 (1999) 795–803
[3] C. Kimme, D. Ballard, J. Sklansky, Finding circles by an array of accumulators, Proc. ACM 18 (1975) 120–122

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InOptGreyImg2d [Input Optional] grey-levels 2d image X
ipsdk::imaproc::attr::InOptGxGreyImg2d [Input Optional] grey-levels 2d image of gradient computed along x-axis X
ipsdk::imaproc::attr::InOptGyGreyImg2d [Input Optional] grey-levels 2d image of gradient computed along y-axis X
ipsdk::imaproc::attr::InOptHoughCircles2dAlgoMethod [Input Optional] Hough circles 2d detector method X
ipsdk::imaproc::attr::InOptCircleIntensityType [Input Optional] circle intensity type for detection algorithms X
ipsdk::imaproc::attr::InOptMaxAngleWithGradDir [Input Optional] maximum angle with gradient direction, in radians X
ipsdk::imaproc::attr::InOptNbMaxPtsPerCircle [Input Optional] maximum number of points per circle X
ipsdk::imaproc::attr::InOptHoughCirclesRadiusRange [Input Optional] range of radius of circles to detect using Hough circles algorithm X
ipsdk::imaproc::attr::InOptAccumIntensityThreshold [Input Optional] threshold on accumulation intensities for local maxima extraction X
ipsdk::imaproc::attr::InOptRemoveTooCloseCirclesParams [Input Optional] parameters of "removing too close circles" phasis in Hough circles detection X
ipsdk::imaproc::attr::OutOptRealImg1 [Output Optional] image for processing operation (data contained in image buffer are reals) X
ipsdk::imaproc::attr::OutOptRealImg2 [Output Optional] image for processing operation (data contained in image buffer are reals) X
ipsdk::imaproc::attr::OutOptGxGreyImg2d [Output Optional] grey-levels 2d image of gradient computed along x-axis X
ipsdk::imaproc::attr::OutOptGyGreyImg2d [Output Optional] grey-levels 2d image of gradient computed along y-axis X
ipsdk::imaproc::attr::OutPIHoughCircles2dPpties [Output] plan indexed collection of properties of circles detected by Hough algorithm ipsdk::processor::allocate (_pOutPIHoughCircles2dPpties)

Global Rule description

Global rule description for algorithm :
(ipsdk::processor::If (
  ipsdk::processor::isSet (_pInOptGreyImg2d),
  ipsdk::processor::Not (
   ipsdk::processor::isSet (_pInOptGxGreyImg2d)) && 
  ipsdk::processor::Not (
   ipsdk::processor::isSet (_pInOptGyGreyImg2d)) && ipsdk::imaproc::matchSize<ipsdk::imaproc::attr::HoughCirclesRadiusRange::MaxRadius>(ipsdk::imaproc::eMatchImageSizeType::eMIST_2d,ipsdk::imaproc::eMatchImageSizeScale::eMISS_HalfSize,_pInOptGreyImg2d,_pInOptHoughCirclesRadiusRange) && 
  ipsdk::processor::If (
   ipsdk::processor::isSet (_pOutOptGxGreyImg2d),
   ipsdk::imaproc::matchSize (_pInOptGreyImg2d,_pOutOptGxGreyImg2d)) && 
  ipsdk::processor::If (
   ipsdk::processor::isSet (_pOutOptGyGreyImg2d),
   ipsdk::imaproc::matchSize (_pInOptGreyImg2d,_pOutOptGyGreyImg2d)) && 
  ipsdk::processor::ifIsSet (_pOutOptRealImg1,
   ipsdk::imaproc::matchSize (_pInOptGreyImg2d,_pOutOptRealImg1)) && 
  ipsdk::processor::ifIsSet (_pOutOptRealImg2,
   ipsdk::imaproc::matchSize (_pInOptGreyImg2d,_pOutOptRealImg2)),
  ipsdk::processor::isSet (_pInOptGxGreyImg2d) && 
  ipsdk::processor::isSet (_pInOptGyGreyImg2d) && 
  ipsdk::imaproc::matchSizeAndType (_pInOptGxGreyImg2d,_pInOptGyGreyImg2d) && ipsdk::imaproc::matchSize<ipsdk::imaproc::attr::HoughCirclesRadiusRange::MaxRadius>(ipsdk::imaproc::eMatchImageSizeType::eMIST_2d,ipsdk::imaproc::eMatchImageSizeScale::eMISS_HalfSize,_pInOptGxGreyImg2d,_pInOptHoughCirclesRadiusRange) && 
  ipsdk::processor::ifIsSet (_pOutOptRealImg1,
   ipsdk::imaproc::matchSize (_pInOptGxGreyImg2d,_pOutOptRealImg1)) && 
  ipsdk::processor::ifIsSet (_pOutOptRealImg2,
   ipsdk::imaproc::matchSize (_pInOptGxGreyImg2d,_pOutOptRealImg2))))

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLFeatureDetection as fd

Code Example

# opening of input image
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# radius range detection definition
radiusRange = PyIPSDK.createHoughCirclesRadiusRange(15, 20)
# hough circle detection computation
outHoughCircles2dPpties = fd.houghCircles2d(inImg, radiusRange)
# retrieve coordinates of first detected circle (associated to maximum intensity)
maxHoughCircles2dPpty = PyIPSDK.toPyDict(outHoughCircles2dPpties)['Coll'][0]
print("Circle with maximum accumulated intensity " + str(maxHoughCircles2dPpty['AccumIntensity'] ) + " found on coordinates x=" + str(maxHoughCircles2dPpty['X'] ) + " and y=" + str(maxHoughCircles2dPpty['Y'] ) + " and with radius=" + str(maxHoughCircles2dPpty['Radius'] ))

Example of C++ code :

Example informations

Associated library

IPSDKIPLFeatureDetection

Header file

Code Example

// function returning the collection of circles with radii in a given range
// detected by Hough algorithm in the image loaded from a given TIFF file
boost::shared_ptr<imaproc::attr::HoughCircles2dPpties>
detectCircles(
const std::string& inImgFilePath,
ipUInt64 nMinRadius,
ipUInt64 nMaxRadius)
{
// load input image from file specified by the user
// apply Hough circles detection
const boost::shared_ptr<imaproc::attr::HoughCircles2dPpties> pCircles =
pInImg,
// return the collection of detected circles
return pCircles;
}
See also
HoughCircles2dLvl1
HoughCircles2dLvl2

Function Documentation

◆ houghCircles2d() [1/4]

wrapper function for detection of circles in image using Hough algorithm This wrapper must be used with mono slice (sizeZ=sizeC=sizeT=1) input images

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ multiSlice_houghCircles2d() [1/4]

IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::attr::PlanIndexedHoughCircles2dPptiesPtr ipsdk::imaproc::fd::multiSlice_houghCircles2d ( const image::ImageConstPtr pInImg,
const attr::HoughCirclesRadiusRangeConstPtr pRadiusRange 
)

multi slice version of wrapper function for detection of circles in image using Hough algorithm This wrapper can be used with multi slices input images

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ houghCircles2d() [2/4]

IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::attr::HoughCircles2dPptiesPtr ipsdk::imaproc::fd::houghCircles2d ( const image::ImageConstPtr pInImg,
const ipsdk::imaproc::attr::HoughCirclesRadiusRangeConstPtr pRadiusRange,
const ipsdk::imaproc::attr::eCircleIntensityType eCircleIntensityType,
const ipUInt32  nbMaxPtsPerCircle,
const ipsdk::imaproc::attr::AccumIntensityThresholdConstPtr pAccumIntensityThreshold,
const ipsdk::imaproc::attr::RemoveTooCloseCirclesParamsConstPtr pRemoveTooCloseCirclesParams 
)

wrapper function for detection of circles in image using Hough algorithm This wrapper must be used with mono slice (sizeZ=sizeC=sizeT=1) input images

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ houghCircles2d() [3/4]

wrapper function for detection of circles in image using Hough algorithm This wrapper must be used with mono slice (sizeZ=sizeC=sizeT=1) input images

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ houghCircles2d() [4/4]

IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::attr::HoughCircles2dPptiesPtr ipsdk::imaproc::fd::houghCircles2d ( const image::ImageConstPtr pInGxImg,
const image::ImageConstPtr pInGyImg,
const ipsdk::imaproc::attr::HoughCirclesRadiusRangeConstPtr pRadiusRange,
const ipsdk::imaproc::attr::eHoughCircles2dAlgoMethod method,
const ipsdk::imaproc::attr::eCircleIntensityType eCircleIntensityType,
const ipReal64  maxAngleWithGradDir,
const ipUInt32  nbMaxPtsPerCircle,
const ipsdk::imaproc::attr::AccumIntensityThresholdConstPtr pAccumIntensityThreshold,
const ipsdk::imaproc::attr::RemoveTooCloseCirclesParamsConstPtr pRemoveTooCloseCirclesParams,
const image::ImagePtr pOutImg1,
const image::ImagePtr pOutImg2 
)

wrapper function for detection of circles in image using Hough algorithm This wrapper must be used with mono slice (sizeZ=sizeC=sizeT=1) input images

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ multiSlice_houghCircles2d() [2/4]

IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::attr::PlanIndexedHoughCircles2dPptiesPtr ipsdk::imaproc::fd::multiSlice_houghCircles2d ( const image::ImageConstPtr pInImg,
const attr::HoughCirclesRadiusRangeConstPtr pRadiusRange,
const attr::eCircleIntensityType eCircleIntensityType,
const ipUInt32  nbMaxPtsPerCircle,
const attr::AccumIntensityThresholdConstPtr pAccumIntensityThreshold,
const attr::RemoveTooCloseCirclesParamsConstPtr pRemoveTooCloseCirclesParams 
)

multi slice version of wrapper function for detection of circles in image using Hough algorithm This wrapper can be used with multi slices input images

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ multiSlice_houghCircles2d() [3/4]

IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::attr::PlanIndexedHoughCircles2dPptiesPtr ipsdk::imaproc::fd::multiSlice_houghCircles2d ( const image::ImageConstPtr pInGxImg,
const image::ImageConstPtr pInGyImg,
const attr::HoughCirclesRadiusRangeConstPtr pRadiusRange 
)

multi slice version of wrapper function for detection of circles in image using Hough algorithm This wrapper can be used with multi slices input images

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ multiSlice_houghCircles2d() [4/4]

IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::attr::PlanIndexedHoughCircles2dPptiesPtr ipsdk::imaproc::fd::multiSlice_houghCircles2d ( const image::ImageConstPtr pInGxImg,
const image::ImageConstPtr pInGyImg,
const attr::HoughCirclesRadiusRangeConstPtr pRadiusRange,
const attr::eHoughCircles2dAlgoMethod method,
const attr::eCircleIntensityType eCircleIntensityType,
const ipReal64  maxAngleWithGradDir,
const ipUInt32  nbMaxPtsPerCircle,
const attr::AccumIntensityThresholdConstPtr pAccumIntensityThreshold,
const attr::RemoveTooCloseCirclesParamsConstPtr pRemoveTooCloseCirclesParams,
const image::ImagePtr pOutImg1,
const image::ImagePtr pOutImg2 
)

multi slice version of wrapper function for detection of circles in image using Hough algorithm This wrapper can be used with multi slices input images

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure