# Energy-term Derivation in the Level Set Formulation of Mumford-Shah

In the level set formulation of the piece-wise constant Mumford-Shah energy for two regions (see e.g. • this presentation on slide 41 • or this video • or page 4 of Chan & Vese, 2001), the energy function is $$E = \underbrace{\int_\Omega \left(\left(I-\mu_1\right)^2 - \left(I-\mu_2\right)^2\right) H\phi + \left(I-\mu_2\right)^2 \operatorname dx}_\text{data term} + \underbrace{\int_\Omega \left\|\nabla H\phi \right\|_1 \operatorname dx}_\text{perimeter penalty} \text, \tag{1} \label{eq:energy}$$ where $I$ is the image intensity at location $x$, the constants $\mu_1, \mu_2$ are the expected mean intensitites in the two regions that are to be separated, $\phi\left(x\right)$ is the surface and $H\phi$ is the Heaviside function of $\phi$, i.e. it is $H\phi = 1$ if $H\phi>0$ and $0$ else.

In all sources that I've looked into (e.g. Eq. (9) of Chan & Vese, 2001), the derivative of the data term of $E$ from Eq. \eqref{eq:energy} w.r.t. $\phi$ is given as \begin{align} \delta\left(\phi\right)\cdot\left(\left(I - \mu_1\right)^2 - \left(I - \mu_2\right)^2\right) \text, \tag{2} \label{eq:data_term_deriv} \end{align} where $\delta$ is the Dirac delta function, i.e. $\frac{\operatorname d}{\operatorname d\phi} H\phi = \delta$.

Why is the above the derivative of the data term w.r.t. $\phi$?

Shouldn't it rather be \begin{align} \frac{\operatorname d}{\operatorname d\phi} \int_\Omega \left(\left(I-\mu_1\right)^2 - \left(I-\mu_2\right)^2\right) \cdot H\phi + \left(I-\mu_2\right)^2 \operatorname dx &\\ = \int_\Omega \left(\left(I-\mu_1\right)^2 - \left(I-\mu_2\right)^2\right) \cdot \frac{\operatorname d}{\operatorname d\phi} H\phi\operatorname dx &\\ = \int_\Omega \left(\left(I-\mu_1\right)^2 - \left(I-\mu_2\right)^2\right) \cdot \delta\left(\phi\right) \operatorname dx &\text? \end{align} So where's the integral gone in Eq. \eqref{eq:data_term_deriv}? I'm aware of the shifting property of the $\delta$ function, which would explain the vanishing of the integral, but then the $\delta$ itself would vanish as well; yet, it's present in Eq. \eqref{eq:data_term_deriv}.