CropBoundary#

class CropBoundary[source]#

Bases: object

Drop points whose segment label is 0 or 1.

Keeps only points with segment not in {0, 1} – conventionally discarding unannotated/boundary classes – and subsamples every per-point key in index_valid_keys together via index_operator. Requires segment (asserted). Registered as CropBoundary – use this string as the type in a transform=[...] config list.

Note

Takes no constructor arguments. The removed labels (0 and 1) are hard-coded; segment is flattened before masking.

Example

>>> import numpy as np
>>> from pimm.datasets.transform import CropBoundary
>>> data = {"coord": np.array([[0., 0., 0.], [1., 1., 1.],
...                            [2., 2., 2.], [3., 3., 3.]], dtype="f4"),
...         "segment": np.array([0, 1, 2, 3])}
>>> out = CropBoundary()(data)  # drop points whose segment is 0 or 1
>>> out["segment"]
array([2, 3])
>>> out["coord"]  # coord cropped in lockstep with segment
array([[2., 2., 2.],
       [3., 3., 3.]], dtype=float32)