Search code examples
pythonimage-segmentationscikit-image

How to make skimage´s active contour get pushed into the corners


I am basically using skimage´s tutorial on morphological_geodesic_active_contour from their website. I am very happy with the results I already got, but I would prefer a result where the contour gets even pulled (or pushed) into the very edges of the circle.

In case you want to replicate the circle I created, here´s the code (the remaining code is from the above linked website):

im = np.zeros((100, 100))
for i in range(100):
    for j in range(100):
        if (i - 50) ** 2 + (j - 50) ** 2 <= 400:
            im[i, j] = 1.0
im[50:80, 50:80] = 0.0

I´d appreciated any help on that!

EDIT: As parameters for the morph GAC I used the following:

morphological_geodesic_active_contour(gimage, 50, init_ls,
                                      smoothing=1, balloon=-1,
                                      threshold=.9,
                                      iter_callback=callback)

Skiamge´s morphological GAC segmentation


Solution

  • It turns out, that the step gimage = inverse_gaussian_gradient(im) that is executed prior to running the actual algorithm has a parameter sigma that controls the smoothing being applied. By default, this is at sigma=5, but changing it to sigma=0.7 allows the GAC algorithm to get into the corners better.

    See the image for details.

    GAC result after adjusting sigma