MATLAB: How to count repetitive features in an image

image blob countingImage Processing Toolbox

How to count the repetitive patterns in an image? Like the total of number of these tiny squares in the attached image?
Dose MatLab provide any image analysis package for this purpose?

Best Answer

Threshold and call bwlabel.
binaryImage = grayImage < someNumber;
[labeledImage, numBlobs] = bwlabel(binaryImage);
See my Image Segmentation Tutorial for a full demo. http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862