<jupyter_start><jupyter_text>Gaussian Smoothing {gaussian_smoothing_example}==================Perform a Gaussian convolution on a uniformly gridded data set.`pyvista.UniformGrid`{.interpreted-text role="class"} data sets (a.k.a.images) a can be smoothed by convolving the image data set with aGaussian for one- to three-dimensional inputs. This is commonly referredto as Gaussian blurring and typically used to reduce noise or decreasethe detail of an image dataset<jupyter_code># sphinx_gallery_thumbnail_number = 2
import pyvista as pv
from pyvista import examples

# Load dataset
data = examples.download_gourds()

# Define a good point of view
cp = [
    (319.5, 239.5, 1053.7372980874645),
    (319.5, 239.5, 0.0),
    (0.0, 1.0, 0.0)
]<jupyter_output><empty_output><jupyter_text>Let\'s apply the gaussian smoothing with different values of standarddeviation.<jupyter_code>p = pv.Plotter(shape=(2, 2))

p.subplot(0, 0)
p.add_text("Original Image", font_size=24)
p.add_mesh(data, rgb=True)
p.camera_position = cp

p.subplot(0, 1)
p.add_text("Gaussian smoothing, std=2", font_size=24)
p.add_mesh(data.gaussian_smooth(std_dev=2.), rgb=True)
p.camera_position = cp

p.subplot(1, 0)
p.add_text("Gaussian smoothing, std=4", font_size=24)
p.add_mesh(data.gaussian_smooth(std_dev=4.), rgb=True)
p.camera_position = cp

p.subplot(1, 1)
p.add_text("Gaussian smoothing, std=8", font_size=24)
p.add_mesh(data.gaussian_smooth(std_dev=8.), rgb=True)
p.camera_position = cp

p.show()<jupyter_output><empty_output><jupyter_text>Now let\'s see an example on a 3D dataset with volume rendering:<jupyter_code>data = examples.download_brain()

smoothed_data = data.gaussian_smooth(std_dev=3.)


dargs = dict(clim=smoothed_data.get_data_range(),
             opacity=[0, 0, 0, 0.1, 0.3, 0.6, 1])

n = [100, 150, 200, 245, 255]

p = pv.Plotter(shape=(1, 2))
p.subplot(0, 0)
p.add_text("Original Image", font_size=24)
# p.add_mesh(data.contour(n), **dargs)
p.add_volume(data, **dargs)
p.subplot(0, 1)
p.add_text("Gaussian smoothing", font_size=24)
# p.add_mesh(smoothed_data.contour(n), **dargs)
p.add_volume(smoothed_data, **dargs)
p.link_views()
p.camera_position = [(-162.0, 704.8, 65.02),
                     (90.0, 108.0, 90.0),
                     (0.0068, 0.0447, 0.999)]
p.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14863102998696218, 'fraction_numerical': 0.06040851803563668, 'mean_word_length': 5.171581769436997, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '420106', 'license': 'MIT', 'n_tokens_mistral': 1005, 'n_tokens_neox': 882, 'n_words': 197, 'path': 'gaussian-smoothing.ipynb', 'repo_name': 'UttamBasu/ipygany_examples', 'size': '2301'}