Solution (source code)

= Solution

For a scalar $u\in BV(\Omega)$, put $E_t=\{x\in\Omega:u(x)>t\}$. The <coarea formula for BV functions> is the <measure> identity
$$
\boxed{|Du|(A)=\int_{\mathbb R}\operatorname{Per}(E_t;A)\,dt}
$$
for every Borel $A\subseteq\Omega$. For almost every real $t$, $E_t$ is a <finite-perimeter set>, with $\operatorname{Per}(E_t;A)=|D\chi_{E_t}|(A)$. In particular $\operatorname{TV}(u)=\int_{\mathbb R}\operatorname{Per}(E_t;\Omega)dt$. This is <relative perimeter>: it counts interfaces inside $\Omega$, and does not add the boundary jump of a zero extension.