Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I have suggestions for number 2. Number 1 is hard without being able to play with images, but you might want to try smoothing the image first. It looks very noisy.

For Number 2, I have two possibilities. The first is to take the moments of the points, which gives you the three values of the covariance matrix, and the center. You can use that to find the long axis of the covariance ellipse, and from the center that should intersect the nose and tail. If you only get a contour around 3/4 the body, say, then the center might be off.

Second is very similar, but use the function minAreaRect, to get a rotated rectangle. This gives you the long axis, and you can find the center easily. If you don't clean up the area outside the outline it could mess this up though.

Perhaps averaging the results from these two is best, but you'll have to experiment.