# How can I change the GrowCut's pseudocode?

**URL:** <https://discourse.slicer.org/t/how-can-i-change-the-growcuts-pseudocode/15467>\
**Category:** Support\
**Created:** [January 12, 2021, 8:17am UTC](https://discourse.slicer.org/t/how-can-i-change-the-growcuts-pseudocode/15467 "2021-01-12T08:17:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anonymous1](https://avatars.discourse-cdn.com/v4/letter/a/77aa72/32.png) [@Anonymous1](https://discourse.slicer.org/u/Anonymous1)\
**Post date:** [January 12, 2021, 8:17am UTC](https://discourse.slicer.org/t/how-can-i-change-the-growcuts-pseudocode/15467/1 "2021-01-12T08:17:09Z")

</div>

Hi!

I want to change the GrowCut’s pseudocode in Slicer 3D so that it has another function or an ‘extra’.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/7/479ae2ce36f397d3c435506b759d060f1c73db0e.png)  
This is the pseudocode that I need to change in Python. Does anyone know how I can do it?

Thank you

---

<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:** [January 12, 2021, 8:55pm UTC](https://discourse.slicer.org/t/how-can-i-change-the-growcuts-pseudocode/15467/2 "2021-01-12T20:55:54Z")

</div>

The code is implemented in C++ (running such pixel-level manipulation in Python would be incredibly slow). Once you build Slicer, you can easily modify the algorithm. The source code is [here](https://github.com/Slicer/Slicer/blob/master/Modules/Loadable/Segmentations/Logic/vtkImageGrowCutSegment.cxx).

We already improved upon the originally described cost, for example we added a m\_DistancePenalty term to add locality constraint. How do you plan to modify the cost term, for what purpose?

---

<div class="post-metadata">

**Author:** ![Anonymous1](https://avatars.discourse-cdn.com/v4/letter/a/77aa72/32.png) [@Anonymous1](https://discourse.slicer.org/u/Anonymous1)\
**Post date:** [January 12, 2021, 10:34pm UTC](https://discourse.slicer.org/t/how-can-i-change-the-growcuts-pseudocode/15467/3 "2021-01-12T22:34:10Z")

</div>

What I intend to do is to experiment with a specific function or routine that I have been able to implement from the GrowCut algorithm with the Python interpreter of Slicer4 and draw conclusions.
