Skip to content

Chan-Vese Segmentation length term energy negative #6889

Closed

Description

@xrhan

Description:

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

    lenenergy = _cv_edge_length_term(phi, mu)
    return np.sum(avgenergy) + np.sum(lenenergy)

also seems incorrect? The curvature term is used in the iterative update but for the energy it should be length instead?

Way to reproduce:

No response

Version information:

No response

Activity

  1. stefanv commented on Apr 12, 2023

    @stefanv
    Member

    This implementation is by @GGoussar from #1957

  2. GGoussar commented on Apr 15, 2023

    @GGoussar
    Contributor

    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.

  3. stefanv commented on Apr 15, 2023

    @stefanv
    Member

    Thanks so much for your effort, @GGoussar.

  4. GGoussar commented on Apr 16, 2023

    @GGoussar
    Contributor

    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.

    OLD
    old_energy_evolution

    NEW
    new_energy_evolution

  5. added this to the 0.21 milestone on Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions