# filters.reciprocity

The Nearest-Neighbor Reciprocity Criterion was introduced in [Weyrich2004] and is based on a simple assumption, that valid points may be in the k-neighborhood of an outlier, but the outlier will most likely not be part of the valid point’s k-neighborhood.

The author suggests that the Nearest-Neighbor Reciprocity Criterion is more robust than both the Plane Fit and Miniball Criterion, being equally sensitive around smooth and detailed regions. The criterion does however produce invalid results near manifold borders.

The filter creates a single new dimension, `Reciprocity`, that records the percentage of points(in the range 0 to 100) that are considered uni-directional neighbors of the current point.

Note

To inspect the newly created, non-standard dimensions, be sure to write to an output format that can support arbitrary dimensions, such as BPF.

Default Embedded Stage

This stage is enabled by default

## Example

The sample pipeline below computes reciprocity with a neighborhood of 8 neighbors, followed by a range filter to crop out points whose `Reciprocity` percentage is less than 98% before writing the output.

    [
        "input.las",
        {
            "type":"filters.reciprocity",
            "knn":8
        },
        {
            "type":"filters.range",
            "limits":"Reciprocity[:98.0]"
        },
        "output.laz"
    ]

## Options

knn

  The number of k nearest neighbors. [Default: 8]

where

  An expression that limits points passed to a filter. Points that don’t pass the expression skip the stage but are available to subsequent stages in a pipeline. [Default: no filtering]

where_merge

  A strategy for merging points skipped by a ‘where’ option when running in standard mode. If `true`, the skipped points are added to the first point view returned by the skipped filter. If `false`, skipped points are placed in their own point view. If `auto`, skipped points are merged into the returned point view provided that only one point view is returned and it has the same point count as it did when the filter was run. [Default: `auto`]