Download: latest (1.8.0)

pymagery — python imagery


1.8.0 documentation / morph_open plugin

The morph_open plugin performs morphological open of a monochrome image (an erosion followed by a dilation). Opening has the general purpose of removing narrow lines smaller than the mask. It is closely related to the close operation.

The plugin prototype is:

def morph_open(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 opens 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_open(mask, (3,3))

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

Original Mask Eroded Image Opened Image
11111
11111
11111
11111
11111

In this case the erosion mask did not remove narrow strips in the bottom, thus the image has not changed because of the closing. Repeating the open operation with a 13x13 mask is big enough to remove the strips:

Original Eroded Image Opened Image

Change Log