[hofig1s9] [Up] [hofig1s11] Chapter 1 - Binary Erosion and Dilation

hofig1s10
Dilation as the dual of erosion

Description

.

Demo Script

Image reading

from morph import *
from handson import *
from MLab import rand
from Numeric import shape
A=mmreadgray('blob_1.tif')
A=mmpad(A,mmsebox(30))
mmshow(A)
A

Dilation

B=mmsedisk(30)
C=mmdil(A,B)
mmshow(C,A)
C,A

Random points on outside

rnd = mmbinary(rand(shape(C)[0],shape(C)[1]) > 0.997)
Ba=mmintersec(mmgradm(C), rnd)
Bg=mmdil(Ba,mmimg2se(mmgradm(mmpad(mmseshow(B),mmsebox()))))
Bg=mmunion(mmdil(Ba,mmsecross(2)),Bg)
mmshow(A,Bg)
A,Bg

Illustration

AC=mmsymdif(mmunion(mmgray(A,'uint8',2),mmgray(C,'uint8',1)),mmgray(Bg,'uint8',1))
mmshow(AC)
AC

[hofig1s9] [Up] [hofig1s11] http://www.python.org