ImageMagick does a pretty good job of it with minimal effort. It is installed on most Linux distros anyway and available for OSX and Windows. Run from the commandline like this:
convert input.png \
-colorspace gray -negate -threshold 10% \
-define connected-components:verbose=true \
-define connected-components:area-threshold=800 \
-connected-components 8 -auto-level output.png
Output
Objects (id: bounding-box centroid area mean-color):
0: 431x424+0+0 209.2,207.5 135697 srgb(13,13,13)
109: 236x273+120+84 231.7,223.0 47047 srgb(255,255,255)

If you change the threshold to only show blobs with an area greater than, say 50, you get this:
Objects (id: bounding-box centroid area mean-color):
0: 431x424+0+0 210.2,208.5 134262 srgb(11,11,11)
109: 236x273+120+84 231.7,223.0 47047 srgb(255,255,255)
1: 40x20+1+1 16.9,9.5 605 srgb(255,255,255)
190: 12x15+309+153 314.2,160.1 126 srgb(253,253,253)
83: 12x13+142+71 148.1,76.7 90 srgb(255,255,255)
164: 12x17+140+132 146.0,140.1 90 srgb(255,255,255)
347: 10x12+50+304 54.5,309.6 85 srgb(255,255,255)
440: 11x11+278+399 282.6,404.2 79 srgb(255,255,255)
448: 6x15+425+403 427.9,409.9 71 srgb(255,255,255)
151: 9x11+145+122 149.2,126.4 68 srgb(255,255,255)
93: 11x9+105+75 110.1,79.6 61 srgb(255,255,255)
170: 9x10+91+136 95.1,140.8 58 srgb(255,255,255)
258: 9x10+107+220 110.8,225.1 52 srgb(255,255,255)
53: 10x8+64+47 68.5,50.2 50 srgb(255,255,255)

Alternatively, if you want some C code, you could look at my answer here to this question: