code: def bwperim(bw, n=4, mode="constant"):
      """
      perim = bwperim(bw, n=4)
  
      Find the perimeter of objects in binary images.
  
      A pixel is part of an object perimeter if its value is one and there
      is at least one zero-valued pixel in its neighborhood.
  
      By default the neighborhood of a pixel is 4 nearest pixels, but
      if `n` is set to 8 the 8 nearest pixels will be considered.
  
      Parameters
      ----------
      bw : ndarray
          A black-and-white image (any other image will be converted to black & white)
      n : int, optional
          Connectivity. Must be 4 or 8 (default: 4)
      mode : {'reflect', 'nearest', 'wrap', 'mirror', 'constant' [default], 'ignore'}
          How to handle borders
  
      Returns
      -------
      perim : ndarray
          A boolean image
  
      See Also
      --------
      borders : function
          This is a more generic function
      """
      bw = bw != 0
      return bw & borders(bw, n, mode=mode)
  
imports: from __future__ import division
  import numpy
  from .morph import get_structuring_elem
  from .None import _labeled
  from .internal import _get_output
  from ._filters import _checked_mode2int
  import mahotas
label_desc: Use image node_id 9 for calling a global function with example usage: bwperim(bw, n, mode) and returns: unknown