# Selecting for morphological components that do not border the edges of an image?

Is there an easy way to select for morphological components which do not border/touch the edges of an image?

Taking this doodle as an example:

We'd want to only select morphological components that stay at least some critical distance from the edges of the image.

-
For example, after labeling all connected components you can check pixels on the border and mark objects that you meet as unlabeled –  Eddy_Em Sep 2 '13 at 20:40
Are the morphological components you have in mind the same as the ones shown by MorphologicalComponents[yourimage] // Colorize? –  Michael E2 Sep 2 '13 at 20:46
How about adding a border to the picture and then removing the border component (with everything attached to it)? –  David Carraher Sep 2 '13 at 20:48
How about DeleteBorderComponents[yourimage]? –  Michael E2 Sep 2 '13 at 20:49
@MichaelE2 hit the nail on the head, imho. –  David Carraher Sep 2 '13 at 20:51

DeleteBorderComponents does what you ask. You can crop or pad the border, I suppose, if you wish to delete components that are close to the border.

img = Import["http://i.stack.imgur.com/2fQ3j.png"];
DeleteBorderComponents[img]


-