![]() |
IPSDK
4_1_0_2
IPSDK : Image Processing Software Development Kit
|
detects 2D lines from the extraction of local maxima in the accumulation Hough matrix computed on the input image More...
detects 2D lines from the extraction of local maxima in the accumulation Hough matrix computed on the input image
In Hough transform, lines are expressed in polar system. The equation of a line is:
with
and
constants and
and
the variables of the equation.
, expressed in pixels, corresponds to the orthogonal distance between the origin of the considered reference frame and the line, while
, expressed in radians, corresponds to the clockwise angle between the x-axis and the normal to the line (clockwise because, in image reference frame, y-axis points towards bottom).
For a given range of orientations, the family of straight lines going through a given point
in cartesian coordinates can be written as:
If we plot, for instance, the family of lines going through point located at (x=3, y=2) in a graph with
in ordinates and
in absciss, we obtain:
Now, let's add in this graph the 2 families of lines, respectively going through points (6, 3) and (12, 5):
We can see that our 3 sinusoids intersect in one single point
, that corresponds to the line going through the 3 points (we chose 3 aligned points on purpose for our example).
In conclusion, lines can be detected at positions in the graph where there are a lot of intersections between sinusoids.
Hough accumulation matrix takes advantage of the property described above.
Considering:
, and
, so that
and both extrema belong to
range (default values:
and
)
, strictly positive (default value: 1.0)The Hough transform applied to the input image with the described parameters realizes the following steps:
(deduced from the
step parameter and from the maximal
value, that equals to half the length of diagonal of the input 2D image)
value of the line going through point (x, y), and increment with the intensity value the associated pixel in the output accumulation matrixTo reduce the number of columns of the accumulation matrix, the origin of the polar reference frame has been positioned at the center of the image. Thus, the maximal absolute value of
equals to half the length of the diagonal of the image (it would have equaled to the length of the diagonal if origin had been positioned at the origin of the image)
All the parameters described above are defined through the data item HoughLinesImgParams.
Applying the algorithm on the following input image with default parameters:
We obtain the following accumulation matrix...
... where the positions of the 3 white spots correspond to the properties of the 3 lines in the input image
Once the accumulation matrix is computed, detected lines correspond to the positions of pixels where the accumulation values are the highest in the matrix. A simple extraction of the local maxima in the accumulation matrix is then enough to deduce the properties of the detected lines. This extraction of local maxima is done with the Local Extrema Extraction 2d algorithm. Through the data item HoughLinesExtractionParams, the user can vary the following parameters of the local maxima extraction:
Once these 2 steps are done, the algorithm returns both the computed accumulation matrix and the collection of properties of detected lines (rho (in pixels), theta (in radians), and associated accumulation intensity). Please note that while rho value in accumulation matrix corresponds to the distance between line and center of image, rho values in the returned collection of properties of detected lines equal to the distance between lines and the origin of the image.
Typical use cases of this algorithm are:
, ThetaNbBins=720, IntensityTreshold=180 } and HoughLinesExtractionParams { AccumThresholdType=eHATT_MaxRatio, AccumThresholdValue=0.25, LocalMaxSearchWindowRadius=75 }. Detected lines are represented in red:
, ThetaNbBins=360, IntensityTreshold=0 } and HoughLinesExtractionParams { AccumThresholdType=eHATT_MaxRatio, AccumThresholdValue=0.5, LocalMaxSearchWindowRadius=7 }.
Attribute description for algorithm :
| Name | ToolTip | Default Initializer |
|---|---|---|
| ipsdk::imaproc::attr::InGreyImg2d | [Input] 2d grey levels image | X |
| ipsdk::imaproc::attr::InOptHoughLinesImgParams | [Input Optional] Parameters for Hough lines detection algorithm | X |
| ipsdk::imaproc::attr::InOptHoughLinesExtractionParams | [Input Optional] Parameters used for step of extraction of lines in Hough lines algorithm | X |
| ipsdk::imaproc::attr::OutOptImg | [Output Optional] image for processing operation | X |
| ipsdk::imaproc::attr::OutPIHoughLines2dPpties | [Output] plan indexed collection of positions and intensities of 2d pixels | ipsdk::imaproc::fromImage (_pOutPIHoughLines2dPpties, _pInGreyImg2d) |
Global rule description for algorithm :
ipsdk::processor::If (
ipsdk::processor::isSet (_pOutOptImg),
ipsdk::imaproc::customImageProperty (_pOutOptImg,
ipsdk::imaproc::fd::houghLines2dCheckOutImgSzXEquals (_pInGreyImg2d,_pInOptHoughLinesImgParams)) &&
ipsdk::imaproc::customImageProperty (_pOutOptImg,
ipsdk::imaproc::fd::houghLines2dCheckOutImgSzYEquals (_pInGreyImg2d,_pInOptHoughLinesImgParams,_pInOptHoughLinesExtractionParams)) &&
ipsdk::imaproc::customImageProperty (_pOutOptImg,
ipsdk::imaproc::fd::houghLines2dCheckOutImgBufferType (_pInGreyImg2d)) &&
ipsdk::imaproc::matchSize (eMatchImageSizeType::eMIST_T,_pInGreyImg2d,_pOutOptImg) &&
ipsdk::imaproc::matchVolumeGeometryType (_pInGreyImg2d,_pOutOptImg) &&
ipsdk::imaproc::matchColorGeometryType (_pInGreyImg2d,_pOutOptImg) &&
ipsdk::imaproc::noInSitu (_pInGreyImg2d,_pOutOptImg),
ipsdk::processor::none ())
| IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::fd::HoughLinesResult ipsdk::imaproc::fd::houghLines2d | ( | const image::ImageConstPtr & | pInImg | ) |
wrapper function for detection of 2D lines in image using Hough algorithm
| ipsdk::processor::IPSDKBaseProcessingException | on failure |
| IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::fd::HoughLinesResult ipsdk::imaproc::fd::houghLines2d | ( | const image::ImageConstPtr & | pInImg, |
| const ipsdk::imaproc::attr::HoughLinesImgParamsConstPtr & | pHoughLinesImgParams, | ||
| const ipsdk::imaproc::attr::HoughLinesExtractionParamsConstPtr & | pHoughLinesExtractionParams | ||
| ) |
wrapper function for detection of 2D lines in image using Hough algorithm
| ipsdk::processor::IPSDKBaseProcessingException | on failure |
| IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::fd::PlanIndexedHoughLinesResult ipsdk::imaproc::fd::multiSlice_houghLines2d | ( | const image::ImageConstPtr & | pInImg | ) |
wrapper function for detection of 2D lines in image using Hough algorithm
| ipsdk::processor::IPSDKBaseProcessingException | on failure |
| IPSDKIPLFEATUREDETECTION_API ipsdk::imaproc::fd::PlanIndexedHoughLinesResult ipsdk::imaproc::fd::multiSlice_houghLines2d | ( | const image::ImageConstPtr & | pInImg, |
| const ipsdk::imaproc::attr::HoughLinesImgParamsConstPtr & | pHoughLinesImgParams, | ||
| const ipsdk::imaproc::attr::HoughLinesExtractionParamsConstPtr & | pHoughLinesExtractionParams | ||
| ) |
wrapper function for detection of 2D lines in image using Hough algorithm
| ipsdk::processor::IPSDKBaseProcessingException | on failure |
1.8.14