code: def haralick(
      f,
      ignore_zeros=False,
      preserve_haralick_bug=False,
      compute_14th_feature=False,
      return_mean=False,
      return_mean_ptp=False,
      use_x_minus_y_variance=False,
      distance=1,
  ):
      """
      feats = haralick(f,
              ignore_zeros=False,
              preserve_haralick_bug=False,
              compute_14th_feature=False,
              return_mean=False,
              return_mean_ptp=False,
              use_x_minus_y_variance=False,
              distance=1
              )
  
      Compute Haralick texture features
  
      Computes the Haralick texture features for the four 2-D directions or
      thirteen 3-D directions (depending on the dimensions of `f`).
  
      ``ignore_zeros`` can be used to have the function ignore any zero-valued
      pixels (as background). If there are no-nonzero neighbour pairs in all
      directions, an exception is raised. Note that this can happen even with
      some non-zero pixels, e.g.::
  
           0 0 0 0
           0 1 0 0
           0 1 0 0
           0 0 0 0
  
      would trigger an error when ``ignore_zeros=True`` as there are no
      horizontal non-zero pairs!
  
      Notes
      -----
      Haralick's paper has a typo in one of the equations. This function
      implements the correct feature unless `preserve_haralick_bug` is True. The
      only reason why you'd want the buggy behaviour is if you want to match
      another implementation.
  
      References
      ----------
  
      Cite the following reference for these features::
  
          @article{Haralick1973,
              author = {Haralick, Robert M. and Dinstein, Its'hak and Shanmugam, K.},
              journal = {Ieee Transactions On Systems Man And Cybernetics},
              number = {6},
              pages = {610--621},
              publisher = {IEEE},
              title = {Textural features for image classification},
              url = {https://ieeexplore.ieee.org/lpdocs/epic03/wrapper.htm?arnumber=4309314},
              volume = {3},
              year = {1973}
          }
  
      Parameters
      ----------
      f : ndarray of integer type
          input image. 2-D and 3-D images are supported.
      distance: int, optional (default=1)
          The distance to consider while computing the cooccurence matrix.
      ignore_zeros : bool, optional
          Whether to ignore zero pixels (default: False).
  
      Other Parameters
      ----------------
      preserve_haralick_bug : bool, optional
          whether to replicate Haralick's typo (default: False).
          You probably want to always set this to ``False`` unless you want to
          replicate someone else's wrong implementation.
      compute_14th_feature : bool, optional
          whether to compute & return the 14-th feature
      return_mean : bool, optional
          When set, the function returns the mean across all the directions
          (default: False).
      return_mean_ptp : bool, optional
          When set, the function returns the mean and ptp (point-to-point, i.e.,
          difference between max() and min()) across all the directions (default:
          False).
      use_x_minus_y_variance : bool, optional
          Feature 10 (index 9) has two interpretations, as the variance of \|x-y\|
          or as the variance of P(\|x-y\|). In order to achieve compatibility with
          other software and previous versions of mahotas, mahotas defaults to
          using ``VAR[P(\|x-y\|)]``; if this argument is True, then it uses
          ``VAR[\|x-y\|]`` (default: False)
  
  
      Returns
      -------
      feats : ndarray of np.double
          A 4x13 or 4x14 feature vector (one row per direction) if `f` is 2D,
          13x13 or 13x14 if it is 3D. The exact number of features depends on the
          value of ``compute_14th_feature`` Also, if either ``return_mean`` or
          ``return_mean_ptp`` is set, then a single dimensional array is
          returned.
      """
      _verify_is_integer_type(f, "mahotas.haralick")
  
      if len(f.shape) == 2:
          nr_dirs = len(_2d_deltas)
      elif len(f.shape) == 3:
          nr_dirs = len(_3d_deltas)
      else:
          raise ValueError(
              "mahotas.texture.haralick: Can only handle 2D and 3D images."
          )
      fm1 = f.max() + 1
      cmat = np.empty((fm1, fm1), np.int32)
  
      def all_cmatrices():
          for dir in range(nr_dirs):
              cooccurence(
                  f, dir, cmat, symmetric=True, distance=distance
              )
              yield cmat
  
      return haralick_features(
          all_cmatrices(),
          ignore_zeros=ignore_zeros,
          preserve_haralick_bug=preserve_haralick_bug,
          compute_14th_feature=compute_14th_feature,
          return_mean=return_mean,
          return_mean_ptp=return_mean_ptp,
          use_x_minus_y_variance=use_x_minus_y_variance,
      )
  
imports: import numpy
  from .None import _texture
  from ..internal import _verify_is_integer_type
label_desc: Use image node_id 2 for calling a global function with example usage: haralick(f, ignore_zeros, preserve_haralick_bug, compute_14th_feature, return_mean, return_mean_ptp, use_x_minus_y_variance, distance) and returns: haralick_features