| [Up] [mmlgranul] | Additional Toolbox functions |
Implemented in Python.
| dim | mmIMAGE. |
| B | mmSE. Default:
|
| R | mmDOUBLE. Default:
|
| p | mmDOUBLE. Default:
|
| y | mmIMAGE. |
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.
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) |
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] | |