# Anisotropic Gaussian Filtering for Python Module

**URL:** https://discourse.slicer.org/t/anisotropic-gaussian-filtering-for-python-module/6221
**Category:** Support
**Created:** [March 20, 2019, 11:49pm UTC](https://discourse.slicer.org/t/anisotropic-gaussian-filtering-for-python-module/6221 "2019-03-20T23:49:13Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Prashant\_Pandey](https://avatars.discourse-cdn.com/v4/letter/p/c0e974/32.png) [@Prashant\_Pandey](https://discourse.slicer.org/u/Prashant_Pandey)
#### Post date: [March 20, 2019, 11:49pm UTC](https://discourse.slicer.org/t/anisotropic-gaussian-filtering-for-python-module/6221/1 "2019-03-20T23:49:13Z")

</div>

OS: Windows 10  
Slicer 4.8.1

Hi, I’m developing a python module consisting of some simple image processing. I want to implement an anisotropic 3D Gaussian filter to smooth an ultrasound sweep, but the only (already implemented) option I can is using the simpletITK and sitkUtils libraries, and these only seem to implement isotropic smoothing (same sigma in all 3 dimensions using sitk.SmoothRecursiveGaussian()). Is there an alternative function?

Side question, what are the units of sigma are for SmoothRecrusiveGaussian()? Are these mm or pixels? Thanks!

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [March 21, 2019, 3:12am UTC](https://discourse.slicer.org/t/anisotropic-gaussian-filtering-for-python-module/6221/2 "2019-03-21T03:12:23Z")

</div>

Anisotropic noise filters typically adjust smoothing factor depending on image content (e.g., smoothing is applied within homogeneous regions but not at high-gradient areas, to preserve contours) and not just use a fixed smoothing factor along each image axis.

Since properly implemented image processing filters always operate in physical space, you can easily tune smoothing factor differently along each image axes by temporarily changing the image spacing (change the image spacing, run the smoothing filter, and revert to the original image spacing).

---

<div class="post-metadata">

### Author: ![Prashant\_Pandey](https://avatars.discourse-cdn.com/v4/letter/p/c0e974/32.png) [@Prashant\_Pandey](https://discourse.slicer.org/u/Prashant_Pandey)
#### Post date: [March 22, 2019, 2:47am UTC](https://discourse.slicer.org/t/anisotropic-gaussian-filtering-for-python-module/6221/3 "2019-03-22T02:47:28Z")

</div>

Thanks. It does seem however that SimpleITK’s Gaussian smoothing filter should accept different sigmas for different axes: [https://github.com/SimpleITK/SimpleITK/releases/tag/v1.1.0](https://github.com/SimpleITK/SimpleITK/releases/tag/v1.1.0) but I can’t seem to make this work.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [March 22, 2019, 3:19am UTC](https://discourse.slicer.org/t/anisotropic-gaussian-filtering-for-python-module/6221/4 "2019-03-22T03:19:03Z")

</div>

You can follow this example:

[https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Running\_an\_ITK\_filter\_in\_Python\_using\_SimpleITK](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Running_an_ITK_filter_in_Python_using_SimpleITK)
