How can I change the GrowCut's pseudocode?

Hi!

I want to change the GrowCut’s pseudocode in Slicer 3D so that it has another function or an ‘extra’.
image
This is the pseudocode that I need to change in Python. Does anyone know how I can do it?

Thank you

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.

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?

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.