I have a binary NIfTI image, i.e., an image of zeros (black) and ones (white) similar to this:

I've been trying for hours to create a tight hull around these white 1-components, so that in the end all pixels inside this hull are ones (white).
In the forum I came across the hint morphsnakes and this code snippet with this result:
def test_concave():
# Load the image.
imgcolor = imread("testimages/concave_hull.jpg")/255.0
img = rgb2gray(imgcolor)
# g(I)
gI = morphsnakes.gborders(img, alpha=1000, sigma=7)
# Morphological GAC. Initialization of the level-set.
mgac = morphsnakes.MorphGAC(gI, smoothing=3, threshold=0.55, balloon=-1)
mgac.levelset = circle_levelset(img.shape, (50, 199), 200)
# Visual evolution.
ppl.figure()
morphsnakes.evolve_visual(mgac, num_iters=62, background=imgcolor)
if __name__ == '__main__':
print """"""
test_concave()
ppl.show()
Unfortunately, I can't get the script to work, no matter which package (that are omitted in the script) I include. Can you please support me or offer an equivalent method?
