开发者

PIL Plus/imToolkit replacements

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜