Download: latest (1.8.0)

pymagery — python imagery


1.8.0 documentation / morph_erode plugin

The morph_erode plugin performs morphological erosion of a monochrome image. Erosion has the general purpose of shrinking (or eroding) the image and is considered one of the two base morphological operations (the other being dilation). Both opening and closing are based on these two operations.

The plugin prototype is:

def morph_erode(mask, origin)

The mask must be another monochrome image and the origin is a zero-based two-tuple of the position that should be considered the origin of the mask. For square-masks of odd dimensions typically have the center pixel ((width-1)/2) as the origin. Of course, masks need not be square nor be fully filled in.

The following example erodes the image with a 5x5 mask (center is the origin):

import pymagery mask = pymagery.image().NEW(5,5, pymagery.modes.MODE_MONO) + 1 i = pymagery.image('foo.ppm') i.morph_erode(mask, (3,3))

The following is the result of erosion of a 5x5 mask to an image.

Original Mask Eroded Image
11111
11111
11111
11111
11111

The image has clearly has been eroded. If the mask were larger then the bottom strip-like portion would be eroded away If combined with an dilation with the same mask then the size of the polygon would remain the same but the notch closed off. This is the open operation.

Change Log