My Requests


Least Squares Detection

This document describes the Least Squares (LSQ) Estimation of a pipe top as implemented in the Pipe detection option of the Validator module.

On this page:


The pipe center estimation comprises 4 steps:

Definition of Estimation window

The estimation window is defined using the shallowest point in a user defined window.
This window is referred to as the search window and it shows up as a magenta drag-box if the user selects the pipe detect menu option.

The default outline of the estimation window is defined as:

Top                          Shallowest/minimum Z-value in search window

Left/Right                +/- Pipe radius

Bottom                     Top – pipe-radius

The estimation window is therefore basically a rectangle that covers the top half of the pipe.

To allow for spikes in the search window, an estimation window is only considered valid if it contains a user selectable minimum number of points.
If the estimation window corresponding to the shallowest point in the search window contains fewer points than the user limit, the search window point is rejected and the one-but-shallowest search window point is used to define the estimation window.
This procedure is repeated until a valid search window is found or until all points in the search window have been tried.

Estimation of the pipe center

The center of the pipe is estimated by means of a least squares adjustment.
The adjustment is based on an observation model. (Not explained here.)

Testing of the pipe center estimate

Testing/validation of the result.

The pipe center estimate is subjected to two tests:

  • A spike or outlier test
  • A flip test

The outlier test computes the distance from a data point to the circle and rejects the point if the distance is larger than a limit that can be set by the user.
The flip test checks whether there are points in the estimation window below the estimated circle center.
By definition the estimation window corresponds to the top half of the pipe, hence points below the center indicate an error. 

The test conditions are translated into 3 actions:

  • Outlier test fails: simple outlier
    The observation is removed, and the pipe center is again estimated and tested.
  • Flip test fails or outlier test rejected for shallowest value in search window
    The estimation window is redefined based on the one-but shallowest value in the search window.
  • Exit: cannot find pipe
    If outliers are detected repeatedly, there is probably something wrong, e.g. many spikes, search window does not actually contain the pipe, and the routine exits without estimating a pipe.
Final estimate

Improved estimate based on re-centered estimation window.

After the initial estimate and testing, the search window is redefined for the final estimation.

The redefinition is based on:

  • Search space is circular
  • Search space is centered on the pipe estimate resulting from the previous step

An example is shown below.
After re-definition, the pipe is again estimated based on the least-squares adjustment, but testing is now skipped, since errors and spikes are likely to have been filtered out in the previous step.


The width of the circular search space is twice the outlier limit -  poor results may be expected if the limit is chosen very large.

User definable parameters

Least squares estimation can be enabled in the pipe detection dialog.
It is only available for Top of Pipe and is activated by selecting the label Least Squares.

There are 4 user definable parameters:

  • Minimum number of points in the estimation window
  • Outlier limit
  • Maximum percentage of outliers
  • Flip test margin

The first two parameters can be defined by the user in the pipe detection dialog, the other parameters can be changed in  the registry.

In the dialog the outlier limit is referred to as the “Spike limit” while the minimum number of points in the estimation space is referred to as “Min. hits on pipe”.


If the spike limit is set too low or the minimum number of hits on the pipe too high, no pipe center will be estimated and the pipe will not appear in the swath view.
If no pipe is visible, increase the spike limit, and decrease the minimum number of hits.

The maximum percentage of outliers and the flip test margin are stored in the registry under the keys:

  • LSQ nMaxOutlierRejectionPercentage
  • LSQ dFlipTestMargin

The default values are 30% and 0.1.
The Maximum outlier percentage is the percentage of points in the estimation window that is allowed to be detected as outlier before the algorithm gives up.
The FlipTest margin is a small offset used during the flip test to make the test somewhat less sensitive.

Return to: How-to Processing Pipeline Surveys