How to Calculate Total Variation (TV) of an Image?
The Total Variation of an image $I$ can be computed using two formulas:


$TV(I) = \sum_{x} \| \nabla I (x) \|_1 $ (anisotropic TV);
$TV(I) = \sum_{x} \sqrt{ \| \nabla I (x) \|_2^2 }$ (isotropic TV).


In practice, both formulas yield almost the same result.

Using matlab, what you propose implements the first formula, while the second one can be obtained by sqrt(gradI_x.^2 + gradI_y.^2).