pchandler.scalar_fields.scalar_fields
Per-point typed scalar-field classes (RGB, normals, intensity, segmentation, generic).
Classes
Abstract scalar field with validation and conversion back to the original dtype. |
|
Contains the original dtype and limits of an array used to create a ScalarField array. |
|
Normal-vector field represented by a scalar field triplet of float32 unit vectors. |
|
Scalar field whose values are normalised into |
|
RGB / Color field, represented by a scalar field triplet of uint8 values. |
|
Generic scalar field backed by a 1D vector. |
|
Scalar field constrained to boolean arrays. |
|
Scalar field constrained to |
|
Scalar field triplet ( |
|
Scalar field constrained to |
|
Segmentation-map scalar field (uint8 or uint16) keyed by point-cloud segment. |
- class pchandler.scalar_fields.scalar_fields.ScalarField
Bases:
BaseVector,AbstractScalarFieldGeneric scalar field backed by a 1D vector.
- __init__(arr, name=None, origin_dtype=None)
Initialise a
ScalarFieldfrom a 1D vector.- Parameters:
arr (VectorT | Array_Nx3_T | Self) – Underlying 1D values.
name (SfNameT, optional) – Field name; inferred from
arror class default if omitted.origin_dtype (SfOrigDtT, optional) – Original
DtypeState; auto-generated if omitted.
- class pchandler.scalar_fields.scalar_fields.RGBFields
Bases:
ScalarFieldTripletRGB / Color field, represented by a scalar field triplet of uint8 values.
- Parameters:
arr (Array_Nx3_Uint8_T) – Underlying
(N, 3)uint8 array.
- arr: Array_Nx3_Uint8_T
Contains the raw numpy ndarray data
- __init__(arr, **kwargs)
Initialise an RGB field.
Will convert any floating point values to uint8.
- property red: GSEGUtils.base_types.Vector_Uint8_T
Return the red component of the RGB values.
- Return type:
Vector_Uint8_T
- property r: GSEGUtils.base_types.Vector_Uint8_T
Return the red component of the RGB values.
- Return type:
Vector_Uint8_T
- property green: GSEGUtils.base_types.Vector_Uint8_T
Return the green component of the RGB values.
- Return type:
Vector_Uint8_T
- property g: GSEGUtils.base_types.Vector_Uint8_T
Return the green component of the RGB values.
- Return type:
Vector_Uint8_T
- property blue: GSEGUtils.base_types.Vector_Uint8_T
Return the blue component of the RGB values.
- Return type:
Vector_Uint8_T
- property b: GSEGUtils.base_types.Vector_Uint8_T
Return the blue component of the RGB values.
- Return type:
Vector_Uint8_T
- as_normalised_float32()
Return the RGB values as a normalized float32 array in the range of [0,1].
- Return type:
Array_Nx3_Float32_T
- origin_dtype: DtypeState
- class pchandler.scalar_fields.scalar_fields.NormalFields
Bases:
ScalarFieldTripletNormal-vector field represented by a scalar field triplet of float32 unit vectors.
- Parameters:
arr (Array_Nx3_Float32_T) – Underlying
(N, 3)float32 array.
- arr: Array_Nx3_Float32_T
Contains the raw numpy ndarray data
- __init__(arr, **kwargs)
Initialize a normal vector field.
Values will be normalized to unit vectors and converted to float32.
- Parameters:
arr (Array_Nx3_Float_T | Self)
kwargs (Unpack[_ScalarKwargT])
- property nx: GSEGUtils.base_types.Vector_Float32_T
Return the X component of the normal vector.
- property ny: GSEGUtils.base_types.Vector_Float32_T
Return the Y component of the normal vector.
- property nz: GSEGUtils.base_types.Vector_Float32_T
Return the Z component of the normal vector.
- classmethod initialize(length, value=None)
Build a
NormalFieldsof lengthlength, optionally seeded withvalue.- Parameters:
length (int) – Number of rows to allocate.
value (Array_Nx3_Float32_T, optional) – Existing values to initialise the array with (defaults to unit vectors along
+Z).
- Returns:
New normals field of the requested length.
- Return type:
- origin_dtype: DtypeState
- class pchandler.scalar_fields.scalar_fields.SegmentationMap
Bases:
ScalarFieldSegmentation-map scalar field (uint8 or uint16) keyed by point-cloud segment.
- Parameters:
arr (Vector_Uint8_T | Vector_Uint16_T) – Per-point segment index.
- arr: Vector_Uint8_T | Vector_Uint16_T
Contains the raw numpy ndarray data
- __init__(arr, **kwargs)
Initialise a
SegmentationMapfrom a uint8/uint16 vector.
- classmethod initialize(name, pt_cloud_sizes)
Initialize a segmentation map scalar field based on the number of points in each point cloud.
- Parameters:
- Return type:
- class pchandler.scalar_fields.scalar_fields.ScalarFieldUint8
Bases:
ScalarFieldScalar field constrained to
uint8dtype.- arr: Vector_Uint8_T
Contains the raw numpy ndarray data
- __init__(arr, **kwargs)
Initialise a
ScalarFieldUint8from a uint8 vector.- Parameters:
arr (Vector_Uint8_T | Self) – Underlying uint8 vector.
**kwargs (Unpack[_ScalarKwargT]) – Optional
nameandorigin_dtype.
- class pchandler.scalar_fields.scalar_fields.ScalarFieldBoolean
Bases:
ScalarFieldScalar field constrained to boolean arrays.
- arr: Vector_Bool_T
Contains the raw numpy ndarray data
- __init__(arr, **kwargs)
Initialise a
ScalarFieldBooleanfrom a boolean vector.- Parameters:
arr (Vector_Bool_T | Self) – Underlying boolean vector.
**kwargs (Unpack[_ScalarKwargT]) – Optional
nameandorigin_dtype.
- class pchandler.scalar_fields.scalar_fields.ScalarFieldFloat32
Bases:
ScalarFieldScalar field constrained to
float32dtype.- arr: Vector_Float32_T
Contains the raw numpy ndarray data
- __init__(arr, **kwargs)
Initialise a
ScalarFieldFloat32from a float32 vector.- Parameters:
arr (Vector_Float32_T | Self) – Underlying float32 vector.
**kwargs (Unpack[_ScalarKwargT]) – Optional
nameandorigin_dtype.
- class pchandler.scalar_fields.scalar_fields.NormalisedInt16ScalarField
Bases:
ScalarFieldScalar field whose values are normalised into
int16at validation time.- arr: Annotated[Vector_Int16_T, BeforeValidator(normalize_int16)]
Contains the raw numpy ndarray data
- __init__(arr, **kwargs)
Initialise a
NormalisedInt16ScalarFieldfrom any numeric vector.- Parameters:
arr (VectorT | Self) – Underlying values (will be normalised to int16).
**kwargs (Unpack[_ScalarKwargT]) – Optional
nameandorigin_dtype.
- to_uint8()
Return a converted copy of the scalar field with the dtype set to uint8.
- Returns:
New uint8 scalar field carrying the same name and origin dtype.
- Return type:
- class pchandler.scalar_fields.scalar_fields.AbstractScalarField
Bases:
FixedLengthArrayAbstract scalar field with validation and conversion back to the original dtype.
- Parameters:
arr (VectorT | Array_Nx3_T) – Underlying array of values.
name (SfNameT) – Field name (lower-cased).
origin_dtype (SfOrigDtT) – Original
DtypeStatecaptured at construction.
- name: LowerStr
- origin_dtype: DtypeState
- __init__(arr, name=None, origin_dtype=None)
Initialise a scalar field.
- Parameters:
arr (VectorT | Array_Nx3_T | Self)
name (SfNameT, optional)
origin_dtype (SfOrigDtT, optional)
- get_original_data()
Return the original data stored in the scalar field.
Performs the inverse normalization from the DtypeState stored with the scalar field.
- Return type:
Array_Nx3_T | BaseVector
- class pchandler.scalar_fields.scalar_fields.DtypeState
Bases:
NamedTupleContains the original dtype and limits of an array used to create a ScalarField array.
- Parameters:
- dtype: type[Any] | dtype[Any] | _SupportsDType[dtype[Any]] | tuple[Any, Any] | list[Any] | _DTypeDict | str | None
Alias for field number 0
- classmethod generate(array)
Build a
DtypeStatefrom an array’s dtype and min/max range.- Parameters:
array (ArrayT | ArrayNx3 | BaseVector) – Source array.
- Returns:
New state instance.
- Return type:
- Raises:
TypeError – If
arraydoes not expose adtypeattribute.
- static validate(obj)
Ensure that the lower value is strictly less than the upper value.
- Parameters:
obj (DtypeState) – State to validate; no-op if
objisNone.- Raises:
ValueError – If
obj.lower >= obj.upper.
- static __new__(_cls, dtype, lower, upper)
Create new instance of DtypeState(dtype, lower, upper)