4
$\begingroup$

TV is L1 norm of gradient of an image. So we've to find gradient of the image (which is still matrix, right?). Then take the sum of absolute values of the gradient matrix (So now it must be a scalar, right?).

Can I simply use imgradient function in matlab for first step? It gives two values magnitude and direction, so which one should I consider for next step?

After getting gradient matrix say Igrad, will just summing absolute values (sum(abs(Igrad(:))) give me TV? And it must be just a single scalar value right?

Thank you for reading. Keenly waiting for your reply.

$\endgroup$
6
$\begingroup$

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).

$\endgroup$
  • $\begingroup$ Thank you for your reply. I have one more query. Since the result of TV is scalar how are we adding it as a regularization term in many image restoration problems? Because images and other parameters are matrices. I don't know if this is proper place to ask this. Anyway thanks again $\endgroup$ – akhilc May 15 '14 at 16:05
  • $\begingroup$ Two solutions that have the same data fidelity score will probably have different TV score. Thus, among the possible solutions, the one with the lowest TV is kept. $\endgroup$ – sansuiso May 15 '14 at 20:53
  • $\begingroup$ I have a related inquiry. How can we calculate DTV (differential total variation) using Matlab? $\endgroup$ – Mohammad nagdawi Sep 1 '18 at 2:56
  • $\begingroup$ @Mohammadnagdawi, Have a look on my answer here - dsp.stackexchange.com/a/57985/128. There is a MATLAB code. $\endgroup$ – Royi Oct 19 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.