src.utils.ptransf.point_cloud_sampler
Classes
|
- class src.utils.ptransf.point_cloud_sampler.PointCloudSampler(**kwargs)
- Author:
Alberto M. Esmoris Pena
Class for transforming points following one or many sampling strategies.
- Variables:
neighborhood_sampling (dict or None) –
The specification of the neighborhood sampling strategy, if any.
The format for this attribute should be like:
{ "support_conditions": [ { "value_name": "ClassAmbiguity", "condition_type": "greater_than_or_equal_to", "value_target": 0.5, "action": "preserve" } ], "support_strategy": "fps", "support_strategy_num_points": 100000, "support_strategy_fast": true, "support_chunk_size": 50000, "center_on_pcloud": false, "neighborhood": { "type": "sphere", "radius": 2.5, "separation_factor": 0 }, "neighborhoods_per_iter": 10000, "nthreads": -1 }
- static extract_ptransf_args(spec)
Extract the arguments to initialize/instantiate a PointCloudSampler.
- Parameters:
spec – The key-word specification containing the arguments.
- Returns:
The arguments to initialize/instantiate a PointCloudSampler.
- Return type:
dict
- __init__(**kwargs)
Initialize/instantiate a PointCloudSampler.
- Parameters:
kwargs – The attributes for the PointCloudSampler.
- transform(X=None, F=None, y=None, yhat=None, out_prefix=None, **kwargs)
The fundamental point transform logic defining the point cloud sampler.
- transform_pcloud(pcloud, out_prefix=None, **kwargs)
Update the input point cloud in place.
See
PointCloudSampler.transform()andPointTransformer.transform_pcloud().
- apply_neighborhood_sampling(X, F, y, yhat, out_prefix=None, **kwargs)
Compute a neighborhood sampling. This strategy considers each support point (for example, the entire X, or a subset of X that satisfied the given conditions) and computes it neighborhood. The indices of the points in the neighborhoods are then returned.
- Parameters:
X (
np.ndarray) – The structure space matrix representing the point cloud to be sampled.F (
np.ndarrayor None) – the feature space matrix representing the point cloud to be sampled.y (
np.ndarrayor None) – The references of the point cloud to be sampled (typically a vector of classes).yhat (
np.ndarrayor None) – The predictions on the point cloud to be sampled ( typically a vector of classes).out_prefix – See
PointTransformerandPointTransformer.transform().
- Returns:
List with the indices of the points to be included in the sampled version of the point cloud.
- Return type:
List of int
- static update_selected_indices(base_selected_indices, new_selected_indices, X, F, y, yhat)
Merge the current selected indices with the new selected indices. Note that the resulting selected indices are built by selecting those indices at
base_selected_indicesspecified bynew_selected_indices.- Returns:
The new list of selected indices.
- Return type:
list
- filter_support_points(conditions, X, F, y, yhat, min_distance=None, out_prefix=None)
Filter the given point cloud considering the given conditions to obtain the corresponding support points.
- Parameters:
conditions (list of dict) –
A list with the dictionary-like specifications of each condition that must be applied. Each condition must specify:
- –
"value_name"The name of the value involved in the condition.
- –
"condition_type"The relational governing the condition, i.e.,
"not_equals"(\(\neq\)),"equals"(\(=\)),"less_than"(\(<\)),"less_than_or_equal_to"(\(\leq\)),"greater_than"(\(>\)),"greater_than_or_equal_to"(\(\geq\)),"in"(\(\in\)), or"not_in"(\(\notin\)).- –
"value_target"The value for the rhs of the relational. Note that the lhs will be the corresponding value from the point cloud.
- –
"action"Whether the conditions define points that must be preserved (
"preserve") or discarded ("discard").
- –
X (
np.ndarrayor None) – The structure space matrix representing the point cloud.F (
np.ndarrayor None) – The feature space matrix representing the point cloud.y (
np.ndarrayor None) – The references of the point cloud.yhat (
np.ndarrayor None) – The predictions of the point cloud.min_distance (float or None) – When given, support points that are closer to other support points in less than min_distance will be discarded.
out_prefix – See
PointTransformerandPointTransformer.transform().
- Returns:
The structure space matrix representing the support points.
- Return type:
np.ndarray
- apply_condition(cond, X, F, y, yhat)
Apply the given condition to the given point cloud. See
PointCloudSampler.filter_support_points()for further details when using this function to filter the support points.- Returns:
The structure space, feature space, references, and predictions of the filtered point cloud.
- Return type:
tuple of
np.ndarray
- static compute_neighborhoods(X, X_sup, neighborhood_spec, support_chunk_size=0, kdt=None)
Compute the neighborhood of each support point on X.
See
SupportNeighborhoodsfor more details.- Parameters:
X_sup (
np.ndarray) – The support structure space.X (
np.ndarray) – The structure space where the neighbors must be.neighborhood_spec (dict) – The key-word specification of the neighborhood.
support_chunk_size (int) – See
SupportNeighborhoods.kdt – See
SupportNeighborhoods.compute().