code: def majority(image, mask=None, iterations=1):
      '''A pixel takes the value of the majority of its neighbors
      
      '''
      global majority_table
      if mask is None:
          masked_image = image
      else:
          masked_image = image.astype(bool).copy()
          masked_image[~mask] = False
      result = table_lookup(masked_image, majority_table, False, iterations)
      if not mask is None:
          result[~mask] = image[~mask]
      return resulf majority(image, mask=None, iterations=1):
      '''A pixel takes the value of the majority of its neighbors
      
      '''
      global majority_table
      if mask is None:
          masked_image = image
      else:
          masked_image = image.astype(bool).copy()
          masked_image[~mask] = False
      result = table_lookup(masked_image, majority_table, False, iterations)
      if not mask is None:
          result[~mask] = image[~mask]
      return result
docs: A pixel takes the value of the majority of its neighbors