Segmenting a binary image into three parts


I am trying to segment a binary image into three parts, head, body, and tail. The binary image is a stack tiff file of a moving fruit fly larvae. I was able to do this initially by removing points within a certain distance of the centroid:

enter image description here

However, this broke down if the larvae’s head moved too close to the centroid, because the head points would then be removed:

enter image description here

I have been looking for creative solutions to this problem. Trying to fit it to a curved ellipsoid and get the vertice points that make up the tail and the head. However, I have not been very successful! I was curious if anyone had any insight into this problem or a suggestion for a creative solution? Thank you! 🙂

Here are the raw binary images:

1)

enter image description here

2)

enter image description here