Documentation of 'org.ddogleg.fitting.modelset.ransac.Ransac' Java class
Ransac
org.ddogleg.fitting.modelset.ransac

Class Ransac<Model,Point>

  • All Implemented Interfaces:
    ModelMatcher<Model,Point>


    public class Ransac<Model,Point>
    extends java.lang.Object
    implements ModelMatcher<Model,Point>

    RANSAC is an abbreviation for "RANdom SAmple Consensus" and is an iterative algorithm. The model with the largest set of inliers is found by randomly sampling the set of points and fitting a model. The algorithm terminates when the maximum number of iterations has been reached. An inlier is defined as a point which has an error less than a user specified threshold to the estimated model being considered. The algorithm was first published by Fischler and Bolles in 1981."

    Sample Points: By default the minimum number of points are sampled. The user to override this default and set it to any number.

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      double getFitQuality()
      Returns the metric used to evaluate the quality of fit.
      int getInputIndex(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()
      A set of points which match the provided parameters.
      int getMaxIterations() 
      int getMinimumSize()
      This is the minimum number of observations which can be input and produce a valid model.
      Model getModelParameters()
      Model for the match set
      double getThresholdFit() 
      void initialize(java.util.List<Point> dataSet)
      Initialize internal data structures
      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.
      static <T> void randomDraw(java.util.List<T> dataSet, int numSample, java.util.List<T> initialSample, java.util.Random rand)
      Two different methods are used to select the initial set of points depending on if the data set is much larger or smaller than the initial sample size
      void setMaxIterations(int maxIterations) 
      void setSampleSize(int sampleSize)
      Override the number of points that are sampled and used to generate models.
      void setThresholdFit(double thresholdFit) 
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Ransac

        public Ransac(long randSeed,
                      ModelManager<Model> modelManager,
                      ModelGenerator<Model,Point> modelGenerator,
                      DistanceFromModel<Model,Point> modelDistance,
                      int maxIterations,
                      double thresholdFit)
        Creates a new instance of the ransac algorithm. The number of points sampled will default to the minimum number. To override this default invoke setSampleSize(int).
        Parameters:
        randSeed - The random seed used by the random number generator.
        modelGenerator - Creates new model(s) given a small number of points.
        modelDistance - Computes the difference between a point an a model.
        maxIterations - The maximum number of iterations the RANSAC algorithm will perform.
        thresholdFit - How close of a fit a points needs to be to the model to be considered a fit.
    • Method Detail

      • process

        public boolean process(java.util.List<Point> dataSet)
        Description copied from interface: ModelMatcher
        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:
        process in interface ModelMatcher<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.
      • initialize

        public void initialize(java.util.List<Point> dataSet)
        Initialize internal data structures
      • randomDraw

        public static <T> void randomDraw(java.util.List<T> dataSet,
                                          int numSample,
                                          java.util.List<T> initialSample,
                                          java.util.Random rand)
        Two different methods are used to select the initial set of points depending on if the data set is much larger or smaller than the initial sample size
      • getMatchSet

        public java.util.List<Point> getMatchSet()
        Description copied from interface: ModelMatcher
        A set of points which match the provided parameters.
        Specified by:
        getMatchSet in interface ModelMatcher<Model,Point>
        Returns:
        List of points in the match set.
      • getInputIndex

        public int getInputIndex(int matchIndex)
        Description copied from interface: ModelMatcher
        For an item in the match set, return the index of the item in the original input set.
        Specified by:
        getInputIndex in interface ModelMatcher<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()
        Description copied from interface: ModelMatcher
        Returns 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:
        getFitQuality in interface ModelMatcher<Model,Point>
        Returns:
        Quality of fit to matched set of points
      • getMaxIterations

        public int getMaxIterations()
      • setMaxIterations

        public void setMaxIterations(int maxIterations)
      • getMinimumSize

        public int getMinimumSize()
        Description copied from interface: ModelMatcher
        This is the minimum number of observations which can be input and produce a valid model.
        Specified by:
        getMinimumSize in interface ModelMatcher<Model,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.
      • getThresholdFit

        public double getThresholdFit()
      • setThresholdFit

        public void setThresholdFit(double thresholdFit)

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.