You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Chan-Vese Segmentation length term energy negative #6889
Hi, in the implementation of Chan-Vese segmentation, the length-term is defined as
def _cv_edge_length_term(phi, mu):
"""Returns the 'energy' contribution due to the length of the
edge between regions at each point, multiplied by a factor 'mu'.
"""
toret = _cv_curvature(phi)
return mu * toret
However, in the original paper, the length related energy should be more like |grad(phi(x, y))| * Delta(Phi(x, y)) dxdy. Here it is only computing the curvature and is sometimes negative. Therefore, the way it currently computes energy
Thanks for bringing this to my attention. It has been a long time since I worked on this, so I am a bit out of the loop. I briefly went through the current code, and the "energy" term is only computed as an indication rather than being used to update the result. However, it is concerning that there might be an error.
I will go through the papers once more, but it might take a bit of time to double check if everything is in order.
Apologies in advance for the delay, and please feel free to send me a reminder if I do not come back with an explanation.
I had a look at the code and the papers that I still have access to.
It appears that _cv_edge_length_term should indeed be updated such that it returns the absolute value of the current result. As mentioned, _cv_edge_length_term is only used to compute the "energy" and not directly involved in the iterative update of the level set itself, and I am using change between iterations as a stopping criterion rather than looking at energy. That code should be fine (assuming the algorithm described by P. Greuter remains correct without the in-place update).
I'll try to create a pull request to fix this in the coming days.
Here are the effects of changing the code on the "energy", when using absolute value rather than the current code.
Activity
stefanv commentedon Apr 12, 2023
This implementation is by @GGoussar from #1957
GGoussar commentedon Apr 15, 2023
Thanks for bringing this to my attention. It has been a long time since I worked on this, so I am a bit out of the loop. I briefly went through the current code, and the "energy" term is only computed as an indication rather than being used to update the result. However, it is concerning that there might be an error.
I will go through the papers once more, but it might take a bit of time to double check if everything is in order.
Apologies in advance for the delay, and please feel free to send me a reminder if I do not come back with an explanation.
stefanv commentedon Apr 15, 2023
Thanks so much for your effort, @GGoussar.
GGoussar commentedon Apr 16, 2023
I had a look at the code and the papers that I still have access to.
It appears that
_cv_edge_length_termshould indeed be updated such that it returns the absolute value of the current result. As mentioned,_cv_edge_length_termis only used to compute the "energy" and not directly involved in the iterative update of the level set itself, and I am using change between iterations as a stopping criterion rather than looking at energy. That code should be fine (assuming the algorithm described by P. Greuter remains correct without the in-place update).I'll try to create a pull request to fix this in the coming days.
Here are the effects of changing the code on the "energy", when using absolute value rather than the current code.
OLD

NEW
