Dont mark the posts as solution if your problem is not solved.
From your posts. You have also another thread where you mentioned detecting ellipse. I feel you are doing it the hardway. Have you tried coverting the image to binary and using a particle filter