docs: def distance_color_labels(labels):
      '''Recolor a labels matrix so that adjacent labels have distant numbers
      
      '''
      #
      # Color labels so adjacent ones are most distant
      #
      colors = color_labels(labels, True)
      #
      # Order pixels by color, then label #
      #
      rlabels = labels.ravel()
      order = np.lexsort((rlabels, colors.ravel()))
      #
      # Construct color indices with the cumsum trick:
      # cumsum([0,0,1,0,1]) = [0,0,1,1,2]
      # and copy back into the color array, using the order.
      #
      different = np.hstack([[rlabels[order[0]] > 0],
                             rlabels[order[1:]] != rlabels[order[:-1]]])
      # We need to careful about ravel() returning a new object, but in the usual
      # case of colors having order='C', this won't create any copies.
      rcolor = colors.ravel()
      rcolor[order] = np.cumsum(different).astype(colors.dtype)
      return rcolor.reshape(colors.shape).astype(labels.dtype)