BinaryPruningImageFilter

Hello, I want to apply this function on my data, but I couldn’t understand the documentation and there’s no example. I would like an example on how can I apply it. Thanks in advance.

Hello @assia855,

First , see the wikipedia explanation of binary pruning.

As you appear to be using SimpleITK, exploring the effects of a filter, even without understanding the underlying algorithms, is very straightforward. I would encourage you to try things out using toy images. Sample code below:

import SimpleITK as sitk

# Create skeleton image with spurs
original_binary_image = sitk.Image([128,128], sitk.sitkUInt8)
original_binary_image[50,20:120] = 1
original_binary_image[50:60,50] = 1
original_binary_image[40:50,70] = 1
original_binary_image[50:100,100] = 1

# multiply by 255 so that the binary data is readily visible in Fiji
sitk.Show(original_binary_image*255, 'original')

binary_pruned = sitk.BinaryPruning(original_binary_image, 10)
sitk.Show(binary_pruned*255, 'pruned')
1 Like

Thank you so much. I thought that will help me to remove a small object from my image but inseat it helps in thinning the data which isn’t my goal for the moment. Do you know any operation in sitk who can help me in removing the small objects. Thanks a lot.

You could try binary opening, or approximation to that by use of signed distance field.

Thanks for the reply. Actually I want to improve the result of open binary filter.