# KdTree Python

**URL:** <https://discourse.itk.org/t/kdtree-python/2427>\
**Category:** Algorithms\
**Created:** [November 20, 2019, 1:44pm UTC](https://discourse.itk.org/t/kdtree-python/2427 "2019-11-20T13:44:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fraca](https://discourse.itk.org/letter_avatar_proxy/v4/letter/f/f19dbf/32.png) [@fraca](https://discourse.itk.org/u/fraca)\
**Post date:** [November 20, 2019, 1:44pm UTC](https://discourse.itk.org/t/kdtree-python/2427/1 "2019-11-20T13:44:18Z")

</div>

There’s a way to implement `itk::Statistics::WeightedCentroidKdTreeGenerator` and `itk::Statistics::KdTreeBasedKmeansEstimator` in python?

EDIT: i’m trying also to use `itk::SmoothingRecursiveGaussianImageFilter` but it seems that is not included in the itk library in python.

> import itk  
> ImageType=itk.Image[itk.F,3]  
> smooth=itk.SmoothingRecursiveGaussianImageFilter[ImageType,Imagetype].New()  
> AttributeError: module ‘itk’ has no attribute ‘SmoothingRecursiveGaussianImageFilter’

---

<div class="post-metadata">

**Author:** ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)\
**Post date:** [November 24, 2019, 3:10am UTC](https://discourse.itk.org/t/kdtree-python/2427/2 "2019-11-24T03:10:14Z")

</div>

> [@fraca](#):
>
> There’s a way to implement `itk::Statistics::WeightedCentroidKdTreeGenerator` and `itk::Statistics::KdTreeBasedKmeansEstimator` in python?

Yes – please review [this patch](https://github.com/InsightSoftwareConsortium/ITK/pull/1440).

> [@fraca](#):
>
> import itk  
> ImageType=itk.Image[itk.F,3]  
> smooth=itk.SmoothingRecursiveGaussianImageFilter[ImageType,ImageType].New()

This worked for me – what version of ITK are you using?

---

<div class="post-metadata">

**Author:** ![fraca](https://discourse.itk.org/letter_avatar_proxy/v4/letter/f/f19dbf/32.png) [@fraca](https://discourse.itk.org/u/fraca)\
**Post date:** [November 27, 2019, 12:05pm UTC](https://discourse.itk.org/t/kdtree-python/2427/3 "2019-11-27T12:05:49Z")

</div>

I’m using ITK 5.1b1 on Conda (jupyther) installed on Windows 10

![Cattura](https://discourse.itk.org/uploads/default/original/2X/6/6c1096851cf82f756a81912092b7b00d964f4dd8.png)

EDIT: I will try to downgrade and i will update you

---

<div class="post-metadata">

**Author:** ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)\
**Post date:** [December 1, 2019, 3:17pm UTC](https://discourse.itk.org/t/kdtree-python/2427/4 "2019-12-01T15:17:47Z")

</div>

@franca great, thanks for the information.

ITK 5.1 RC 1 will be coming out soon; it addresses issue identified in 5.0b1 and adds the k-d tree wrapping – we can try that.
