IPSDK 4.1.0.2
IPSDK : Image Processing Software Development Kit
Computation of accumulator matrix for extension of Hough lines detection
imagehoughLinesGradient2dImg (inGxGreyImg2d,inGyGreyImg2d)
imagehoughLinesGradient2dImg (inGxGreyImg2d,inGyGreyImg2d,houghLinesImgParams,orientationTolerance)

Detailed Description

computes the accumulator matrix used by the Hough lines detector from gradient images

detection from gradient images

This algorithm computes, from a grey level 2d image, the accumulation matrix used to detect straight lines in the input image, using the implemented extension of Hough transform based on gradient orientation.

See HoughLinesGradient2d for more information

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)
# compute images of gradient along each axis, applying a gaussian gradient with
# sigma=1
gxImg, gyImg = filter.gaussianGradient2dImg(inImg, 1.0)
# Initialize parameters for Hough lines accumulation matrix construction:
# - step for rho = 1
rhoStep = 2.0
# - range of 15 evenly spaced orientations between pi/2 and 3.pi/4 radians
thetaRange = PyIPSDK.createEvenlySpacedRange(math.pi/2, 3*math.pi/4, 15)
# only accumulate pixels of input image with intensity greater than 70
intensityThreshold = 70.0
imgParams = PyIPSDK.createHoughLinesGradientImgParams(
rhoStep, thetaRange, intensityThreshold)
# orientation tolerance = 10 degrees (pi / 18 radians)
orientationTolerance = math.pi/18
# hough circle detection computation
outImg = fd.houghLinesGradient2dImg(
gxImg, gyImg, imgParams, orientationTolerance)

Example of C++ code :

Example informations

Header file

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

Code Example

ImageConstPtr pInImg = loadTiffImageFile(inImgPath);
GradientXYImg xyImg = sobelGradient2dImg(pInImg);
// Initialize parameters for Hough lines accumulation matrix construction:
// - step for rho = 1
const ipReal64 rhoStep = 1.0;
// - range of 15 evenly spaced orientations between pi/2 and 3.pi/4 radians
const EvenlySpacedRange& thetaRange = *createEvenlySpacedRange(
M_PI / 2, 3 * M_PI / 4, 15);
// only accumulate pixels of input image with intensity greater than 10
const ipReal32 intensityThreshold = 10.0f;
const HoughLinesGradientImgParamsConstPtr pInHoughImgPrms =
rhoStep, thetaRange, intensityThreshold);
// Initialize orientation tolerance parameter to 10 degrees (pi/18 radians)
const ipReal32 orientationTolerance = static_cast<ipReal32>(M_PI / 18);
// launch Hough lines detection algorithm
const ImageConstPtr pOutImg = houghLinesGradient2dImg(
xyImg._pXGradImg,
xyImg._pYGradImg,
pInHoughImgPrms,
orientationTolerance);