Okay that will help us to help you in a better way.
so your basic task is to take a photograph, segment the image (different objects), identify the object, may be you should go through MATLAB examples of Digital Image proessing.
Here i am posting one for you ->
http://www.mathworks.in/help/images/image-enhancement-and-analysis.htmlthe program is all about counting the number of rice grains present, computing area of each rice grain & so on.
go through it, it will help you in some way!