开发者

PIL Plus/imToolkit replacements

开发者 https://www.devze.com 2023-03-27 09:35 出处:网络
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 exten

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

精彩评论

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

关注公众号