public abstract class Model extends Object implements CoordinateTransform
Points
in n-dimensional space.
Model: R^n --> R^n
Provides methods for generic optimization and model extraction algorithms. Currently, the Random Sample Consensus \citet{FischlerB81} and a robust regression method are implemented.
TODO: A model is planned to be a generic transformation pipeline to be applied to images, volumes or arbitrary sets of n-dimensional points. E.g. lens transformation of camera images, pose and location of mosaic tiles, non-rigid bending of confocal stacks etc.
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}, }
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 |
---|
Model() |
Modifier and Type | Method and Description |
---|---|
boolean |
betterThan(Model m)
less than operater to make the models comparable, returns false for error < 0
|
abstract Model |
clone()
Clone the model.
|
static <M extends Model> |
filter(Class<M> modelClass,
Collection<PointMatch> candidates,
Collection<PointMatch> inliers)
Estimate a
Model and filter potential outliers by robust
iterative regression. |
static <M extends Model> |
filterRansac(Class<M> modelType,
List<PointMatch> candidates,
Collection<PointMatch> inliers,
int iterations,
float max_epsilon,
float min_inlier_ratio)
Estimate the best model for a set of feature correspondence candidates.
|
abstract void |
fit(Collection<PointMatch> matches)
Fit the
Model to a set of data points minimizing the global
transfer error. |
double |
getCost() |
double |
getError()
Deprecated.
The term Error may be missleading---use
getCost() instead |
abstract int |
getMinSetSize() |
static <M extends Model> |
ransac(Class<M> modelClass,
List<PointMatch> candidates,
Collection<PointMatch> inliers,
int iterations,
double epsilon,
double min_inlier_ratio)
|
void |
setCost(double c) |
void |
setError(double e)
Deprecated.
The term Error may be missleading---use
getCost() instead |
abstract void |
shake(Collection<PointMatch> matches,
float scale,
float[] center)
randomly change the model a bit
estimates the necessary amount of shaking for each single dimensional
distance in the set of matches
|
static boolean |
test(Model model,
Collection<PointMatch> candidates,
Collection<PointMatch> inliers,
double epsilon,
double min_inlier_ratio)
Test the
Model for a set of point correspondence candidates. |
abstract String |
toString()
Create a meaningful string representation of the model for save into
text-files or display on terminals.
|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
apply, applyInPlace
protected static final Random rnd
protected double cost
public abstract int getMinSetSize()
public final double getCost()
public final void setCost(double c)
@Deprecated public final double getError()
getCost()
instead@Deprecated public final void setError(double e)
getCost()
insteadpublic boolean betterThan(Model m)
m
- public abstract void shake(Collection<PointMatch> matches, float scale, float[] center)
matches
- point matchesscale
- gives a multiplicative factor to each dimensional distance (scales the amount of shaking)center
- local pivot point for centered shakes (e.g. rotation)public abstract void fit(Collection<PointMatch> matches) throws NotEnoughDataPointsException
Model
to a set of data points minimizing the global
transfer error. This is assumed to be implemented as a least squares
minimization. Use
ransac
and/ or filter(Class, Collection, Collection)
to remove
outliers from your data points
The estimated model transfers match.p2.local to match.p1.world.matches
- set of point correpondencesNotEnoughDataPointsException
- an exception if matches does not contain enough data pointspublic static final boolean test(Model model, Collection<PointMatch> candidates, Collection<PointMatch> inliers, double epsilon, double min_inlier_ratio)
Model
for a set of point correspondence 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.candidates
- set of point correspondence candidatesinliers
- set of point correspondences that fit the modelepsilon
- maximal allowed transfer errormin_inlier_ratio
- minimal ratio of inliers (0.0 => 0%, 1.0 => 100%)public static final <M extends Model> M filter(Class<M> modelClass, Collection<PointMatch> candidates, Collection<PointMatch> inliers) throws NotEnoughDataPointsException
Model
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.lang.Class<M>, java.util.List<stitching.model.PointMatch>, java.util.Collection<stitching.model.PointMatch>, int, float, float)
.modelClass
- Class of the model to be estimatedcandidates
- Candidate data points eventually inluding some outliersinliers
- Remaining after the robust regression filterNotEnoughDataPointsException
public static final <M extends Model> M ransac(Class<M> modelClass, List<PointMatch> candidates, Collection<PointMatch> inliers, int iterations, double epsilon, double min_inlier_ratio) throws NotEnoughDataPointsException
Model
from a set with many outliers by first
filtering the worst outliers with
ransac
\citet[{FischlerB81} tand 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.lang.Class<M>, java.util.List<stitching.model.PointMatch>, java.util.Collection<stitching.model.PointMatch>, int, float, float)
.modelClass
- Class of the model to be estimatedcandidates
- Candidate data points inluding (many) outliersinliers
- Remaining candidates after RANSACiterations
- epsilon
- min_inlier_ratio
- minimal number of inliers to number of
candidatesNotEnoughDataPointsException
public static <M extends Model> M filterRansac(Class<M> modelType, List<PointMatch> candidates, Collection<PointMatch> inliers, int iterations, float max_epsilon, float min_inlier_ratio) throws NotEnoughDataPointsException
NotEnoughDataPointsException
public abstract String toString()
Copyright © 2015–2021 Fiji. All rights reserved.