Piecewise-constant segmentation contrast threshold (source code)

= Piecewise-constant segmentation contrast threshold
{title2=$\beta L<\frac{a(A-a)}A d^2$}

Suppose two constant data intensities differ by $d$, have areas $a$ and $A-a$, and share an internal boundary of length $L$. Keeping the boundary costs $\beta L$ with zero fidelity; merging the two regions costs $a(A-a)d^2/A$ after fitting their common mean. The displayed inequality makes splitting cheaper among these two candidate geometries. This comparison does not prove either geometry is globally optimal among all partitions.