- All Implemented Interfaces:
LineFit
This class implements incremental orthogonal line fitting to a set of 2D points using eigendecomposition (see
OrthogonalLineFitEigen for a non-incremental version). See Sec. 10.3 (Alg. 10.4) of [1] for additional
details.
This fitter behaves like a queue: sample points may be added and removed freely either at its front or its end, while the ordering of the remaining points remains unchanged. This is to simplify back-tracking, for example for incremental contour fitting. Whenever a point is added or removed, the internal statistics (scatter matrix) are updated. The current line fit can be queried any time as long as there are more than two points in the point set (otherwise an exception is thrown).
[1] W. Burger, M.J. Burge, Digital Image Processing – An Algorithmic Introduction, 3rd ed, Springer (2022).
- Version:
- 2022/09/29 revised
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor creating a fitter with an empty set of points.IncrementalLineFit(Pnt2d[] initPnts) Constructor accepting a sequence of initial points. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a new sample points to the end of the point sequence (same asaddLast(Pnt2d)).voidAdds a new sample points to the front of the point sequence.voidAdds a new sample points to the end of the point sequence (same asaddLast(Pnt2d)).double[]Returns the parameters [A, B, C] for theAlgebraicLineassociated with this line fit.Pnt2d[]Returns the current point sequence of this fit as an array.intgetSize()Returns the size of the point set used for calculating this line fit.doubleCalculates and returns the sum of the squared orthogonal distances of the current point set for this line fit.Returns (but does not remove) the point positioned at the front of the point sequence.peekLast()Returns (but does not remove) the point positioned at the end of the point sequence.Retrieves and removes the first point from the front of the point sequence.Retrieves and removes the last point from the end of the point sequence.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface imagingbook.common.geometry.fitting.line.LineFit
getLine, getSquaredOrthogonalError
-
Constructor Details
-
IncrementalLineFit
public IncrementalLineFit()Constructor creating a fitter with an empty set of points. -
IncrementalLineFit
Constructor accepting a sequence of initial points. The first point is placed at the from of the queue, the last point at its end.- Parameters:
initPnts- an array of initial points
-
-
Method Details
-
getSquaredOrthogonalError
Calculates and returns the sum of the squared orthogonal distances of the current point set for this line fit.- Returns:
- the squared orthogonal error
- See Also:
-
getPoints
Returns the current point sequence of this fit as an array.- Returns:
- an array of points
-
add
Adds a new sample points to the end of the point sequence (same asaddLast(Pnt2d)).- Parameters:
pnt- the point to be added- Returns:
- true (always, to be compatible with
Deque)
-
addFirst
Adds a new sample points to the front of the point sequence.- Parameters:
pnt- the point to be added
-
addLast
Adds a new sample points to the end of the point sequence (same asaddLast(Pnt2d)).- Parameters:
pnt- the point to be added
-
removeFirst
Retrieves and removes the first point from the front of the point sequence.- Returns:
- the removed point
-
removeLast
Retrieves and removes the last point from the end of the point sequence.- Returns:
- the removed point
-
peekFirst
Returns (but does not remove) the point positioned at the front of the point sequence.- Returns:
- the first point
-
peekLast
Returns (but does not remove) the point positioned at the end of the point sequence.- Returns:
- the last point
-
getSize
Description copied from interface:LineFitReturns the size of the point set used for calculating this line fit. -
getLineParameters
Description copied from interface:LineFitReturns the parameters [A, B, C] for theAlgebraicLineassociated with this line fit. To be implemented by concrete classes.nullis returned if no fit was found.- Specified by:
getLineParametersin interfaceLineFit- Returns:
- algebraic line parameters [A, B, C]
- See Also:
-