In the task, I got an discontinuous edge image, how could make it closed? in other word make the curve continuous. And the shape could be any kind, cause this the coutour shadow
Here is a slightly different approach to finish it off using Imagemagick
1) Threshold and dilate the contour
convert 8y0KL.jpg -threshold 50% -morphology dilate disk:11 step1.gif
2) Erode by a smaller amount
convert step1.gif -morphology erode disk:8 step2.gif
3) Pad by 1 pixel all around with black and floodfill the outside with white and remove the padded 1 pixel all around
convert step2.gif -bordercolor black -border 1 -fill white -draw "color 0,0 floodfill" -alpha off -shave 1x1 step3.gif
4) Erode by a smaller amount and get the edge on white side of the transition. Note that we started with dilate 11, then we eroded by 8, then we now erode by 3. So 8+3=11 should get us back to about the center line.
convert step3.gif -morphology erode disk:3 -morphology edgein diamond:1 step4.gif
5) Create animation to compare
convert -delay 50 8y0KL.jpg step4.gif -loop 0 animation.gif