[mmunion] [Up] [mmsebox] | Structuring Elements |
Implemented in Python.
mmimg2se creates a flat structuring element
B
from the binary image
fd
or creates a non-flat structuring element
b
from the binary image
fd
and the gray-scale image
f
.
fd
represents the domain of
b
and
f
represents the image of the points in
fd
.
Let us apply
mmimg2se to create structuring elements. In the example below, the flat 3x3 diamond is created.
>>> a = mmimg2se(mmbinary([ [0,1,0], [1,1,1], [0,1,0]]))
>>> print mmseshow(a)
[[0 1 0] [1 1 1] [0 1 0]]
>>> b = mmbinary([ [0,1,1,1], [1,1,1,0]])
>>> b1 = mmimg2se(b)
>>> print mmseshow(b1)
[[0 0 0 0 0] [0 0 1 1 1] [0 1 1 1 0]]
>>> c = mmbinary([ [0,1,0], [1,1,1], [0,1,0]])
>>> d = int32([ [0,0,0], [0,1,0], [0,0,0]])
>>> e = mmimg2se(c,'NON-FLAT',d)
>>> print mmseshow(e)
[[-2147483647 0 -2147483647] [ 0 1 0] [-2147483647 0 -2147483647]]
def mmimg2se(fd, FLAT="FLAT", f=None): from string import upper from Numeric import choose, ones assert mmisbinary(fd),'First parameter must be binary' FLAT = upper(FLAT) if FLAT == 'FLAT': return mmseshow(fd) else: B = choose(fd, (mmlimits(int32([0]))[0]*ones(fd.shape),f) ) B = mmseshow(int32(B),'NON-FLAT') return B
mmfreedom | Control automatic data type conversion. |
mmsebox | Create a box structuring element. |
mmsecross | Diamond structuring element and elementary 3x3 cross. |
mmsedisk | Create a disk or a semi-sphere structuring element. |
mmseline | Create a line structuring element. |
mmseshow | Display a structuring element as an image. |
mmdil | Dilate an image by a structuring element. |
[mmunion] [Up] [mmsebox] | ![]() |
Copyright (c) 2003, Roberto A. Lotufo, UNICAMP-University of Campinas; Rubens C. Machado, CenPRA-Renato Archer Research Center. |