[Up] [mmlgranul] Additional Toolbox functions

mmbggmodel
Bernoulli germ-grain model realization.

Synopsis

y = mmbggmodel( dim, B = None, R = 3, p = 0.01 )

Implemented in Python.

Input

dim mmIMAGE.
B mmSE.

Default: None (3x3 elementary cross)

R mmDOUBLE.

Default: 3

p mmDOUBLE.

Default: 0.01

Output

y mmIMAGE.

Description

mmbggmodel generates a realization of a Bernoulli germ-grain model. The germs are distributed according to a Bernoulli process with probability p. A structuring element rB, with radius r uniformly distributed between 1 and R is assigned at each point of the Bernoulli process.

Examples

from handson import *
mmshow(mmbggmodel((100, 256)))
mmshow(mmbggmodel((100, 256),mmsebox(),5,0.05))
B=mmsedisk(1,'1D')
mmshow(mmbggmodel((100,256),B,5,0.03))
mmshow(mmbggmodel((100,256),mmserot(B,45),5,0.005))
mmbggmodel((100, 256)) mmbggmodel((100, 256),mmsebox(),5,0.05)
mmbggmodel((100,256),B,5,0.03) mmbggmodel((100,256),mmserot(B,45),5,0.005)

Source Code

def mmbggmodel(dim, B=None, R=3, p=0.01):
    from MLab import rand
    from morph import mmsecross, mmintersec, uint8, mmbinary, mmgray, mmskelmrec
    if B is None: B = mmsecross()
    dy,dx=dim
    a=mmbinary(rand(dy,dx)<p)
    b=uint8((rand(dy,dx)*(R-1))+1.5)
    a=mmintersec(mmgray(a),b)
    y=mmskelmrec(a,B)
    return y
    
[Up] [mmlgranul] http://www.python.org