# Reference count with Python

**URL:** <https://discourse.itk.org/t/reference-count-with-python/1483>\
**Category:** Beginner Questions\
**Tags:** python\
**Created:** [December 17, 2018, 2:09pm UTC](https://discourse.itk.org/t/reference-count-with-python/1483 "2018-12-17T14:09:33Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![fbudin](https://discourse.itk.org/user_avatar/discourse.itk.org/fbudin/32/14_2.png) [@fbudin](https://discourse.itk.org/u/fbudin)\
**Post date:** [December 21, 2018, 9:12pm UTC](https://discourse.itk.org/t/reference-count-with-python/1483/8 "2018-12-21T21:12:12Z")

</div>

Here is a short example how to use the Python pipeline:

> def my\_func():
> 
> ```
> my_pipeline=itk.pipeline()
> MedianFilter=itk.MeanImageFilter.IUC2IUC2.New()
> my_pipeline.connect(MedianFilter)
> my_pipeline.expose("Radius")
> thresholdFilter=itk.ThresholdImageFilter.IUC2.New()
> my_pipeline.connect(thresholdFilter)
> my_pipeline.expose("Lower")
> return my_pipeline
> 
> ```
> 
> my\_pipeline = my\_func()  
> my\_pipeline.SetInput(im)  
> my\_pipeline.SetRadius(5)  
> my\_pipeline.SetLower(100)  
> my\_pipeline.Update()  
> arr=itk.GetArrayFromImage(my\_pipeline.GetOutput())

You could also derive the itk.pipeline class and create your pipeline inside the constructor ` __init__ ` of the new pipeline class like it is done in [one ITK test](https://github.com/fbudin69500/ITK/blob/master/Wrapping/Generators/Python/Tests/templated_pipeline.py).

---

_[View the full topic](https://discourse.itk.org/t/reference-count-with-python/1483)._
