Package stitching.model
Class Model
java.lang.Object
stitching.model.Model
- All Implemented Interfaces:
CoordinateTransform
- Direct Known Subclasses:
InvertibleModel
Abstract class for arbitrary transformation models to be applied
to
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},
}
- Version:
- 0.2b
- Author:
- Stephan Saalfeld
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbetterThan(Model m) less than operater to make the models comparable, returns false for error < 0abstract Modelclone()Clone the model.static final <M extends Model>
Mfilter(Class<M> modelClass, Collection<PointMatch> candidates, Collection<PointMatch> inliers) Estimate aModeland filter potential outliers by robust iterative regression.static <M extends Model>
MfilterRansac(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 voidfit(Collection<PointMatch> matches) Fit theModelto a set of data points minimizing the global transfer error.final doublegetCost()final doublegetError()Deprecated.abstract intstatic final <M extends Model>
Mransac(Class<M> modelClass, List<PointMatch> candidates, Collection<PointMatch> inliers, int iterations, double epsilon, double min_inlier_ratio) final voidsetCost(double c) final voidsetError(double e) Deprecated.The term Error may be missleading---usegetCost()insteadabstract voidshake(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 matchesstatic final booleantest(Model model, Collection<PointMatch> candidates, Collection<PointMatch> inliers, double epsilon, double min_inlier_ratio) Test theModelfor a set of point correspondence candidates.abstract StringtoString()Create a meaningful string representation of the model for save into text-files or display on terminals.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface stitching.model.CoordinateTransform
apply, applyInPlace
-
Field Details
-
rnd
-
cost
protected double costThe cost depends on what kind of algorithm is running. It is always true that a smaller cost is better than large cost
-
-
Constructor Details
-
Model
public Model()
-
-
Method Details
-
getMinSetSize
public abstract int getMinSetSize() -
getCost
public final double getCost() -
setCost
public final void setCost(double c) -
getError
Deprecated.The term Error may be missleading---usegetCost()instead -
setError
Deprecated.The term Error may be missleading---usegetCost()instead -
betterThan
less than operater to make the models comparable, returns false for error < 0- Parameters:
m-- Returns:
- false for error < 0, otherwise true if this.error is smaller than m.error
-
shake
randomly change the model a bit estimates the necessary amount of shaking for each single dimensional distance in the set of matches- Parameters:
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)
-
fit
Fit theModelto a set of data points minimizing the global transfer error. This is assumed to be implemented as a least squares minimization. Useransacand/ orfilter(Class, Collection, Collection)to remove outliers from your data points The estimated model transfers match.p2.local to match.p1.world.- Parameters:
matches- set of point correpondences- Throws:
NotEnoughDataPointsException- an exception if matches does not contain enough data points
-
test
public static final boolean test(Model model, Collection<PointMatch> candidates, Collection<PointMatch> inliers, double epsilon, double min_inlier_ratio) Test theModelfor 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.- Parameters:
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%)
-
filter
public static final <M extends Model> M filter(Class<M> modelClass, Collection<PointMatch> candidates, Collection<PointMatch> inliers) throws NotEnoughDataPointsException Estimate aModeland 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 infilterRansac(java.lang.Class<M>, java.util.List<stitching.model.PointMatch>, java.util.Collection<stitching.model.PointMatch>, int, float, float).- Parameters:
modelClass- Class of the model to be estimatedcandidates- Candidate data points eventually inluding some outliersinliers- Remaining after the robust regression filter- Throws:
NotEnoughDataPointsException
-
ransac
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 Estimate aModelfrom a set with many outliers by first filtering the worst outliers withransac\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 infilterRansac(java.lang.Class<M>, java.util.List<stitching.model.PointMatch>, java.util.Collection<stitching.model.PointMatch>, int, float, float).- Parameters:
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 candidates- Returns:
- an instance of
- Throws:
NotEnoughDataPointsException
-
filterRansac
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 Estimate the best model for a set of feature correspondence candidates. Increase the error as long as not more inliers apear. TODO: This is a very crappy way of identifying the minimal max_epsilon and maximal number of inliers at the same time. We suggest a more elaborate technique as follows: 1. Run RANSAC with large max_epsilon resulting in many outliers included. 2. Get rid of the outliers using the robust regression method of Dutter and Huber- Throws:
NotEnoughDataPointsException
-
toString
Create a meaningful string representation of the model for save into text-files or display on terminals. -
clone
Clone the model.
-
getCost()instead