HOUGH Function (PV-WAVE Extreme Advantage)
Computes the line or circle Hough transform of an image.
Usage
result = HOUGH(image[, radius][, thresh])
Input Parameters
image—A 2D or 3D array containing an image; or image, row or pixel-interleaved images.
radius—(optional) The radius of the circle for the Hough circle transform.
thresh—(optional) The threshold value for image, if image is not already a binary image. Values in image that are greater than or equal to thresh are used for the Hough transform calculation.
Returned Value
result—The Hough accumulator array.
For a 2D
image input parameter,
result is a 2D long array whose dimensions are the diagonal of the original image by the value of the
N_Angles keyword.
For a 3D
image array (an array of 2D images),
result is a 3D long array whose dimensions are the diagonal of the original image by the value of the
N_Angles keyword by the number of images in the array.
Keywords
Intleave—A scalar string indicating the type of interleaving of 3D input image arrays. Valid strings and corresponding interleaving methods are:
'pixel'—The input array arrangement is (
p,
x,
y) for
p pixel-interleaved images of
x-by-
y.
'row'—The 3D
image array arrangement is (
x,
p,
y) for
p row-interleaved images of
x-by-
y.
'image'—The 3D
image array arrangement is (
x,
y,
p) for
p image-interleaved images of
x-by-
y.
N_Angles—Specifies the number of angles (0 ≤ N_Angles ≤ 360), to quantize for the Hough accumulator array. (Default: 360)
Discussion
The line Hough transform is based on the parametric description of a line in the polar coordinate system, as in the following equation:
ρ = x cos θ + y sin θ
where ρ is the distance of the line from origin, θ is the angle of the line with respect to x-axis, and x and y are Cartesian coordinates of a pixel in image. The transformation consists of filling an accumulator array, H(ρ, θ), where ρ is calculated for each nonzero xy-pixel in image for 0 ≤ θ < 360.
The circle Hough transform is based on the description of a circle, as in the following equation:
ρ2 = (x – a)2 + (y – b)2
where ρ is the radius of the circle, a and b are the center of the circle; and x and y are the Cartesian coordinates of a pixel in image.
This equation can be broken down into the parametric equations:
a = ρ cos θ + x
b = ρ sin θ + y
The circle Hough transform consists of an accumulator array H(a, b) where a and b are computed for each nonzero xy-pixel in image for 0 ≤ θ < 360 that is filled.
Edge linking is one useful chore that the line Hough transform can perform. Local maxima in the Hough accumulator array correspond to straight lines in the transformed image. By locating maxima in the Hough array, the edge-enhanced image is placed on top of the corresponding straight lines, thus linking any unclosed edges.
The circle Hough transform, on the other hand, allows you to identify points in an image which lie on a circle of a given radius. Again, these points correspond to local maxima in the Hough accumulator array.
Example 1
The following example illustrates the use of the Hough line transform.
; Read an image.
image = IMAGE_READ(!IP_Data + 'airplane.tif')
; Compute the line Hough transform.
hough_line = HOUGH(image('pixels'), 100)
; Display the Hough transform.
TVSCL, hough_line
; Find the maximum values in the Hough line transform,
; corresponds to straight lines.
max_hough = THRESHOLD(hough_line, 0.95 * MAX(hough_line), $
/Binary)
; Display only the maximums.
TVSCL, max_hough
Example 2
This example illustrates the use of the Hough circle transform. The results of this example are shown in
Figure 10-11: Cell Images,
Figure 10-12: Circle Hough Transform, and
Figure 10-13: Hough Transform Maxima.
; Read an image.
image = IMAGE_READ(!IP_Data + 'cells.tif')
IMAGE_DISPLAY, image
; Compute the circle Hough transform at a radius of 20 pixels.
hough_circle = HOUGH(image('pixels'), 11.0, 75, /Circle)
hough_circle = NOT(BYTSCL(hough_circle))
; Display the Hough transform.
TVSCL, hough_circle
; Find the maximum values in the Hough circle transform,
; corresponds to circles in the image of radius 20.0.
max_hough = THRESHOLD(hough_circle, 0.90 * MAX(hough_circle), $
/Binary)
; Display only the maximums.
TVSCL, max_hough
See Also