code: def endpoints(image, mask=None):
      '''Remove all pixels from an image except for endpoints
      
      image - a skeletonized image
      mask -  a mask of pixels excluded from consideration
      
      1 0 0    ? 0 0
      0 1 0 -> 0 1 0
      0 0 0    0 0 0
      '''
      global endpoints_table
      if mask is None:
          masked_image = image
      else:
          masked_image = image.astype(bool).copy()
          masked_image[~mask] = False
      result = table_lookup(masked_image, endpoints_table, False, 1)
      if not mask is None:
          result[~mask] = image[~mask]
      return resulf endpoints(image, mask=None):
      '''Remove all pixels from an image except for endpoints
      
      image - a skeletonized image
      mask -  a mask of pixels excluded from consideration
      
      1 0 0    ? 0 0
      0 1 0 -> 0 1 0
      0 0 0    0 0 0
      '''
      global endpoints_table
      if mask is None:
          masked_image = image
      else:
          masked_image = image.astype(bool).copy()
          masked_image[~mask] = False
      result = table_lookup(masked_image, endpoints_table, False, 1)
      if not mask is None:
          result[~mask] = image[~mask]
      return result
docs: Remove all pixels from an image except for endpoints
      
      image - a skeletonized image
      mask -  a mask of pixels excluded from consideration
      
      1 0 0    ? 0 0
      0 1 0 -> 0 1 0
      0 0 0    0 0 0