Morphological operations¶
In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import SimpleITK as sitk
print(sitk.Version())
from myshow import myshow
# Download data to work on
%run update_path_to_download_script
from downloaddata import fetch_data as fdata
SimpleITK Version: 2.4.0 (ITK 5.4) Compiled: Aug 15 2024 01:21:37
In [2]:
img = sitk.ReadImage(fdata("a_vm1108.png"))
myshow(img)
Fetching a_vm1108.png
libpng warning: iCCP: known incorrect sRGB profile libpng warning: iCCP: known incorrect sRGB profile libpng warning: iCCP: known incorrect sRGB profile
In [3]:
seeds = [[400, 500], [1500, 800]]
seg = sitk.VectorConfidenceConnected(
img, seedList=seeds, numberOfIterations=5, multiplier=7
)
In [4]:
myshow(sitk.Mask(img, seg == 0))
In [5]:
seg = sitk.BinaryClosingByReconstruction(seg, [100] * seg.GetDimension())
In [6]:
myshow(sitk.Mask(img, seg == 0))