docstr: Filter out objects touching the border
  
  In addition, if the image has a mask, filter out objects
  touching the border of the mask.
code: def filter_on_border(self, image, labeled_image):
      """Filter out objects touching the border
  
      In addition, if the image has a mask, filter out objects
      touching the border of the mask.
      """
      if self.exclude_border_objects.value:
          border_labels = list(labeled_image[0, :])
          border_labels.extend(labeled_image[:, 0])
          border_labels.extend(
              labeled_image[labeled_image.shape[0] - 1, :]
          )
          border_labels.extend(
              labeled_image[:, labeled_image.shape[1] - 1]
          )
          border_labels = numpy.array(border_labels)
          #
          # the following histogram has a value > 0 for any object
          # with a border pixel
          #
          histogram = scipy.sparse.coo_matrix(
              (
                  numpy.ones(border_labels.shape),
                  (border_labels, numpy.zeros(border_labels.shape)),
              ),
              shape=(numpy.max(labeled_image) + 1, 1),
          ).todense()
          histogram = numpy.array(histogram).flatten()
          if any(histogram[1:] > 0):
              histogram_image = histogram[labeled_image]
              labeled_image[histogram_image > 0] = 0
          elif image.has_mask:
              # The assumption here is that, if nothing touches the border,
              # the mask is a large, elliptical mask that tells you where the
              # well is. That's the way the old Matlab code works and it's duplicated here
              #
              # The operation below gets the mask pixels that are on the border of the mask
              # The erosion turns all pixels touching an edge to zero. The not of this
              # is the border + formerly masked-out pixels.
              mask_border = numpy.logical_not(
                  scipy.ndimage.binary_erosion(image.mask)
              )
              mask_border = numpy.logical_and(mask_border, image.mask)
              border_labels = labeled_image[mask_border]
              border_labels = border_labels.flatten()
              histogram = scipy.sparse.coo_matrix(
                  (
                      numpy.ones(border_labels.shape),
                      (border_labels, numpy.zeros(border_labels.shape)),
                  ),
                  shape=(numpy.max(labeled_image) + 1, 1),
              ).todense()
              histogram = numpy.array(histogram).flatten()
              if any(histogram[1:] > 0):
                  histogram_image = histogram[labeled_image]
                  labeled_image[histogram_image > 0] = 0
      return labeled_image
  
imports: import math
  import cellprofiler_core.module.image_segmentation
  import cellprofiler_core.object
  import centrosome.cpmorphology
  import centrosome.outline
  import centrosome.propagate
  import centrosome.threshold
  import numpy
  import scipy.ndimage
  import scipy.sparse
  import skimage.morphology
  import skimage.segmentation
  from cellprofiler_core.setting import Binary, Color
  from cellprofiler_core.setting.choice import Choice
  from cellprofiler_core.setting.range import IntegerRange
  from cellprofiler_core.setting.text import Integer, Float
  import cellprofiler.gui.help
  import cellprofiler.gui.help.content
  from cellprofiler.modules import _help, threshold
label_desc: Use image node_id 15 for calling the IdentifyPrimaryObjects obj's underlying member method code with example usage: obj.filter_on_border(image, labeled_image) and returns: labeled_image