Introduction - If you have any usage issues, please Google them yourself
Matlab code to get the number of objects in the image. Effectively count overlapping objects in an image. You can also use this code to extract the object with a very little modification.