Connected Component ManipulationΒΆ

The Brainlit package contains some functions to manipulate connected components. This is usually done on binary images, especially labels.

[1]:
import numpy as np
from brainlit.preprocessing import getLargestCC, removeSmallCCs
from skimage import data
import matplotlib.pyplot as plt

img = data.binary_blobs(512, 0.1, n_dim = 2, volume_fraction = 0.5, seed=10)
largest_cc = getLargestCC(img)
large_cc = removeSmallCCs(img, 10000)


plt.figure()
plt.subplot(1,3,1)
plt.imshow(img)
plt.title("Original Image")
plt.axis("Off")
plt.subplot(1,3,2)
plt.imshow(largest_cc)
plt.title("Largest CC")
plt.axis("Off")
plt.subplot(1,3,3)
plt.imshow(large_cc)
plt.title("Small CCs Removed")
plt.axis("Off")
plt.show()
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-7b5027618d01> in <module>
----> 1 import numpy as np
      2 from brainlit.preprocessing import getLargestCC, removeSmallCCs
      3 from skimage import data
      4 import matplotlib.pyplot as plt
      5

ModuleNotFoundError: No module named 'numpy'
[ ]: