# Clustering adjacent points in 2D

I need to find all clusters of adjacent white points in a binary image. By term "adjacent" I mean that coordinates of two points differ by no more than 1 (i.e. the points {0,0} and {1,1} are adjacent). How to do this in Mathematica efficiently?

-

In version 7 and 8 you have MorphologicalComponents which can do this. Its default Method (version 8) is "Connected" with 8 point connectivity being the default (you can switch this off with the option CornerNeighbors->False). So, this seems ideally suited to your requirements.
An example from the MorphologicalComponents doc page:
@Sjoerd +1. You (and the creators of the Documentation) forgot to mention that the target clusters of points must be white on black background. My original image is negate of this and this is the reason why my first attempts to use MorphologicalComponents failed. –  Alexey Popkov May 21 '12 at 7:53
@AlexeyPopkov Just use ColorNegate to invert the image. –  Sjoerd C. de Vries May 21 '12 at 8:30