Edit mask shape (add/remove pixels) using sitk

I have multiple image sets with manually drawn masks (using ITK snap) and I want to edit the shape of the masks using simpleITK. For example, I tried sitk.BinaryDilate(label,1) to grow the regions by one pixel at the boundaries but instead it actually doubles the number of pixels.

My masks are hand drawn and have random shapes, is there a way to add/remove one or more row of pixels at the mask boundaries?

Thanks

Hello Omar,

It sounds like the binary morphology filters like BinaryDilate, BinaryErode, BinaryOpening and BinaryClosing are the filters needed. However, it’s is not clear how the output of BinaryDilate is does not match expectations. I suggest you experiment with these morphology filters to understand their behavior and aligned your expectations to the algorithms. If it is then needed sharing the input and output image would help us understand the undesirable behavior.

Good luck.

1 Like

Thanks alot Bradley.

Those filters are helpful. Although, I don’t know how to customise their action, I have used a combination of them and got some good results.