public abstract class AbstractModel<M extends AbstractModel<M>> extends Object implements Model<M>, Serializable
Points
in n-dimensional space.
Model: R^n --> R^n
Provides methods for generic optimization and model extraction algorithms. Currently, the Random Sample Consensus \cite{FischlerB81}, a robust regression method and the Iterative Closest Point Algorithm \cite{Zhang94} are implemented.
BibTeX:
@article{FischlerB81, author = {Martin A. Fischler and Robert C. Bolles}, title = {Random sample consensus: a paradigm for model fitting with applications to image analysis and automated cartography}, journal = {Communications of the ACM}, volume = {24}, number = {6}, year = {1981}, pages = {381--395}, publisher = {ACM Press}, address = {New York, NY, USA}, issn = {0001-0782}, doi = {http://doi.acm.org/10.1145/358669.358692}, } @article{Zhang94, author = {{Zhengyou Zhang}}, title = {Iterative point matching for registration of free-form curves and surfaces}, journal = {International Journal of Computer Vision}, volume = {13}, number = {2}, month = {October}, year = {1994}, pages = {119--152}, }
Modifier and Type | Field and Description |
---|---|
protected double |
cost
The cost depends on what kind of algorithm is running.
|
protected static Random |
rnd |
Constructor and Description |
---|
AbstractModel() |
Modifier and Type | Method and Description |
---|---|
boolean |
betterThan(M m)
"Less than" operater to make
Models comparable. |
<P extends PointMatch> |
filter(Collection<P> candidates,
Collection<P> inliers)
Call
filter(Collection, Collection, double) with maxTrust = 4 and minNumInliers = Model.getMinNumMatches() . |
<P extends PointMatch> |
filter(Collection<P> candidates,
Collection<P> inliers,
double maxTrust)
Call
filter(Collection, Collection, double, int) with minNumInliers = Model.getMinNumMatches() . |
<P extends PointMatch> |
filter(Collection<P> candidates,
Collection<P> inliers,
double maxTrust,
int minNumInliers)
Estimate the
AbstractModel and filter potential outliers by robust
iterative regression. |
<P extends PointMatch> |
filterRansac(List<P> candidates,
Collection<P> inliers,
int iterations,
double maxEpsilon,
double minInlierRatio)
Call
filterRansac(List, Collection, int, double, double, double)
with maxTrust = 4. |
<P extends PointMatch> |
filterRansac(List<P> candidates,
Collection<P> inliers,
int iterations,
double maxEpsilon,
double minInlierRatio,
double maxTrust)
Call
filterRansac(List, Collection, int, double, double, int, double)
with minNumInliers = Model.getMinNumMatches() . |
<P extends PointMatch> |
filterRansac(List<P> candidates,
Collection<P> inliers,
int iterations,
double maxEpsilon,
double minInlierRatio,
int minNumInliers)
Call
filterRansac(List, Collection, int, double, double, int, double)
with maxTrust = 4. |
<P extends PointMatch> |
filterRansac(List<P> candidates,
Collection<P> inliers,
int iterations,
double maxEpsilon,
double minInlierRatio,
int minNumInliers,
double maxTrust)
Estimate a
AbstractModel from a set with many outliers by first
filtering the worst outliers with RANSAC
\citet[{FischlerB81} and filter potential outliers by robust iterative
regression. |
void |
fit(double[][] p,
double[][] q,
double[] w)
Default fit implementation using
Model.fit(Collection) . |
void |
fit(float[][] p,
float[][] q,
float[] w)
Default fit implementation using
Model.fit(Collection) . |
double |
getCost() |
Collection<PointMatch> |
icp(List<Point> p,
List<Point> q)
Estimate the best model in terms of the Iterative Closest Point
Algorithm \cite{Zhang94} for matching two point clouds into each other.
|
<P extends PointMatch> |
localSmoothnessFilter(Collection<P> candidates,
Collection<P> inliers,
double sigma,
double maxEpsilon,
double maxTrust)
Default implementation of
localSmoothnessFilter(Collection, Collection, double, double, double) . |
<P extends PointMatch> |
ransac(List<P> candidates,
Collection<P> inliers,
int iterations,
double epsilon,
double minInlierRatio)
Call
ransac(List, Collection, int, double, double, int) with
minNumInliers = Model.getMinNumMatches() . |
<P extends PointMatch> |
ransac(List<P> candidates,
Collection<P> inliers,
int iterations,
double epsilon,
double minInlierRatio,
int minNumInliers)
Find the
AbstractModel of a set of PointMatch candidates
containing a high number of outliers using
RANSAC
\citet[{FischlerB81}. |
void |
setCost(double c) |
<P extends PointMatch> |
test(Collection<P> candidates,
Collection<P> inliers,
double epsilon,
double minInlierRatio)
Call
test(Collection, Collection, double, double, int) with
minNumInliers = Model.getMinNumMatches() . |
<P extends PointMatch> |
test(Collection<P> candidates,
Collection<P> inliers,
double epsilon,
double minInlierRatio,
int minNumInliers)
Test the
AbstractModel for a set of PointMatch candidates. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
copy, fit, getMinNumMatches, set
apply, applyInPlace
protected static final Random rnd
protected double cost
public final double getCost()
getCost
in interface Model<M extends AbstractModel<M>>
public final void setCost(double c)
setCost
in interface Model<M extends AbstractModel<M>>
public final boolean betterThan(M m)
Models
comparable.betterThan
in interface Model<M extends AbstractModel<M>>
m
- cost
< 0.0, otherwise true if
this.cost
is smaller than m.cost
public final <P extends PointMatch> boolean test(Collection<P> candidates, Collection<P> inliers, double epsilon, double minInlierRatio, int minNumInliers)
AbstractModel
for a set of PointMatch
candidates.
Return true if the number of inliers / number of candidates is larger
than or equal to min_inlier_ratio, otherwise false.
Clears inliers and fills it with the fitting subset of candidates.
Sets cost
= 1.0 - |inliers| / |candidates|.test
in interface Model<M extends AbstractModel<M>>
candidates
- set of point correspondence candidatesinliers
- set of point correspondences that fit the modelepsilon
- maximal allowed transfer errorminInlierRatio
- minimal ratio |inliers| / |candidates| (0.0 => 0%, 1.0 => 100%)
minNumInliers
- minimally required absolute number of inlierspublic final <P extends PointMatch> boolean test(Collection<P> candidates, Collection<P> inliers, double epsilon, double minInlierRatio)
test(Collection, Collection, double, double, int)
with
minNumInliers = Model.getMinNumMatches()
.test
in interface Model<M extends AbstractModel<M>>
public final <P extends PointMatch> boolean filter(Collection<P> candidates, Collection<P> inliers, double maxTrust, int minNumInliers) throws NotEnoughDataPointsException
AbstractModel
and filter potential outliers by robust
iterative regression.
This method performs well on data sets with low amount of outliers. If
you have many outliers, you can filter those with a `tolerant' RANSAC
first as done in filterRansac(java.util.List<P>, java.util.Collection<P>, int, double, double, int, double)
.
Sets cost
to the average point transfer error.
filter
in interface Model<M extends AbstractModel<M>>
candidates
- Candidate data points eventually inluding some outliersinliers
- Remaining after the robust regression filtermaxTrust
- reject candidates with a cost larger than
maxTrust * median costminNumInliers
- minimally required absolute number of inliersAbstractModel
could be estimated and inliers is not
empty, false otherwise. If false, AbstractModel
remains unchanged.NotEnoughDataPointsException
public final <P extends PointMatch> boolean filter(Collection<P> candidates, Collection<P> inliers, double maxTrust) throws NotEnoughDataPointsException
filter(Collection, Collection, double, int)
with minNumInliers = Model.getMinNumMatches()
.filter
in interface Model<M extends AbstractModel<M>>
NotEnoughDataPointsException
public final <P extends PointMatch> boolean filter(Collection<P> candidates, Collection<P> inliers) throws NotEnoughDataPointsException
filter(Collection, Collection, double)
with maxTrust = 4 and minNumInliers = Model.getMinNumMatches()
.filter
in interface Model<M extends AbstractModel<M>>
NotEnoughDataPointsException
public final <P extends PointMatch> boolean ransac(List<P> candidates, Collection<P> inliers, int iterations, double epsilon, double minInlierRatio, int minNumInliers) throws NotEnoughDataPointsException
AbstractModel
of a set of PointMatch
candidates
containing a high number of outliers using
RANSAC
\citet[{FischlerB81}.ransac
in interface Model<M extends AbstractModel<M>>
candidates
- candidate data points inluding (many) outliersinliers
- remaining candidates after RANSACiterations
- number of iterationsepsilon
- maximal allowed transfer errorminInlierRatio
- minimal number of inliers to number of
candidatesminNumInliers
- minimally required absolute number of inliersAbstractModel
could be estimated and inliers is not
empty, false otherwise. If false, AbstractModel
remains unchanged.NotEnoughDataPointsException
public final <P extends PointMatch> boolean ransac(List<P> candidates, Collection<P> inliers, int iterations, double epsilon, double minInlierRatio) throws NotEnoughDataPointsException
ransac(List, Collection, int, double, double, int)
with
minNumInliers = Model.getMinNumMatches()
.ransac
in interface Model<M extends AbstractModel<M>>
NotEnoughDataPointsException
public final <P extends PointMatch> boolean filterRansac(List<P> candidates, Collection<P> inliers, int iterations, double maxEpsilon, double minInlierRatio, int minNumInliers, double maxTrust) throws NotEnoughDataPointsException
AbstractModel
from a set with many outliers by first
filtering the worst outliers with RANSAC
\citet[{FischlerB81} and filter potential outliers by robust iterative
regression.filterRansac
in interface Model<M extends AbstractModel<M>>
candidates
- candidate data points inluding (many) outliersinliers
- remaining candidates after RANSACiterations
- number of iterationsmaxEpsilon
- maximal allowed transfer errorminInlierRatio
- minimal number of inliers to number of
candidatesminNumInliers
- minimally required absolute number of inliersmaxTrust
- reject candidates with a cost larger than
maxTrust * median costAbstractModel
could be estimated and inliers is not
empty, false otherwise. If false, AbstractModel
remains unchanged.NotEnoughDataPointsException
public final <P extends PointMatch> boolean filterRansac(List<P> candidates, Collection<P> inliers, int iterations, double maxEpsilon, double minInlierRatio, int minNumInliers) throws NotEnoughDataPointsException
filterRansac(List, Collection, int, double, double, int, double)
with maxTrust = 4.filterRansac
in interface Model<M extends AbstractModel<M>>
NotEnoughDataPointsException
public final <P extends PointMatch> boolean filterRansac(List<P> candidates, Collection<P> inliers, int iterations, double maxEpsilon, double minInlierRatio, double maxTrust) throws NotEnoughDataPointsException
filterRansac(List, Collection, int, double, double, int, double)
with minNumInliers = Model.getMinNumMatches()
.filterRansac
in interface Model<M extends AbstractModel<M>>
NotEnoughDataPointsException
public final <P extends PointMatch> boolean filterRansac(List<P> candidates, Collection<P> inliers, int iterations, double maxEpsilon, double minInlierRatio) throws NotEnoughDataPointsException
filterRansac(List, Collection, int, double, double, double)
with maxTrust = 4.filterRansac
in interface Model<M extends AbstractModel<M>>
NotEnoughDataPointsException
public final Collection<PointMatch> icp(List<Point> p, List<Point> q)
p -> q
icp
in interface Model<M extends AbstractModel<M>>
p
- sourceq
- targetpublic void fit(float[][] p, float[][] q, float[] w) throws NotEnoughDataPointsException, IllDefinedDataPointsException
Model.fit(Collection)
. This foils
the intention that fit(float[][], float[][], float[])
would be
potentially more efficient. You should better implement it directly.fit
in interface Model<M extends AbstractModel<M>>
p
- source pointsq
- target pointsw
- weightsNotEnoughDataPointsException
- if not enough data points
were availableIllDefinedDataPointsException
- if the set of data points is
inappropriate to solve the Modelpublic void fit(double[][] p, double[][] q, double[] w) throws NotEnoughDataPointsException, IllDefinedDataPointsException
Model.fit(Collection)
. This foils
the intention that fit(double[][], double[][], double[])
would be
potentially more efficient. You should better implement it directly.fit
in interface Model<M extends AbstractModel<M>>
p
- source pointsq
- target pointsw
- weightsNotEnoughDataPointsException
- if not enough data points
were availableIllDefinedDataPointsException
- if the set of data points is
inappropriate to solve the Modelpublic <P extends PointMatch> boolean localSmoothnessFilter(Collection<P> candidates, Collection<P> inliers, double sigma, double maxEpsilon, double maxTrust)
Default implementation of
localSmoothnessFilter(Collection, Collection, double, double, double)
.
Requires that Model.fit(Collection)
is implemented as a weighted
least squares fit or something similar.
Note that if candidates == inliers and an exception occurs, inliers will be cleared according to that there are no inliers.
localSmoothnessFilter
in interface Model<M extends AbstractModel<M>>
Copyright © 2015–2021 Fiji. All rights reserved.