Generating a list of contour pixels for a morphological component


I have a set of pixilated shapes, and after transforming each shape into a morphological component, I want to be able to return the coordinates for pixels that lie on the contour of the shape. More specifically, I want pixels that have some number of background neighbors in their von Neumann or Moore neighborhoods.

Say this "shape" is a phrase like the following:

We can isolate and color all of the morphological components / pixilated shapes we care about as follows:

shape = Import[""]
m = MorphologicalComponents[ColorNegate[ImageCrop[shape, {300, 100}]]] // Colorize

How can we return a von Neumann or Moore-neighborhood connected set of contour pixels for each component?


Posted 2013-09-08T04:04:32.700

Reputation: 105



Vitaliy Kaurov

Posted 2013-09-08T04:04:32.700

Reputation: 66 672

Thanks. As a quick question, can you explain the Range[12] choice? – LCook – 2013-09-08T04:22:04.750

@user9408 In your image you have 10 letter and 2 punctuation signs. Also Union[Flatten[m]]. Could you please register a name here so it is easier to refer to it? – Vitaliy Kaurov – 2013-09-08T04:27:19.377

Sorry, there's no trouble with your answer, and I accepted it. The "trouble" comment wasn't referring to your answer, and I'll delete it. – LCook – 2013-09-08T04:45:43.340