tfmri.image.total_variation

total_variation(image, axis=None, keepdims=False, name='total_variation')[source]

Calculate and return the total variation along the specified axes.

The total variation is the sum of the absolute differences for neighboring values in the input tensor. This is a measure of the noise present.

Supports ND inputs.

Parameters
  • image – A Tensor of shape [batch_size] + spatial_dims + [channels].

  • axis – An int or a list of ints. The axes along which the differences are taken. Defaults to list(range(1, tensor.shape.rank - 1)), i.e. differences are taken along all axes except the first and the last, which are assumed to be the batch and channel axes, respectively.

  • keepdims – A boolean. If True, keeps the singleton reduced dimensions. Defaults to False.

  • name – A name for the operation (optional).

Returns

The total variation of image.

Raises

ValueError – If tensor has unknown static rank or axis is out of bounds.