ITK study notes (10) Deep learning segmentation post-processing to fill holes

ITK study notes (10) Deep learning segmentation post-processing to fill holes

The deep learning segmentation results may have incorrectly segmented parts, including holes, redundancy, and multiple connected domains.
The example below is an example of a hole.
insert image description here

Common sense tells us that there is no hole inside this organ, so we fill it in by post-processing, which can improve the segmentation accuracy.

This three-dimensional hole, we hope to have a convenient method to directly fill this three-dimensional hole. The binary hole filling method of SITK can be used. sitk.BinaryFillhole

sitk.BinaryFillhole
Note: This function is only for binary images (value 0 or 1)

import SimpleITK as sitk
import os
import glob

imglist= glob.glob('./*.nii.gz')
save_dir = './fillhole'

for img in imglist:
    img_nii = sitk.ReadImage(img, outputPixelType=sitk.sitkUInt16)
    img_fill = sitk.BinaryFillhole(img_nii)
    img_savedir = os.path.join(save_dir, img.split('/')[-1])

    sitk.WriteImage(img_fill, img_savedir)

This example shows how to fill holes in batches and save them.

There are no pores after treatment.
insert image description here

Reference: Deep learning, post-segmentation processing improves segmentation accuracy by filling holes

Guess you like

Origin blog.csdn.net/juluwangriyue/article/details/123826205