How to detect objects and location i.e. coordinates from an image in matlab?

I need to detect an object and its location from an image. I have used different techniques to get it but i am able to identify the object only but not its location.  

Work out the centroid of the object that you have detected.
Jayefuu5 years ago
A sample image would be helpful. And the code that you've written so far.