Approximating the total variation with finite differences or finite elements