Every height check, coplanarity test and ground-extraction step in 3D vision reduces to one operation: fit a plane to a point cloud, then judge the points against it. Which estimator you pick decides whether the result survives real clouds that carry fixtures, edges and stray returns alongside the part. This guide compares the two standard estimators, least squares and RANSAC, with the arithmetic that shows why least squares alone fails on dirty clouds, the inlier threshold to start from, and the denoise–segment–refine recipe inline inspection runs. The figures are reproducible: iteration counts come from the standard RANSAC model, and the worked example is a 52,000-point cloud you can rebuild from any 3D sensors capture.
What does fitting a plane to a point cloud actually produce?
A plane fit returns four numbers: the unit normal (nx, ny, nz), the plane's offset d from the sensor origin, and — written in slope form — the two tilts a and b with the height c in z = a·x + b·y + c.
The normal form n·p + d = 0 gives the point-to-plane distance |n·pᵢ + d| directly; that distance is the quantity RANSAC thresholds. The slope form suits near-horizontal machined surfaces, because a and b read as millimetres of drop per millimetre of travel. The normal itself is the eigenvector of the smallest eigenvalue of the 3×3 covariance matrix of the point coordinates — one matrix, no iteration. From the fit you read tilt against a datum, flatness from the spread of residuals, and coplanarity between features; height checks against a fitted datum follow the same pattern as measuring surface height difference from a 3D point cloud.
How does least squares fit a plane, and how fast is it?
Least squares accumulates one 3×3 covariance matrix in a single pass over the N points and reads the normal off its smallest eigenvector, so a one-million-point cloud fits in milliseconds and the cost grows only linearly with cloud size.
The estimator minimizes the sum of squared residuals and is the maximum-likelihood answer when residuals are Gaussian — which is what a calibrated sensor's noise looks like. There are no tuning parameters: no threshold, no iteration cap, nothing to drift between shifts. Two practical notes. On steep surfaces, fit perpendicular (total least squares) distances rather than regressing z on x and y, or the slopes bias low. And the speed that makes least squares attractive — one pass, cost O(N) — is exactly why it cannot reject anything: every point carries equal weight, so the result is only as clean as the cloud you feed it.
How badly do outliers skew a least-squares plane?
Badly, and through two mechanisms. In the worked cloud below, 2,000 fixture-edge strays — 4% of the points, sitting 2 mm below the part — tilt the least-squares plane by 0.25°. A 100 mm plate then reads 0.21 mm out of level at one edge against 0.05 mm of point noise.
Work the example. The cloud: 50,000 points on a 100 mm × 100 mm plate top at z = 0 with noise σ = 0.05 mm, plus 2,000 stray returns at z = −2 mm. If those strays were scattered evenly, they would only drag the height offset: the mean z becomes (50,000 × 0 + 2,000 × (−2)) / 52,000 = −4,000 / 52,000 = −0.077 mm, so the whole plane reads 0.08 mm low. Scattered outliers cost fraction × offset and nothing more.
Clustered strays do worse, because they bend the slope as well. With the strays near the x = +50 mm edge:
- Σxz = 2,000 × 50 mm × (−2 mm) = −2.0×10⁵ mm²
- Σx² = 50,000 × (100²/12) + 2,000 × 50² = 4.167×10⁷ + 5.0×10⁶ = 4.667×10⁷ mm²
- slope a = −2.0×10⁵ / 4.667×10⁷ = −4.29×10⁻³ mm/mm, so tilt = arctan(0.00429) = 0.25°
- height error at the plate edge: 0.00429 × 50 mm = 0.21 mm
Random noise averages away as 1/√N; errors that share a location steer the plane instead. A single stray among 50,000 shifts the offset by 2 mm / 50,000 = 0.00004 mm — nothing. Clusters are what wreck least squares, and off-centre clusters wreck it fastest.
How does RANSAC beat the outliers, and how many iterations does it need?
RANSAC draws random 3-point candidate planes, counts the inliers within threshold t of each candidate and keeps the highest-scoring plane. The worked cloud above needs just 3 iterations for 99% confidence at its 96% inlier fraction, while a cloud half-covered by clutter needs 35.
The count follows the standard RANSAC model, with w the inlier fraction and p the target probability of drawing at least one clean sample:
| Inlier fraction w | Iterations for p = 0.99 |
|---|---|
| 25% | 293 |
| 50% | 35 |
| 70% | 11 |
| 80% | 7 |
| 90% | 4 |
| 95% | 3 |
| 99% | 2 |
For the worked cloud, w = 50,000 / 52,000 = 0.962, so w³ = 0.890, 1 − w³ = 0.110, and N = ln(0.01) / ln(0.110) = 4.605 / 2.207 = 2.1, which rounds up to 3. Each iteration tests every point against the candidate: 3 × 52,000 ≈ 160,000 distance evaluations, single-digit milliseconds on a desktop-class core. Even the cluttered case, 35 × 52,000 ≈ 1.8 million tests, stays in the tens of milliseconds. RANSAC's cost is not the problem; the threshold and the inlier set are.
The raw RANSAC plane is quantized by t, so finish with a least-squares refit on the inliers only — that refit is what reaches noise-floor accuracy. On 50,000 inliers with σ = 0.05 mm, the offset's statistical uncertainty is σ/√N ≈ 0.0002 mm, so the fit is then limited by calibration, not by the estimator. The classic single-plane job is pulling the dominant plane out of a depth cloud — the same task as removing ground points from a depth point cloud for obstacle detection — and multi-plane scenes simply repeat the loop, remove the winning plane's inliers and continue, as segmenting planes and cylinders in a point cloud walks through.
If t never settles, median-based estimators (LMedS) drop the threshold entirely; published comparisons report plane quality comparable to RANSAC at higher speed.
What inlier threshold should you set?
Start at t ≈ 3σ of the sensor's point noise — near 0.1–0.3 mm for laser-profiler clouds on machined parts, 0.5–1 mm for structured-light area clouds and 5–20 mm for coarse ToF logistics clouds — then widen in doubling steps until the inlier count stops climbing.
Three sigma keeps 99.7% of true surface points for Gaussian noise, so real geometry survives the cut. Take σ from the sensor's noise class, not from the fit itself. The plateau is the tuning loop: double t, watch the inlier count, stop at the last step before it jumps — a jump means background just joined the plane. Too tight fragments one surface into several candidates; too loose merges the part with its fixtures.
The threshold only selects. Once the inlier set is fixed, the least-squares refit sets the final numbers, so a slightly generous t costs nothing on accuracy — provided the refit's residual RMS stays at the noise floor.
Should you denoise a point cloud before fitting a plane?
Yes: repair depth holes first, then remove isolated strays with statistical outlier removal — each point's mean distance to its k = 16 nearest neighbours, cut at 2–3σ of that statistic across the cloud — and never thin the cloud by random decimation before a fit.
Depth holes cluster on shiny or steep faces, so the surviving points over-represent the faces that returned well and pull the plane toward them; the repairs live in missing points in a 3D camera point cloud. Random decimation is worse than leaving the cloud alone: dropping points at random shifts local density and moves the fitted plane, as point cloud downsampling distortion shows; when a huge cloud must shrink, voxel-grid centroids preserve geometry. Denoising pays twice — a cleaner inlier set, and a higher w: the table above prices the same cloud at 168 iterations for w = 0.30 and 7 for w = 0.80.
Which sensor should feed the plane fit, and where does it run?
Match the sensor class to the surface: a laser profiler for machined parts where the threshold rides on noise, projected structured light for full-area single-shot clouds, ToF for coarse logistics depth — with the fit itself running on the vision controllers beside the camera.
For machined surfaces, datum and coplanarity checks, a laser profiler is the natural feed: dense calibrated profiles with a low, stable σ that keeps the 3σ threshold sharp.
- Type
- Laser profiler
For full-area coverage in one shot — flatness maps, gasket and spacer coplanarity, panel bow — a projected structured-light camera captures the whole field at once, and its cloud is where the 0.5–1 mm threshold range usually applies.
- Type
- Stereo / structured light
For pallet and parcel volume work, depth precision matters less than coverage and speed, which is ToF territory.
- Type
- Depth / ToF camera
The three classes side by side:
| Specification | MIS-DP3850-01P | MV-DPS200P-02 | MV-DT01WMU |
|---|---|---|---|
| Repeatability (Z-axis) | 1.68 μm @ data that sensor tests gauge block on optical platform1 | 0.02 mm @ 300 mm | ±(10+0.5%depth1)mm |
| Laser wavelength | 405 nm | – | 940 nm |
| Laser safety class | Class3R | – | Class 1 |
| Data interface | Gigabit Ethernet (1000 Mbit/s), compatible with Fast Ethernet (100 Mbit/s) | Gigabit Ethernet (1000 Mbit/s) | USB3.0 |
| Digital I/O | 12-pin M12 interface provides power and I/O, including opto-isolated input × 2 (Line 0/9), differential input × 2 (Line 3/6), and differential output × 1 (Line 1) | 12-pin M12 connector provides power supply and I/O, including opto-isolated input × 3 (Line 0/3/6), opto-isolated output × 3 (Line 1/4/7) | – |
| Power supply | 24 VDC | 24 V DC | 5 VDC (USB-powered) |
| Power consumption | 17.2 W @ 24 VDC | 11 W @ 24 V DC | 4.7 W @ 5 VDC (USB-powered) |
| Dimension | 144.5 mm × 96 mm × 58 mm | 126 mm × 90 mm × 50 mm | 91 mm × 26 mm × 31.2 mm |
| Weight | Approx. 950 g (2.1 lb.) | 0.74 kg | Approx. 70 g |
| Ingress protection | IP67 | IP67 | – |
| Temperature | Working temperature: 0 °C to 45 °C (32 °F to 113 °F); Storage temperature: –30 °C to 80 °C (–22 °F to 176 °F) | Working temperature: 0 °C to 45 °C (32 °F to 113 °F); Storage temperature: –30 °C to 80 °C (–22 °F to 176 °F) | Working temperature: 0 °C to 45 °C (32 °F to 113 °F); Storage temperature: –30 °C to 80 °C (–22 °F to 176 °F) |
| Humidity | 20% RH to 85% RH (no condensation) | 20% to 85% RH (non-condensing) | 20% RH to 85% RH (no condensation) |
| Price | $12,379.00 · quoted | $8,829.00 · quoted | Price on request |
Values as printed in each product's data sheet; open a part for its drawing and full specifications.
Moving web and large panels call for line-scan 2.5D instead: a system such as the MV-HLVS-16K100-L60 samples at 120 kHz across a 600 mm emitting area at 16K resolution, accumulating the cloud line by line while the belt moves.
Wherever the cloud comes from, the fit belongs on the controller that already owns the cameras and light channels. The MV-VC5525-256G70-NN pairs a 12th-generation Intel Core i5 with 32 GB of memory, PoE camera ports and 8 built-in light channels — headroom for capture, denoise, RANSAC and refit in one process.
- LAN ports
- 5+ LAN ports
- USB 3 ports
- 3-4 USB 3 ports
- PoE
- PoE camera ports
- Light outputs
- 8 built-in channels
The cycle budget follows from the arithmetic above: at one part per second, the whole chain has roughly 1,000 ms available and the cluttered 52,000-point case costs tens of milliseconds. Clouds near one million points still land in the same order single-threaded, with parallel cores in reserve. Filter hardware by what the cell already speaks in the 3D sensor finder.
When is a plane the wrong model for the points?
When the refit's residual RMS stays well above the point noise, the surface is not flat: a sine-shaped bow of ±0.1 mm forces a residual RMS near 0.07 mm (0.1/√2) that no placement of the plane can remove.
Check RMS = √(Σrᵢ² / N) after every refit and read it against σ. RMS near σ: the plane is valid and the tolerances computed from residuals are trustworthy. RMS at 2–3σ: look for a leftover cluster or a shallow bow — fit residuals against position and the pattern will say which. Curved and cylindrical faces need different tools entirely; the diagnostics continue in point cloud plane curvature and, for multiple surfaces, in the segmentation guide already linked above.
The decision, case by case:
- One clean surface inside the ROI: least squares alone — one pass, zero parameters, optimal for Gaussian noise.
- Fixtures, edges or background in the volume: statistical outlier removal, then RANSAC at t ≈ 3σ with iterations from the table, then a least-squares refit on the inliers.
- Residual RMS well above σ after the refit: stop tuning the fit — the model is wrong, so segment the cloud or switch to a curved model.
More capture-side and point-cloud guides live on the 3D vision topic page. If a cloud refuses to behave, send its noise figure and part drawing through the contact page and we will help you read it.
Questions
How many points does a plane fit actually need?
The fitted height's statistical uncertainty falls as σ/√N: with 0.05 mm point noise, 10,000 well-spread points give 0.05/√10,000 ≈ 0.0005 mm of random contribution, and a few hundred points already pin the tilt. Distribution matters more than count: cloud the whole surface, because corner-heavy or edge-clustered samples bend the normal exactly the way clustered outliers do. Past a few thousand points, calibration error, not statistics, sets the accuracy floor.
How do I get flatness and tilt angle out of a fitted plane?
From the slope form z = a·x + b·y + c: tilt = arctan(√(a² + b²)), in degrees once a and b are in mm per mm. Flatness is the spread of the inlier residuals — max minus min — read against the tolerance band. Compute both from the least-squares refit on RANSAC inliers, not from RANSAC's own plane, which the threshold quantizes.
Why does my fitted plane tilt when the part itself is flat?
Look for returns that share a location: a fixture edge, a clamp or a second surface inside the ROI bends the normal instead of averaging out the way random noise does. Run RANSAC with a tight threshold, then plot the inlier map over the field of view. Inliers should cover the part and nothing else; anything clustering along one edge explains the tilt.
Is RANSAC repeatable if it samples points at random?
Yes, once the confidence target is set: the iteration formula guarantees an outlier-free 3-point sample with 99% probability, and the least-squares refit on the selected inliers converges to the same plane whichever sample won. Pin the random seed during validation so run-to-run spreads vanish; in production the seed can drift without moving the result on a clean plane.
Can I run least squares first and skip RANSAC entirely?
Yes — when the ROI holds exactly one surface. Gate the cloud with a 2D ROI or a depth band before fitting; if the residual RMS then sits at the sensor's noise level, the cloud is clean and least squares is the statistically optimal, zero-parameter choice. RANSAC earns its keep only when fixtures, background or a second surface stay inside the measurement volume and cannot be gated out upstream.



