Do you see that?There are some small objects spread below the brain. and I want to remove them to get a whole clean brain.
A 3D image can be expressed as a 3D array in Numpy.
Below is an approach to remove small objects in 2D image.
from skimage import morphology
img_size = img.shape[0] * img.shape[1]
new_img = morphology.remove_small_objects(img, img_size*0.1)