code: def _image_tv(x, axis=0, n_points=3):
      """Computes total variation (TV) of matrix x across a given axis and
      along two directions.
  
      Parameters
      ----------
      x : 2D ndarray
          matrix x
      axis : int (0 or 1)
          Axis which TV will be calculated. Default a is set to 0.
      n_points : int
          Number of points to be included in TV calculation.
  
      Returns
      -------
      ptv : 2D ndarray
          Total variation calculated from the right neighbours of each point.
      ntv : 2D ndarray
          Total variation calculated from the left neighbours of each point.
  
      """
      xs = x.copy() if axis else x.T.copy()
  
      # Add copies of the data so that data extreme points are also analysed
      xs = np.concatenate(
          (xs[:, (-n_points - 1) :], xs, xs[:, 0 : (n_points + 1)]),
          axis=1,
      )
  
      ptv = np.absolute(
          xs[:, (n_points + 1) : (-n_points - 1)]
          - xs[:, (n_points + 2) : (-n_points)]
      )
      ntv = np.absolute(
          xs[:, (n_points + 1) : (-n_points - 1)]
          - xs[:, n_points : (-n_points - 2)]
      )
      for n in range(1, n_points):
          ptv = ptv + np.absolute(
              xs[:, (n_points + 1 + n) : (-n_points - 1 + n)]
              - xs[:, (n_points + 2 + n) : (-n_points + n)]
          )
          ntv = ntv + np.absolute(
              xs[:, (n_points + 1 - n) : (-n_points - 1 - n)]
              - xs[:, (n_points - n) : (-n_points - 2 - n)]
          )
  
      if axis:
          return ptv, ntv
      else:
          return ptv.T, ntv.T
  
file_path: dipy/dipy/denoise/gibbs.py
imports: from functools import partial
  from multiprocessing import Pool
  import numpy
  import scipy
  from dipy.utils.multiproc import determine_num_processes
  from dipy.utils.deprecator import deprecated_params
  import scipy.fft
label_desc: Use image node_id 1 for calling a global function with example usage: _image_tv(x, axis, n_points) and returns: ptv,  ntv, ptv,  ntv