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 suppo开发者_运维知识库rt 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.
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.
精彩评论