Exemple #1
0
    def grid_sub_sampling(points,
                          features=None,
                          labels=None,
                          grid_size=0.1,
                          verbose=0):
        """
        CPP wrapper for a grid sub_sampling (method = barycenter for points and features
        :param points: (N, 3) matrix of input points
        :param features: optional (N, d) matrix of features (floating number)
        :param labels: optional (N,) matrix of integer labels
        :param grid_size: parameter defining the size of grid voxels
        :param verbose: 1 to display
        :return: sub_sampled points, with features and/or labels depending of the input
        """

        if (features is None) and (labels is None):
            return cpp_subsampling.compute(points,
                                           sampleDl=grid_size,
                                           verbose=verbose)
        elif labels is None:
            return cpp_subsampling.compute(points,
                                           features=features,
                                           sampleDl=grid_size,
                                           verbose=verbose)
        elif features is None:
            return cpp_subsampling.compute(points,
                                           classes=labels,
                                           sampleDl=grid_size,
                                           verbose=verbose)
        else:
            return cpp_subsampling.compute(points,
                                           features=features,
                                           classes=labels,
                                           sampleDl=grid_size,
                                           verbose=verbose)
Exemple #2
0
def grid_subsampling(points, features=None, labels=None, sampleDl=0.1, verbose=0):
    """CPP wrapper for a grid subsampling (method = barycenter for points and features)

    Args:
        points (tensor): input points, (N,3)
        features (tensor, optional): point features, (N,d)
        labels (tensor, optional): labels, (N,)
        sampleDl (float, optional): the size of grid voxels
        verbose (int, optional): 1 to display

    Returns:
        tuple: subsampled points, with features and/or labels depending of the input 
    """

    if (features is None) and (labels is None):
        return cpp_subsampling.compute(points, sampleDl=sampleDl, verbose=verbose)
    elif (labels is None):
        return cpp_subsampling.compute(points, features=features, sampleDl=sampleDl, verbose=verbose)
    elif (features is None):
        return cpp_subsampling.compute(points, classes=labels, sampleDl=sampleDl, verbose=verbose)
    else:
        return cpp_subsampling.compute(points, features=features, classes=labels, sampleDl=sampleDl, verbose=verbose)