org.ddogleg.fitting.modelset.ransac
Class RansacMulti<Point>
- java.lang.Object
-
- org.ddogleg.fitting.modelset.ransac.RansacMulti<Point>
-
- All Implemented Interfaces:
- ModelMatcher<java.lang.Object,Point>, ModelMatcherMulti<Point>
public class RansacMulti<Point> extends java.lang.Object implements ModelMatcherMulti<Point>
Modification of
RANSACthat finds the best fit model and model parameters to a set of data. A model is a mathematical description of a specific object type (e.g. circle, square) and model parameters is the description (e.g. radius and center point for a circle). The minimum (or user specified) set of points is drawn from the set of all points. Then for each model parameters are estimated. The model and parameter pair with the largest inliers set is returned.To change the default behavior of the class for specific applications the child class can override internal functions. Suggestions are shown below.
checkExitIteration(): Override to provide custom logic for when the RANSAC iteration should stopselectMatchSet(org.ddogleg.fitting.modelset.DistanceFromModel<Model, Point>, double, Model): Override to provide custom for how the inlier set is found. Be sure to set up matchToInput[] correctly.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classRansacMulti.ObjectType<Model,Point>Describes a model and RANSAC fit parameters for specific type of object.
-
Constructor Summary
Constructors Constructor and Description RansacMulti(long randSeed, int maxIterations, java.util.List<RansacMulti.ObjectType> objectTypes, java.lang.Class<Point> typePoint)Creates a new instance of the ransac algorithm.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description doublegetFitQuality()Returns the metric used to evaluate the quality of fit.intgetInlierSize()intgetInputIndex(int matchIndex)For an item in the match set, return the index of the item in the original input set.intgetIteration()java.util.List<Point>getMatchSet()A set of points which match the provided parameters.intgetMaxIterations()intgetMinimumSize()This is the minimum number of observations which can be input and produce a valid model.intgetModelIndex()Indicates which model was found to best fit the points.java.lang.ObjectgetModelParameters()Model for the match setbooleanprocess(java.util.List<Point> dataSet)Finds a set of points from the provided list that are a good fit for the internal model and computes the fit parameters for the model.voidsetMaxIterations(int maxIterations)voidsetSampleSize(int sampleSize)Override the number of points that are sampled and used to generate models.
-
-
-
Constructor Detail
-
RansacMulti
public RansacMulti(long randSeed, int maxIterations, java.util.List<RansacMulti.ObjectType> objectTypes, java.lang.Class<Point> typePoint)Creates a new instance of the ransac algorithm. The number of points sampled will default to the minimum number. To override this default invokesetSampleSize(int).- Parameters:
randSeed- The random seed used by the random number generator.maxIterations- The maximum number of iterations the RANSAC algorithm will perform.objectTypes- Description of the different types of objects it can detecttypePoint- Class of Point
-
-
Method Detail
-
process
public boolean process(java.util.List<Point> dataSet)
Finds a set of points from the provided list that are a good fit for the internal model and computes the fit parameters for the model.- Specified by:
processin interfaceModelMatcher<java.lang.Object,Point>- Parameters:
dataSet- Set of points (with noise) that are to be fit.- Returns:
- true if it successfully found a solution or false if not.
-
getMatchSet
public java.util.List<Point> getMatchSet()
Description copied from interface:ModelMatcherA set of points which match the provided parameters.- Specified by:
getMatchSetin interfaceModelMatcher<java.lang.Object,Point>- Returns:
- List of points in the match set.
-
getInputIndex
public int getInputIndex(int matchIndex)
Description copied from interface:ModelMatcherFor an item in the match set, return the index of the item in the original input set.- Specified by:
getInputIndexin interfaceModelMatcher<java.lang.Object,Point>- Parameters:
matchIndex- Index of an element in the match set.- Returns:
- Index of the same element in the original input list.
-
getFitQuality
public double getFitQuality()
Description copied from interface:ModelMatcherReturns the metric used to evaluate the quality of fit. Meaning is implementation specific. Larger or smaller values could be preferred depending on implementation..- Specified by:
getFitQualityin interfaceModelMatcher<java.lang.Object,Point>- Returns:
- Quality of fit to matched set of points
-
getModelParameters
public java.lang.Object getModelParameters()
Description copied from interface:ModelMatcherModel for the match set- Specified by:
getModelParametersin interfaceModelMatcher<java.lang.Object,Point>- Returns:
- model.
-
getModelIndex
public int getModelIndex()
Description copied from interface:ModelMatcherMultiIndicates which model was found to best fit the points. The index is implementation specific and is likely to refer to the index inside a list.- Specified by:
getModelIndexin interfaceModelMatcherMulti<Point>- Returns:
- Index of selected model.
-
getInlierSize
public int getInlierSize()
-
getMaxIterations
public int getMaxIterations()
-
setMaxIterations
public void setMaxIterations(int maxIterations)
-
getMinimumSize
public int getMinimumSize()
Description copied from interface:ModelMatcherThis is the minimum number of observations which can be input and produce a valid model.- Specified by:
getMinimumSizein interfaceModelMatcher<java.lang.Object,Point>- Returns:
- Minimum number of sample points
-
setSampleSize
public void setSampleSize(int sampleSize)
Override the number of points that are sampled and used to generate models. If this value is not set it defaults to the minimum number.- Parameters:
sampleSize- Number of sample points.
-
getIteration
public int getIteration()
-
-
DataMelt 3.0 © DataMelt by jWork.ORG