# Examples from pyvista.ImageDataFilters.median_smooth
# ====================================================

# First, create sample data to smooth. Here, we use
# `pyvista.perlin_noise()`
# to create meaningful data.
import numpy as np
import pyvista as pv
noise = pv.perlin_noise(0.1, (2, 5, 8), (0, 0, 0))
grid = pv.sample_function(
    noise, bounds=[0, 1, 0, 1, 0, 1], dim=(20, 20, 20)
)
grid.plot(show_scalar_bar=False)

# Next, smooth the sample data.
smoothed = grid.median_smooth(kernel_size=(10, 10, 10))
smoothed.plot(show_scalar_bar=False)

# ----------------------------------------------------------------------
# Generated by sphinx-examples-as-code https://github.com/pyvista/sphinx-examples-as-code
