| [mmcero] [Up] [mmero] | Dilations And Erosions |
Implemented in Python.
| f | Image Gray-scale (uint8 or uint16) or binary image. |
| b | Structuring Element Default:
|
| y | Image |
mmdil performs the dilation of image
f by the structuring element
b. Dilation is a neighbourhood operator that compares locally
b with
f, according to an intersection rule. Since Dilation is a fundamental operator to the construction of all other morphological operators, it is also called an elementary operator of Mathematical Morphology. When
f is a gray-scale image,
b may be a flat or non-flat structuring element.
>>> f=mmbinary([ [0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0]])
>>> b=mmbinary([1, 1, 0])
>>> mmdil(f,b)
array([[0, 0, 0, 0, 0, 1, 1],
[1, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 0, 0]],'1')
>>> f=uint8([ [ 0, 1, 2, 50, 4, 5], [ 2, 3, 4, 0, 0, 0], [12, 255, 14, 15, 16, 17]])
>>> mmdil(f,b)
array([[ 1, 2, 50, 50, 5, 5],
[ 3, 4, 4, 0, 0, 0],
[255, 255, 15, 16, 17, 17]],'b')
>>> f=mmbinary(mmreadgray('blob.tif'))
>>> bimg=mmbinary(mmreadgray('blob1.tif'))
>>> b=mmimg2se(bimg)
>>> mmshow(f)
>>> mmshow(mmdil(f,b))
>>> mmshow(mmdil(f,b),mmgradm(f))
![]() |
![]() |
|
| f | mmdil(f,b) |
![]() |
|
| mmdil(f,b),mmgradm(f) |
>>> f=mmreadgray('pcb_gray.tif')
>>> b=mmsedisk(5)
>>> mmshow(f)
>>> mmshow(mmdil(f,b))
![]() |
![]() |
|
| f | mmdil(f,b) |
def mmdil(f, b=None):
from Numeric import maximum, NewAxis, ones
if b is None: b = mmsecross()
if len(f.shape) == 1: f = f[NewAxis,:]
h,w = f.shape
x,v = mmmat2set(b)
if len(x)==0:
y = (ones((h,w)) * mmlimits(f)[0]).astype(f.typecode())
else:
if mmisbinary(v):
v = mmintersec(mmgray(v,'int32'),0)
mh,mw = max(abs(x)[:,0]),max(abs(x)[:,1])
y = (ones((h+2*mh,w+2*mw)) * mmlimits(f)[0]).astype(f.typecode())
for i in range(x.shape[0]):
if v[i] > -2147483647:
y[mh+x[i,0]:mh+x[i,0]+h, mw+x[i,1]:mw+x[i,1]+w] = maximum(
y[mh+x[i,0]:mh+x[i,0]+h, mw+x[i,1]:mw+x[i,1]+w], mmadd4dil(f,v[i]))
y = y[mh:mh+h, mw:mw+w]
return y
| mmfreedom | Control automatic data type conversion. |
| mmcdil | Dilate an image conditionally. |
| mmero | Erode an image by a structuring element. |
| mmsebox | Create a box structuring element. |
| mmsecross | Diamond structuring element and elementary 3x3 cross. |
| mmimg2se | Create a structuring element from a pair of images. |
| mmsesum | N-1 iterative Minkowski additions |
| mmfreedom | Control automatic data type conversion. |
| mmsedil | Dilate one structuring element by another |
| mmcdil | Dilate an image conditionally. |
| mmero | Erode an image by a structuring element. |
| mmsecross | Diamond structuring element and elementary 3x3 cross. |
| mmimg2se | Create a structuring element from a pair of images. |
| mmsesum | N-1 iterative Minkowski additions |
| [mmcero] [Up] [mmero] | |
| Copyright (c) 2003, Roberto A. Lotufo, UNICAMP-University of Campinas; Rubens C. Machado, CenPRA-Renato Archer Research Center. |