# RegionFit

RegionFit[{p1,p2,},"model"]

finds a geometric region "model" that best fits the points p1,p2,.

RegionFit[{p1,p2,},"model","prop"]

specifies what fit property "prop" should be returned.

# Details and Options    • RegionFit is also known as sample consensus model.
• RegionFit is typically used for fitting and reconstructing regions from a set of points.
• • RegionFit[{p1,p2,},"model"] finds a region that contains the most points pi by iteratively estimating parameters of the specified "model" from a set of points.
• Possible 2D "model" specifications include:
• "Line" infinite line "Circle" circle
• Possible 3D "model" specifications include:
• "Line" infinite line "Circle" circle "Plane" plane "Sphere" sphere "Cylinder" cylinder "Cone" cone
• RegionFit[Point[{p1,p2,}]] is effectively equivalent to RegionFit[{p1,p2,}].
• Vertex normals ni for points pi can be specified by Point[{p1,p2,},VertexNormals{n1,n2,}].
• RegionFit[{p1,p2,},"model","prop"] returns the value of the fit property "prop".
• Possible fit properties "prop" include:
•  "BestFit" the best candidate model "Points" set of points "Inliers" points fitting the candidate model "Outliers" points not fitting the candidate model "DistanceVariance" variance of distances to the candidate model "Distances" distances to the best candidate model {prop1,prop2,…} several fit properties
• The following options can be given:
•  ConfidenceLevel Automatic desired probability of outlier-free sample Method Automatic method to use PerformanceGoal \$PerformanceGoal aspects of performance to try to optimize Tolerance Automatic numerical tolerance to use VertexNormals None vertex normals for points WorkingPrecision Automatic precision to use in computations
• Possible settings for Method include:
•  "RANSAC" random sample consensus "LMEDS" least median of squares "MSAC" M-estimator sample consensus "RRANSAC" randomized RANSAC "RMSAC" randomized MSAC "MLESAC" maximum likelihood estimation sample consensus "PROSAC" progressive sample consensus

# Examples

open allclose all

## Basic Examples(2)

Find a circle that fits a set of points:

Show the fit:

A set of points with many outliers fitted by a cylinder:

Visualize the fitted region with the data:

Distribution of the distances of the data to the bestfit cylinder:

## Scope(15)

### Data(4)

RegionFit works on coordinates:

List of points:

Collections of points:

Oriented collections of points:

### Models(7)

Obtain an InfiniteLine that best fits a set of points:

InfiniteLine in 3D:

Cone:

### Properties(4)

RegionFit gives the best fit region:

Distances of each point from the best fit region:

Variance of the distances:

Inliers and outliers:

## Options(4)

### Tolerance(1)

Use Tolerance to control the maximum distance of inliers:

### WorkingPrecision(3)

Compute the best-fit model using machine arithmetic:

Find the fit using exact numbers:

Find the fit using 30 digits of precision:

## Applications(3)

Find a best-fit parametrized region for a set of points on a circle:

Show the exact fit:

A set of points with noise:

Find a best-fit parametrized region:

Visualize the fitted region with the data:

Find the equation of a line passing through a set of points:

## Properties & Relations(1)

For near-perfect linear data, RegionFit and Fit produce equivalent fits using LeastSquares:

Use Fit to find the equation of the line:

Use RegionFit to find the line region:

Compare the results:

Fit minimizes the least squares error across all points, while RegionFit ignores outliers:

Fit the data with an outlier:

Show the new fits: