IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Extension of Hough lines detection based on gradient orientation

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

IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::fd::HoughLinesResult ipsdk::imaproc::fd::houghLinesGradient2d (const image::ImageConstPtr &pInGxImg, const image::ImageConstPtr &pInGyImg)
 wrapper function for detection of 2D lines in gradient images using extension of Hough algorithm based on gradient orientation More...
 
IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::fd::HoughLinesResult ipsdk::imaproc::fd::houghLinesGradient2d (const image::ImageConstPtr &pInGxImg, const image::ImageConstPtr &pInGyImg, const ipsdk::imaproc::attr::HoughLinesGradientImgParamsConstPtr &pHoughLinesImgParams, const ipsdk::imaproc::attr::HoughLinesExtractionParamsConstPtr &pHoughLinesExtractionParams, const ipsdk::ipReal32 orientationTolerance)
 wrapper function for detection of 2D lines in gradient images using extension of Hough algorithm based on gradient orientation More...
 
IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::fd::PlanIndexedHoughLinesResult ipsdk::imaproc::fd::multiSlice_houghLinesGradient2d (const image::ImageConstPtr &pInGxImg, const image::ImageConstPtr &pInGyImg)
 wrapper function for detection of 2D lines in gradient images using extension of Hough algorithm based on gradient orientation More...
 
IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::fd::PlanIndexedHoughLinesResult ipsdk::imaproc::fd::multiSlice_houghLinesGradient2d (const image::ImageConstPtr &pInGxImg, const image::ImageConstPtr &pInGyImg, const ipsdk::imaproc::attr::HoughLinesGradientImgParamsConstPtr &pHoughLinesImgParams, const ipsdk::imaproc::attr::HoughLinesExtractionParamsConstPtr &pHoughLinesExtractionParams, const ipsdk::ipReal32 orientationTolerance)
 wrapper function for detection of 2D lines in gradient images using extension of Hough algorithm based on gradient orientation More...
 

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:

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InGxGreyImg2d [Input] 2d grey levels image of gradient computed along x-axis X
ipsdk::imaproc::attr::InGyGreyImg2d [Input] 2d grey levels image of gradient computed along y-axis X
ipsdk::imaproc::attr::InOptHoughLinesGradientImgParams [Input Optional] Parameters for Hough lines detection algorithm using 2 input gradient images X
ipsdk::imaproc::attr::InOptHoughLinesExtractionParams [Input Optional] Parameters used for step of extraction of lines in Hough lines algorithm X
ipsdk::imaproc::attr::InOptHoughLinesOrientationTolerance [Input Optional] Tolerance for orientation around estimated gradient direction X
ipsdk::imaproc::attr::OutOptRealImg [Output Optional] image for processing operation (data contained in image buffer are reals) X
ipsdk::imaproc::attr::OutPIHoughLines2dPpties [Output] plan indexed collection of positions and intensities of 2d pixels ipsdk::imaproc::fromImage (_pOutPIHoughLines2dPpties, _pInGxGreyImg2d)

Global Rule description

Global rule description for algorithm :
ipsdk::processor::If (
 ipsdk::processor::isSet (_pOutOptRealImg),
 ipsdk::imaproc::customImageProperty (_pOutOptRealImg,
  ipsdk::imaproc::fd::houghLines2dCheckOutImgSzXEquals (_pInGxGreyImg2d,_pInOptHoughLinesGradientImgParams)) && 
 ipsdk::imaproc::customImageProperty (_pOutOptRealImg,
  ipsdk::imaproc::fd::houghLines2dCheckOutImgSzYEquals (_pInGxGreyImg2d,_pInOptHoughLinesGradientImgParams,_pInOptHoughLinesExtractionParams)) && 
 ipsdk::imaproc::customImageProperty (_pOutOptRealImg,
  ipsdk::imaproc::fd::houghLines2dCheckOutImgBufferType (_pInGxGreyImg2d)) && 
 ipsdk::imaproc::matchSize (eMatchImageSizeType::eMIST_T,_pInGxGreyImg2d,_pOutOptRealImg) && 
 ipsdk::imaproc::matchVolumeGeometryType (_pInGxGreyImg2d,_pOutOptRealImg) && 
 ipsdk::imaproc::matchColorGeometryType (_pInGxGreyImg2d,_pOutOptRealImg) && 
 ipsdk::imaproc::noInSitu (_pInGxGreyImg2d,_pOutOptRealImg),
 ipsdk::processor::none ())

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

Associated library

IPSDKIPLFeatureDetection

Header file

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;
See also
HoughLinesGradient2dLvl1
HoughLinesGradient2dLvl2

Function Documentation

◆ houghLinesGradient2d() [1/2]

IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::fd::HoughLinesResult ipsdk::imaproc::fd::houghLinesGradient2d ( const image::ImageConstPtr pInGxImg,
const image::ImageConstPtr pInGyImg 
)

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

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ houghLinesGradient2d() [2/2]

IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::fd::HoughLinesResult ipsdk::imaproc::fd::houghLinesGradient2d ( const image::ImageConstPtr pInGxImg,
const image::ImageConstPtr pInGyImg,
const ipsdk::imaproc::attr::HoughLinesGradientImgParamsConstPtr pHoughLinesImgParams,
const ipsdk::imaproc::attr::HoughLinesExtractionParamsConstPtr pHoughLinesExtractionParams,
const ipsdk::ipReal32  orientationTolerance 
)

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

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ multiSlice_houghLinesGradient2d() [1/2]

IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::fd::PlanIndexedHoughLinesResult ipsdk::imaproc::fd::multiSlice_houghLinesGradient2d ( const image::ImageConstPtr pInGxImg,
const image::ImageConstPtr pInGyImg 
)

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

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ multiSlice_houghLinesGradient2d() [2/2]

IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::fd::PlanIndexedHoughLinesResult ipsdk::imaproc::fd::multiSlice_houghLinesGradient2d ( const image::ImageConstPtr pInGxImg,
const image::ImageConstPtr pInGyImg,
const ipsdk::imaproc::attr::HoughLinesGradientImgParamsConstPtr pHoughLinesImgParams,
const ipsdk::imaproc::attr::HoughLinesExtractionParamsConstPtr pHoughLinesExtractionParams,
const ipsdk::ipReal32  orientationTolerance 
)

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

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure