Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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.

like image 752
Doomchinchilla Avatar asked Feb 13 '26 20:02

Doomchinchilla


1 Answers

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.

like image 59
unutbu Avatar answered Feb 15 '26 12:02

unutbu