IPSDK 4.2
IPSDK : Image Processing Software Development Kit
Computation of complex accumulator matrix for Hough circles detection
realImg,imImg = houghCirclesPhaseCoded2dImg (inGxImg,inGyImg,radiusRange)

Detailed Description

computes the complex accumulator matrix used by the Hough circles detector ("gradient phase-coded" method)

This algorithm computes, from the 2 gradient images (respectively along x and y axis) of the same grey levels 2d image, the complex accumulator matrix used to detect circles in an image, using Hough algorithm ("gradient phase-coded" method).

See Hough circles detection for more information.

Below is an example of image returned by the algorithm on gradient images computed from an image of coins:

houghCirclesPhaseCoded2dImg.png

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLFeatureDetection as fd
import PyIPSDK.IPSDKIPLFiltering as filter

Code Example

# opening of input image
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# associated gradient images computation
gxImg, gyImg = filter.gaussianGradient2dImg(inImg, 1.0)
# radius range detection definition
radiusRange = PyIPSDK.createHoughCirclesRadiusRange(15, 20)
# hough circle phase coded detection computation
outRealImg, outImImg = fd.houghCirclesPhaseCoded2dImg(gxImg, gyImg, radiusRange)

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLFeatureDetection/Processor/HoughCirclesPhaseCoded2dImg/HoughCirclesPhaseCoded2dImg.h>

Code Example

#include <IPSDKImage/Geometry/ImageGeometryInstances.h>
#include <IPSDKImage/Image/Memory/MemoryImage.h>
#include <IPSDKImageFile/Tiff/TiffImageFileUtils.h>
#include <IPSDKIPL/IPSDKIPLFeatureDetection/Processor/HoughCirclesPhaseCoded2dImg/HoughCirclesPhaseCoded2dImg.h>
#include <utility>
// function returning the complex accumulation image (one image for real part
// + one image for imaginary part) used by Hough circle detector
// ("gradient phase-coded" method) applied on an input image loaded from a given
// file to detect circles of radii belonging to a given range
std::pair<ipsdk::image::ImagePtr, ipsdk::image::ImagePtr>
computeHoughCirclesPhaseCoded2dImages(
const std::string& inImgFilePath,
ipUInt64 nMinRadius,
ipUInt64 nMaxRadius)
{
// load input image from file specified by the user
ipsdk::image::ImagePtr pInImg =
// compute gradient images, in x and y
GradientXYImg gxyImg =
gaussianGradient2dImg(pInImg, 1.0f, 1.0f, createGaussianCoverage(0.997f, 2));
ImagePtr pInGxImg = gxyImg._pXGradImg;
ImagePtr pInGyImg = gxyImg._pYGradImg;
// apply Hough circles detection on gradient images
HoughCirclesComplexImg hcComplexImg =
ipsdk::imaproc::fd::houghCirclesPhaseCoded2dImg(
pInGxImg,
pInGyImg,
// return the accumulation image
return std::make_pair(hcComplexImg._pRealImg, hcComplexImg._pImImg);
}