Exemplo n.º 1
0
def Wavelet(extent=(-10, 10, -10, 10, -10, 10),
            center=(0, 0, 0),
            maximum=255,
            x_freq=60,
            y_freq=30,
            z_freq=40,
            x_mag=10,
            y_mag=18,
            z_mag=5,
            std=0.5,
            subsample_rate=1):
    """Create a wavelet."""
    wavelet_source = _vtk.vtkRTAnalyticSource()
    wavelet_source.SetWholeExtent(*extent)
    wavelet_source.SetCenter(center)
    wavelet_source.SetMaximum(maximum)
    wavelet_source.SetXFreq(x_freq)
    wavelet_source.SetYFreq(y_freq)
    wavelet_source.SetZFreq(z_freq)
    wavelet_source.SetXMag(x_mag)
    wavelet_source.SetYMag(y_mag)
    wavelet_source.SetZMag(z_mag)
    wavelet_source.SetStandardDeviation(std)
    wavelet_source.SetSubsampleRate(subsample_rate)
    wavelet_source.Update()
    return pyvista.wrap(wavelet_source.GetOutput())
Exemplo n.º 2
0
def Wavelet(extent=(-10, 10, -10, 10, -10, 10),
            center=(0, 0, 0),
            maximum=255,
            x_freq=60,
            y_freq=30,
            z_freq=40,
            x_mag=10,
            y_mag=18,
            z_mag=5,
            std=0.5,
            subsample_rate=1):
    """Create a wavelet.

    Produces images with pixel values determined by
    ``Maximum*Gaussian*x_mag*sin(x_freq*x)*sin(y_freq*y)*cos(z_freq*z)``

    Values are float scalars on point data with name ``"RTData"``.

    Parameters
    ----------
    extent : sequence, optional
        Set/Get the extent of the whole output image.  Default
        ``(-10, 10, -10, 10, -10, 10)``.

    center : list, optional
        Center of the wavelet.

    maximum : float, optional
        Maximum of the wavelet function.

    x_freq : float, optional
        Natural frequency in the x direction.

    y_freq : float, optional
        Natural frequency in the y direction.

    z_freq : float, optional
        Natural frequency in the z direction.

    x_mag : float, optional
        Magnitude in the x direction.

    y_mag : float, optional
        Magnitude in the y direction.

    z_mag : float, optional
        Magnitude in the z direction.

    std : float, optional
        Standard deviation.

    subsample_rate : int, optional
        The sub-sample rate.

    Returns
    -------
    pyvista.PolyData
        Wavelet mesh.

    Examples
    --------
    >>> import pyvista
    >>> wavelet = pyvista.Wavelet(extent=(0, 50, 0, 50, 0, 10), x_freq=20,
    ...                           y_freq=10, z_freq=1, x_mag=100, y_mag=100, 
    ...                           z_mag=1000)
    >>> wavelet.plot(show_scalar_bar=False)

    Extract lower valued cells of the wavelet and create a surface from it.

    >>> thresh = wavelet.threshold(800).extract_surface()
    >>> thresh.plot(show_scalar_bar=False)

    Smooth it to create "waves"

    >>> waves = thresh.smooth(n_iter=100, relaxation_factor=0.1)
    >>> waves.plot(color='white', smooth_shading=True, show_edges=True)

    """
    wavelet_source = _vtk.vtkRTAnalyticSource()
    wavelet_source.SetWholeExtent(*extent)
    wavelet_source.SetCenter(center)
    wavelet_source.SetMaximum(maximum)
    wavelet_source.SetXFreq(x_freq)
    wavelet_source.SetYFreq(y_freq)
    wavelet_source.SetZFreq(z_freq)
    wavelet_source.SetXMag(x_mag)
    wavelet_source.SetYMag(y_mag)
    wavelet_source.SetZMag(z_mag)
    wavelet_source.SetStandardDeviation(std)
    wavelet_source.SetSubsampleRate(subsample_rate)
    wavelet_source.Update()
    return pyvista.wrap(wavelet_source.GetOutput())