java.lang.Object
imagingbook.common.hough.HoughTransformLines
- All Implemented Interfaces:
ProgressReporter
This class implements the "classic" Hough Transform for straight lines. This implementation improves the algorithm
described in the textbook in the way the accumulator is updated. Here, the quantity 1 is not added to a single
accumulator cell but gets distributed over two neighboring (radial) cells to reduce aliasing effects. Thus we
accumulate non-integer values and therefore the various accumulators are of type float[][]
. See Sec. 12.2 of
[1] for additional details.
[1] W. Burger, M.J. Burge, Digital Image Processing – An Algorithmic Introduction, 3rd ed, Springer (2022).
- Version:
- 2022/09/10 removed ImageJ progress reporting
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionConstructor, creates a new Hough transform from the binary image.HoughTransformLines
(Pnt2d[] points, int width, int height, HoughTransformLines.Parameters params) Constructor, creates a new Hough transform from a sequence of 2D points. -
Method Summary
Modifier and TypeMethodDescriptiondouble
angleFromIndex
(int ai) Calculates the actual angle (in radians) for angle indexai
float[][]
Returns the accumulator as a 2D float-array.float[][]
Returns the extended accumulator as a 2D float-array.Creates and returns an image of the 2D accumulator array.Creates and returns an image of the extended 2D accumulator array, produced by adding a vertically mirrored copy of the accumulator to its right end.float[][]
Returns the local maximum values of the accumulator as a 2D float-array (all non-maximum elements are set to zero).Creates and returns an image of the local maxima of the 2D accumulator array.getLines
(int amin, int maxLines) Finds and returns the parameters of the strongest lines with a specified min.double
Returns a value in [0,1) indicating to which degree this task is complete.double
getXref()
Returns the reference points x-coordinate.double
getYref()
Returns the reference points y-coordinate.double
radiusFromIndex
(int ri) Calculates the actual radius for radius index ri.double
radiusToIndex
(double rad)
-
Constructor Details
-
HoughTransformLines
Constructor, creates a new Hough transform from the binary image.- Parameters:
I
- input image, relevant (edge) points have pixel values greater 0.params
- parameter object.
-
HoughTransformLines
-
HoughTransformLines
public HoughTransformLines(Pnt2d[] points, int width, int height, HoughTransformLines.Parameters params) Constructor, creates a new Hough transform from a sequence of 2D points. Parameters M, N are only used to specify the reference point (usually at the center of the image). Use this constructor if the relevant image points are collected separately.- Parameters:
points
- an array of 2D points.width
- width of the corresponding image plane.height
- height of the corresponding image plane.params
- parameter object.
-
-
Method Details
-
getLines
Finds and returns the parameters of the strongest lines with a specified min. pixel count. All objects in the returned array are valid, but the array may be empty. Note: Could perhaps be implemented more efficiently with insert-sort.- Parameters:
amin
- the minimum accumulator value for each line.maxLines
- maximum number of (strongest) lines to extract.- Returns:
- a possibly empty array of
HoughLine
objects.
-
getXref
Returns the reference points x-coordinate.- Returns:
- as described.
-
getYref
Returns the reference points y-coordinate.- Returns:
- as described.
-
angleFromIndex
Calculates the actual angle (in radians) for angle indexai
- Parameters:
ai
- angle index [0,...,nAng-1]- Returns:
- Angle [0,...,PI] for angle index ai
-
radiusFromIndex
Calculates the actual radius for radius index ri.- Parameters:
ri
- radius index [0,...,nRad-1].- Returns:
- Radius [-maxRad,...,maxRad] with respect to reference point (xc, yc).
-
radiusToIndex
-
getAccumulator
Returns the accumulator as a 2D float-array.- Returns:
- the contents of the accumulator
-
getAccumulatorMax
Returns the local maximum values of the accumulator as a 2D float-array (all non-maximum elements are set to zero).- Returns:
- the local maximum values of the accumulator
-
getAccumulatorExtended
Returns the extended accumulator as a 2D float-array.- Returns:
- the extended accumulator
-
getAccumulatorImage
Creates and returns an image of the 2D accumulator array.- Returns:
- a
FloatProcessor
image of the accumulator
-
getAccumulatorImageExtended
Creates and returns an image of the extended 2D accumulator array, produced by adding a vertically mirrored copy of the accumulator to its right end.- Returns:
- a
FloatProcessor
image of the extended accumulator
-
getAccumulatorMaxImage
Creates and returns an image of the local maxima of the 2D accumulator array.- Returns:
- a
FloatProcessor
image of the accumulator maxima
-
getProgress
Description copied from interface:ProgressReporter
Returns a value in [0,1) indicating to which degree this task is complete.- Specified by:
getProgress
in interfaceProgressReporter
- Returns:
- a value between 0 and 1
-