Consider an image (
I want to create a binary mask which will exactly cover the foreground.
If I do the following
b = DeleteSmallComponents@FillingTransform@Binarize[img]; skeleton = SkeletonTransform[b]; pruned = Pruning[skeleton, 1, 1]; mask = InverseDistanceTransform[pruned]
You can see that the head is not completely white as desired and this may be due to the fact that the bottom of the head is connected to the boundary of image. Secondly, near the neck (as indicated by the green line), some pixels are black which should be white.
How can I fix these two issues?