org.ddogleg.fitting.modelset.lmeds
Class LeastMedianOfSquares<Model,Point>
- java.lang.Object
-
- org.ddogleg.fitting.modelset.lmeds.LeastMedianOfSquares<Model,Point>
-
- All Implemented Interfaces:
- ModelMatcher<Model,Point>
public class LeastMedianOfSquares<Model,Point> extends java.lang.Object implements ModelMatcher<Model,Point>
Another technique similar to RANSAC known as Least Median of Squares (LMedS). For each iteration a small number N points are selected. A model is fit to these points and then the error is computed for the whole set. The model which minimizes the median is selected as the final model. No pruning or formal selection of inlier set is done.
-
-
Constructor Summary
Constructors Constructor and Description LeastMedianOfSquares(long randSeed, int totalCycles, double maxMedianError, double inlierFraction, ModelManager<Model> modelManager, ModelGenerator<Model,Point> generator, DistanceFromModel<Model,Point> errorMetric)Configures the algorithm.LeastMedianOfSquares(long randSeed, int totalCycles, ModelManager<Model> modelManager, ModelGenerator<Model,Point> generator, DistanceFromModel<Model,Point> errorMetric)Configures the algorithm.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description doublegetFitQuality()Value of the best median error.intgetInputIndex(int matchIndex)For an item in the match set, return the index of the item in the original input set.java.util.List<Point>getMatchSet()If configured to computer the inlier set it returns the computed inliers.intgetMinimumSize()This is the minimum number of observations which can be input and produce a valid model.ModelgetModelParameters()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.voidsetSampleSize(int sampleSize)Number of points it samples to compute a model from.
-
-
-
Constructor Detail
-
LeastMedianOfSquares
public LeastMedianOfSquares(long randSeed, int totalCycles, double maxMedianError, double inlierFraction, ModelManager<Model> modelManager, ModelGenerator<Model,Point> generator, DistanceFromModel<Model,Point> errorMetric)Configures the algorithm.- Parameters:
randSeed- Random seed used internally.totalCycles- Number of random draws it will make when estimating model parameters.maxMedianError- If the best median error is larger than this it is considered a failure.inlierFraction- Data which is this fraction or lower is considered an inlier and used to recompute model parameters at the end. Set to 0 to turn off. Domain: 0 to 1.generator- Creates a list of model hypotheses from a small set of points.errorMetric- Computes the error between a point and a model
-
LeastMedianOfSquares
public LeastMedianOfSquares(long randSeed, int totalCycles, ModelManager<Model> modelManager, ModelGenerator<Model,Point> generator, DistanceFromModel<Model,Point> errorMetric)Configures the algorithm.- Parameters:
randSeed- Random seed used internally.totalCycles- Number of random draws it will make when estimating model parameters.generator- Creates a list of model hypotheses from a small set of points.errorMetric- Computes the error between a point and a model
-
-
Method Detail
-
setSampleSize
public void setSampleSize(int sampleSize)
Number of points it samples to compute a model from. Typically this is the minimum number of points needed.- Parameters:
sampleSize- Number of points sampled when computing the model.
-
process
public boolean process(java.util.List<Point> dataSet)
Description copied from interface:ModelMatcherFinds 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<Model,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.
-
getModelParameters
public Model getModelParameters()
Description copied from interface:ModelMatcherModel for the match set- Specified by:
getModelParametersin interfaceModelMatcher<Model,Point>- Returns:
- model.
-
getMatchSet
public java.util.List<Point> getMatchSet()
If configured to computer the inlier set it returns the computed inliers. Otherwise it returns the data set orginally passed in.- Specified by:
getMatchSetin interfaceModelMatcher<Model,Point>- Returns:
- Set of points that are inliers to the returned model parameters..
-
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<Model,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()
Value of the best median error.- Specified by:
getFitQualityin interfaceModelMatcher<Model,Point>- Returns:
-
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<Model,Point>- Returns:
- Minimum number of sample points
-
-
DataMelt 3.0 © DataMelt by jWork.ORG