IPSDK 0.2
IPSDK : Image Processing Software Development Kit
Extension of Hough lines detection based on gradient orientationSee full documentation
linesPpties,outImghoughLinesGradient2d (inGxImg,inGyImg)
linesPpties,outImghoughLinesGradient2d (inGxImg,inGyImg,houghLinesImgParams,houghLinesExtractionParams,orientationTolerance)

Detailed Description

detection of 2D lines in gradient images using extension of Hough algorithm based on gradient orientation

This algorithm detects 2D lines in an input image using an extension of Hough algorithm based on gradient orientation. Differences with the implementation of regular Hough detector HoughLines2d are:

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 210
intensityThreshold = 70.0
# orientation tolerance = 10 degrees (pi / 18 radians)
orientationTolerance = math.pi / 18
imgParams = PyIPSDK.createHoughLinesGradientImgParams(
rhoStep, thetaRange, intensityThreshold)
# Initialize parameters for extraction of lines from accumulation matrix
# to default
extractionParams = PyIPSDK.createDefaultHoughLinesExtractionParams()
# hough circle detection computation
outLines, outImg = fd.houghLinesGradient2d(
gxImg, gyImg, imgParams, extractionParams, orientationTolerance)

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLFeatureDetection/Processor/HoughLinesGradient2d/HoughLinesGradient2d.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;
createHoughLinesGradientImgParams(rhoStep, thetaRange, intensityThreshold);
// Initialize parameters for extraction of lines from accumulation matrix:
// - only keep local maxima with a value greater than 50 % of global maximum
// of the accumulation matrix
const eHoughAccumThresholdType accumThresholdType =
const ipReal64 accumThresholdValue = 0.5f;
// - only one local maximum allowed in a neighborhood of radius equalling to 10
// pixels
const ipUInt32 localMaxSearchWindowRadius = 10;
const HoughLinesExtractionParamsConstPtr pInExtractPrms =
accumThresholdType, accumThresholdValue, localMaxSearchWindowRadius);
// Initialize orientation tolerance parameter to 10 degrees (pi/18 radians)
const ipReal32 orientationTolerance = static_cast<ipReal32>(M_PI / 18);
// launch Hough lines detection algorithm
HoughLinesResult res = houghLinesGradient2d(
xyImg._pXGradImg,
xyImg._pYGradImg,
pInImgPrms,
pInExtractPrms,
orientationTolerance);
// store results in variables
const HoughLines2dPptiesConstPtr& pPlinesPpties = res._pLinesPpties;
const ImagePtr pAccumulationMatrix = res._pOutImg;