Download: latest (1.8.0)

pymagery — python imagery


1.8.0 documentation / morph_dilate plugin

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

The plugin prototype is:

def morph_dilate(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 dilates 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_dilate(mask, (3,3))

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

Original Mask Dilated Image
11111
11111
11111
11111
11111

The image has clearly has been dilated. If the mask were larger then the notch in the top-right would be closed off. If combined with an erosion with the same mask then the size of the polygon would remain the same but the notch closed off. This is the close operation.

Change Log