code: def black_tophat(image, radius=None, mask=None, footprint=None):
      '''Black tophat filter an image using a circular structuring element
      
      image - image in question
      radius - radius of the circular structuring element. If no radius, use
               an 8-connected structuring element.
      mask  - mask of significant pixels in the image. Points outside of
              the mask will not participate in the morphological operations
      '''
      #
      # Subtract the image from the closing to get the bothat
      #
      final_image = closing(image, radius, mask, footprint) - image 
      #
      # Paint the masked pixels into the final image
      #
      if not mask is None:
          not_mask = np.logical_not(mask)
          final_image[not_mask] = image[not_mask]
      return final_imagf black_tophat(image, radius=None, mask=None, footprint=None):
      '''Black tophat filter an image using a circular structuring element
      
      image - image in question
      radius - radius of the circular structuring element. If no radius, use
               an 8-connected structuring element.
      mask  - mask of significant pixels in the image. Points outside of
              the mask will not participate in the morphological operations
      '''
      #
      # Subtract the image from the closing to get the bothat
      #
      final_image = closing(image, radius, mask, footprint) - image 
      #
      # Paint the masked pixels into the final image
      #
      if not mask is None:
          not_mask = np.logical_not(mask)
          final_image[not_mask] = image[not_mask]
      return final_image
docs: Black tophat filter an image using a circular structuring element
      
      image - image in question
      radius - radius of the circular structuring element. If no radius, use
               an 8-connected structuring element.
      mask  - mask of significant pixels in the image. Points outside of
              the mask will not participate in the morphological operations