How to count near circular objects in image
A simple approach to start with is to extract just the red channel, do some binary thresholding (e.g., Otsu's method), and then use standard morphology operators to find the blobs. You could try applying a closing operation.  Then, you could apply the watershed transformation or region flooding to identify the blobs where the tomatoes are.

A possibly better approach could be to convert to HSV representation, then generate a binary image as follows: every pixel whose hue matches the hue of a tomato (from some range you manually determine) is colored white, the rest are colored black.  Then you could continue with morphology operators and watershed/region flooding.

How well this will work will depend upon your requirements (e.g., whether you need to deal with occlusion) and on application-specific details (e.g., how constant in color the tomatoes are).

Take a look at the following questions on StackOverflow; they are quite relevant and will be helpful to you:


https://stackoverflow.com/q/11631188/781723
https://stackoverflow.com/q/4063965/781723
https://stackoverflow.com/q/5298884/781723
https://stackoverflow.com/q/4387488/781723
https://stackoverflow.com/q/10480609/781723
https://stackoverflow.com/q/6416117/781723
https://stackoverflow.com/q/10313602/781723
https://stackoverflow.com/q/18972932/781723
https://stackoverflow.com/q/10168686/781723
https://stackoverflow.com/q/8593091/781723
https://stackoverflow.com/q/16100708/781723


and also these resources:


http://blogs.mathworks.com/steve/2006/06/02/cell-segmentation/
http://www.mathworks.com/products/image/examples.html?file=%2Fproducts%2Fdemos%2Fshipping%2Fimages%2Fipexcell.html
https://en.wikipedia.org/wiki/Blob_detection