How to use the pyntcloud.scalar_fields.base.ScalarField function in pyntcloud

To help you get started, we’ve selected a few pyntcloud examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github daavoo / pyntcloud / pyntcloud / scalar_fields / sf_xyz.py View on Github external
import numpy as np
from ..geometry.coord_systems import (
    cartesian_to_spherical,
    cartesian_to_cylindrical
)
from ..ransac import single_fit, RANSAC_MODELS, RANSAC_SAMPLERS
from .base import ScalarField


class ScalarField_XYZ(ScalarField):
    def extract_info(self):
        self.points = self.pyntcloud.xyz


class PlaneFit(ScalarField_XYZ):
    """
    Get which points belong to the best RansacPlane found.
    """

    def __init__(self, pyntcloud, max_dist=1e-4, max_iterations=100, n_inliers_to_stop=None):
        self.model = RANSAC_MODELS["plane"]
        self.sampler = RANSAC_SAMPLERS["random"]
        self.name = "is_plane"
        self.model_kwargs = {"max_dist": max_dist}
        self.max_iterations = max_iterations
        self.n_inliers_to_stop = n_inliers_to_stop
github daavoo / pyntcloud / pyntcloud / scalar_fields / sf_eigenvalues.py View on Github external
import numpy as np
from .base import ScalarField


class ScalarField_EigenValues(ScalarField):
    """
    Parameters
    ----------
    ev : list of str
        Column names of the eigen values.
        Tip:
            ev = self.add_scalar_field("eigen_values", ...)

    """

    def __init__(self, pyntcloud, ev):
        super().__init__(pyntcloud)
        self.k = ev[0].split("e1")[1]
        self.ev = ev

    def extract_info(self):
github daavoo / pyntcloud / pyntcloud / scalar_fields / sf_normals.py View on Github external
import numpy as np
from .base import ScalarField


class ScalarField_Normals(ScalarField):
    def extract_info(self):
        self.normals = self.pyntcloud.points[["nx", "ny", "nz"]].values


class InclinationDegrees(ScalarField_Normals):
    """ Vertical inclination with respect to Z axis in degrees.
    """
    def compute(self):
        inclination = np.arccos(self.normals[:, -1])
        self.to_be_added["inclination_deg"] = np.rad2deg(inclination)


class InclinationRadians(ScalarField_Normals):
    """ Vertical inclination with respect to Z axis in radians.
    """
    def compute(self):
github daavoo / pyntcloud / pyntcloud / scalar_fields / sf_voxelgrid.py View on Github external
import numpy as np
from .base import ScalarField


class ScalarField_Voxelgrid(ScalarField):

    def __init__(self, pyntcloud, voxelgrid):
        super().__init__(pyntcloud)
        self.voxelgrid = voxelgrid

    def extract_info(self):
        self.voxelgrid = self.pyntcloud.structures[self.voxelgrid]


class VoxelX(ScalarField_Voxelgrid):
    """Voxel index along x axis."""
    def compute(self):
        name = "{}({})".format("voxel_x", self.voxelgrid.id)
        self.to_be_added[name] = self.voxelgrid.voxel_x
github daavoo / pyntcloud / pyntcloud / scalar_fields / sf_rgb.py View on Github external
import numpy as np
from .base import ScalarField


class ScalarField_RGB(ScalarField):
    def extract_info(self):
        self.rgb = self.pyntcloud.points[[
            "red", "green", "blue"]].values.astype("f")


class RGBIntensity(ScalarField_RGB):
    """ Red, green and blue intensity.
    """
    def compute(self):
        rgb_i = np.nan_to_num(
            self.rgb / np.sum(self.rgb, axis=1, keepdims=True))
        self.to_be_added["Ri"] = rgb_i[:, 0]
        self.to_be_added["Gi"] = rgb_i[:, 1]
        self.to_be_added["Bi"] = rgb_i[:, 2]
github daavoo / pyntcloud / pyntcloud / scalar_fields / sf_kneighbors.py View on Github external
import numpy as np

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import minimum_spanning_tree, depth_first_order

from .base import ScalarField
from ..utils.array import cov3D


class ScalarField_KNeighbors(ScalarField):
    """
    Parameters
    ----------
    k_neighbors: ndarray
        (N, k, 3) The k neighbors associated to each of the N points.
    """

    def __init__(self, pyntcloud, k_neighbors):
        super().__init__(pyntcloud)
        self.k_neighbors_idx = k_neighbors

    def extract_info(self):
        self.k_neighbors = self.pyntcloud.xyz[self.k_neighbors_idx]


class EigenValues(ScalarField_KNeighbors):