3

I've been trying to find if there was any continuation of the abilities that were provided for PIL Plus for Python also known as imToolkit. I know that PIL Plus (aka imToolkit) was a commercial extension to Python. And that it was available to PIL support customers. I also know that the PIL Plus extension is no longer available.

My question is, "Were the features/capabilities of PIL Plus folded into any other toolkits or were they completely disregarded?"

What I'm trying to do is replicate what Matlab's imfill can perform and fill in 'holes' to create a better binary image mask.

Thanks for your help in advance.

agf
  • 171,228
  • 44
  • 289
  • 238
Doomchinchilla
  • 465
  • 5
  • 14

1 Answers1

2

I'm not sure how imfill works. Is it like this:

import numpy as np
import scipy.ndimage.morphology as morphology

bw = np.array([[0, 0, 0, 0, 0, 0, 0, 0],
               [0, 1, 1, 1, 1, 1, 0, 0],
               [0, 1, 0, 0, 0, 1, 0, 0],
               [0, 1, 0, 0, 0, 1, 0, 0],
               [0, 1, 0, 0, 0, 1, 0, 0],
               [0, 1, 1, 1, 1, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, 0]])

print(morphology.binary_fill_holes(bw).astype('int'))

yields

[[0 0 0 0 0 0 0 0]
 [0 1 1 1 1 1 0 0]
 [0 1 1 1 1 1 0 0]
 [0 1 1 1 1 1 0 0]
 [0 1 1 1 1 1 0 0]
 [0 1 1 1 1 0 0 0]
 [0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0]]

If so, you might want to look at scipy's morphology package.

unutbu
  • 842,883
  • 184
  • 1,785
  • 1,677
  • Thank you so much! I also found something called Mahotas that can be easy_installed which contains Otsu's method for thresholding. I'm not sure why this doesn't appear on my multiple google searches. Regardless thank you for finding this, makes my early morning coding much more pleasant. – Doomchinchilla Aug 10 '11 at 13:14