1

I have an image of size 301,512,512 which is a binary mask image .

the one values are concentrated near a patch,but there are a few holes inside the path.I would like to fill them with value one.

i have tried

img_fill_holes = scipy.ndimage.binary_fill_holes(array_to_be_filled[:,:,:]).astype(int)

and

import SimpleITK as sitk 
filledImage = sitk.BinaryFillhole(array_to_be_filled)

but both of the methods dont give the desired outputs, Any suggestions which may help me would be great. Thanks in advance.

Ryan
  • 8,459
  • 14
  • 40
  • 66
  • 1
    I don't think this is going to be a trivial task. I'd look into point cloud densification. Do you have sample data? – duhaime Apr 07 '18 at 10:45
  • Hi @duhaime what do you mean by sample data?, i have a few individual masks that i would like to this operation on – Ryan Apr 07 '18 at 10:55
  • I mean, would you be able to provide `array_to_be_filled` and the expected output? That could help expedite... – duhaime Apr 07 '18 at 10:59
  • Sorry duhaime, im not able to provide sample images due to some constariants.is there atleast a general method you could point me to,im stuck on this for a while now! – Ryan Apr 07 '18 at 11:06
  • can you make a toy array with holes that resemble your dataset's holes? That will help make this a minimal reproducible example. Also, can you explain why your binary mask has the shape it does? Those dimensions seem strange for a binary mask. – duhaime Apr 07 '18 at 11:23
  • its a lung mask ,and there are 301 slices of 512*512 images, let me see if i can make a toy example – Ryan Apr 07 '18 at 11:32

1 Answers1

3

BinaryFillHoles might not work because your "holes" are not holes topologically. They might be thin "tubes" that extend all the way to the "outside" of the object and thus topologically not being holes. But they would mostly appear as holes when looking at individual slices.

What you might try then is BinaryMorphologicalClosing in ITK or SimpleITK. Just make sure to SetRadius() to a value greater than your biggest "hole".

Dženan
  • 3,329
  • 3
  • 31
  • 44