Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a binarized image in Mathematica 9, and I would like to generate a list of coordinates for clusters of pixels connected through their Moore neighborhoods, e.g. $((c_{1,1},c_{1,2},...),(c_{2,1},c_{2,2},...),...)$ where some $c_{n,k}$ is the coordinate for the $k$th pixel in the $N$th set of pixels connected through their Moore neighborhoods.

Is there a simple way to proceed with Mathematica 9's image analysis tool set?

share|improve this question
Have you tried MorphologicalComponents@Dilation[image, 1]? – Dr. belisarius Jun 25 '13 at 3:35
@belisarius MorphologicalComponents seems to work fairly well, but what exactly is this command doing? – Bob Jun 25 '13 at 4:47
Have you read this? (... and all the answers to that question, BTW) – Dr. belisarius Jun 25 '13 at 11:36

From Belisarius' comment:

MorphologicalComponents@Dilation[image, 1]

The documentation states:

MorphologicalComponents assigns sequential integers to different connected components.


MorphologicalComponents by default treats all eight pixels surrounding a given pixel as adjacent.

This is precisely the connectedness you were looking for.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.