Main Content

# removeInvalidPoints

Remove invalid points from point cloud

## Syntax

``[ptCloudOut,indices] = removeInvalidPoints(ptCloud)``

## Description

example

````[ptCloudOut,indices] = removeInvalidPoints(ptCloud)` removes points with `Inf` or `NaN` coordinate values from point cloud and returns the indices of valid points. NoteThe output is always an unorganized (X-by-3) point cloud. If the input `ptCloud` is an organized point cloud (M-by-N-by-3), the function returns the output as an unorganized point cloud. ```

## Examples

collapse all

Create a point cloud object with `NaN` and `Inf` values.

```xyzpoints = abs(randn(10,3)).*100; xyzpoints(1:2:4,:) = nan('single'); xyzpoints(6:2:10,:) = inf('single'); ptCloud = pointCloud(xyzpoints);```

Inspect the `Location` property of point cloud data to verify the occurrence of `NaN` and `Inf` values.

`ptCloud.Location`
```ans = 10×3 NaN NaN NaN 183.3885 303.4923 120.7487 NaN NaN NaN 86.2173 6.3055 163.0235 31.8765 71.4743 48.8894 Inf Inf Inf 43.3592 12.4144 72.6885 Inf Inf Inf 357.8397 140.9034 29.3871 Inf Inf Inf ```

Remove points with `NaN` and `Inf` values from the point cloud.

`ptCloudOut = removeInvalidPoints(ptCloud);`

Inspect the `Location` property of point cloud data to verify that the invalid points are removed.

`ptCloudOut.Location`
```ans = 5×3 183.3885 303.4923 120.7487 86.2173 6.3055 163.0235 31.8765 71.4743 48.8894 43.3592 12.4144 72.6885 357.8397 140.9034 29.3871 ```

## Input Arguments

collapse all

Point cloud, specified as a `pointCloud` object.

## Output Arguments

collapse all

Point cloud, returned as a `pointCloud` object with `Inf` or `NaN` coordinates removed.

Note

The output is always an unorganized (X-by-3) point cloud. If the input `ptCloud` is an organized point cloud (M-by-N-by-3), the function returns the output as an unorganized point cloud.

Indices of valid points in the point cloud, specified as a vector.

## Version History

Introduced in R2015a