예제 #1
0
def colored_quad_cloud(points,
                       amplitude,
                       indices,
                       colormap="viridis",
                       log_scale=False,
                       cm_resolution=256,
                       matrix=np.eye(4, dtype='f4'),
                       color=None,
                       name="quad"):
    #color = ensure_QColor(color)

    min_amplitude = float(amplitude.min())
    max_amplitude = float(amplitude.max())

    if log_scale:
        norm = mpl_colors.LogNorm(1, cm_resolution)
    else:
        norm = mpl_colors.Normalize(0, cm_resolution)

    colormap_ = getattr(cm, colormap)(norm(np.arange(cm_resolution)))
    cm_array = np.ascontiguousarray(colormap_ * 255, dtype=np.uint8)

    if color is None:
        effect = CustomEffects.color_map(Array.Array(ndarray=cm_array),
                                         amplitude.min(), amplitude.max())
    else:
        effect = CustomEffects.material(color=color)

    return Actors.Actor(geometry=Geometry.Geometry(
        indices=Array.Array(ndarray=indices),
        attribs=CustomAttribs.ColorsAttribs(
            vertices=Array.Array(ndarray=points),
            colors=Array.Array(ndarray=amplitude)),
        primitive_type=Geometry.PrimitiveType.TRIANGLES),
                        effect=effect,
                        transform=ensure_Transform(matrix),
                        name=name)
예제 #2
0
def colormap_point_cloud(points,
                         amplitude,
                         min_amplitude=None,
                         max_amplitude=None,
                         colormap="viridis",
                         log_scale=False,
                         cm_resolution=256,
                         matrix=np.eye(4, dtype='f4'),
                         name="cmap_pcl"):
    """
    resolution: the color map texture resolution, it affect granularity/precision of the color distribution only
    """

    if min_amplitude is None:
        min_amplitude = float(amplitude.min())

    if max_amplitude is None:
        max_amplitude = float(amplitude.max())

    if log_scale:
        norm = mpl_colors.LogNorm(1, cm_resolution)
    else:
        norm = mpl_colors.Normalize(0, cm_resolution)

    colormap_ = getattr(cm, colormap)(norm(np.arange(cm_resolution)))
    cm_array = np.ascontiguousarray(colormap_ * 255, dtype=np.uint8)

    return Actors.Actor(geometry=Geometry.Geometry(
        attribs=CustomAttribs.AmplitudeAttribs(
            vertices=Array.Array(ndarray=points),
            amplitude=Array.Array(ndarray=amplitude)),
        primitive_type=Geometry.PrimitiveType.POINTS),
                        effect=CustomEffects.color_map(
                            Array.Array(ndarray=cm_array), min_amplitude,
                            max_amplitude),
                        transform=ensure_Transform(matrix),
                        name=name)