code: def size_similarly(labels, secondary):
      """Size the secondary matrix similarly to the labels matrix
  
      labels - labels matrix
      secondary - a secondary image or labels matrix which might be of
                  different size.
      Return the resized secondary matrix and a mask indicating what portion
      of the secondary matrix is bogus (manufactured values).
  
      Either the mask is all ones or the result is a copy, so you can
      modify the output within the unmasked region w/o destroying the original.
      """
      if labels.shape[:2] == secondary.shape[:2]:
          return secondary, numpy.ones(secondary.shape, bool)
      if (
          labels.shape[0] <= secondary.shape[0]
          and labels.shape[1] <= secondary.shape[1]
      ):
          if secondary.ndim == 2:
              return (
                  secondary[: labels.shape[0], : labels.shape[1]],
                  numpy.ones(labels.shape, bool),
              )
          else:
              return (
                  secondary[: labels.shape[0], : labels.shape[1], :],
                  numpy.ones(labels.shape, bool),
              )
  
      #
      # Some portion of the secondary matrix does not cover the labels
      #
      result = numpy.zeros(
          list(labels.shape) + list(secondary.shape[2:]),
          secondary.dtype,
      )
      i_max = min(secondary.shape[0], labels.shape[0])
      j_max = min(secondary.shape[1], labels.shape[1])
      if secondary.ndim == 2:
          result[:i_max, :j_max] = secondary[:i_max, :j_max]
      else:
          result[:i_max, :j_max, :] = secondary[:i_max, :j_max, :]
      mask = numpy.zeros(labels.shape, bool)
      mask[:i_max, :j_max] = 1
      return result, mask
  
imports: import matplotlib.cm
  import numpy
  import skimage.color
  from ...preferences import get_default_colormap
label_desc: Use image node_id 2 for calling a global function with example usage: size_similarly(labels, secondary) and returns: result,  mask, secondary,  numpy, secondary,  numpy, secondary,  numpy