code: def fill4(image, mask=None, iterations=1):
      '''Fill 4-connected black pixels
      
      x 1 x     x 1 x
      1 0 1 ->  1 1 1
      x 1 x     x 1 x
      '''
      global fill4_table
      if mask is None:
          masked_image = image
      else:
          masked_image = image.astype(bool).copy()
          masked_image[~mask] = True
      result = table_lookup(masked_image, fill4_table, True, iterations)
      if not mask is None:
          result[~mask] = image[~mask]
      return resulf fill4(image, mask=None, iterations=1):
      '''Fill 4-connected black pixels
      
      x 1 x     x 1 x
      1 0 1 ->  1 1 1
      x 1 x     x 1 x
      '''
      global fill4_table
      if mask is None:
          masked_image = image
      else:
          masked_image = image.astype(bool).copy()
          masked_image[~mask] = True
      result = table_lookup(masked_image, fill4_table, True, iterations)
      if not mask is None:
          result[~mask] = image[~mask]
      return result
docs: Fill 4-connected black pixels
      
      x 1 x     x 1 x
      1 0 1 ->  1 1 1
      x 1 x     x 1 x