code: def plot_img(ax, image, title, plot_text, image_values):
      """Plot an image, overlaying image values or indices."""
      ax.imshow(
          image, cmap="gray", aspect="equal", vmin=0, vmax=np.max(image)
      )
      ax.set_title(title)
      ax.set_yticks([])
      ax.set_xticks([])
  
      for x in np.arange(-0.5, image.shape[0], 1.0):
          ax.add_artist(
              Line2D(
                  (x, x),
                  (-0.5, image.shape[0] - 0.5),
                  color="blue",
                  linewidth=2,
              )
          )
  
      for y in np.arange(-0.5, image.shape[1], 1.0):
          ax.add_artist(
              Line2D(
                  (-0.5, image.shape[1]),
                  (y, y),
                  color="blue",
                  linewidth=2,
              )
          )
  
      if plot_text:
          for i, j in np.ndindex(*image_values.shape):
              ax.text(
                  j,
                  i,
                  image_values[i, j],
                  fontsize=8,
                  horizontalalignment="center",
                  verticalalignment="center",
                  color="red",
              )
      return
  
file_path: scikit-image/doc/examples/developers/plot_max_tree.py
imports: import numpy
  import matplotlib.pyplot
  from matplotlib.lines import Line2D
  from skimage.morphology import max_tree
  import networkx
label_desc: Use image node_id 1 for calling a global function with example usage: plot_img(ax, image, title, plot_text, image_values) without return types