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

hofig1s12
Dilation as reflected robot path planning from outside

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(10))
mmshow(A)
A

Structuring element and its reflection

Bimg=mmreadgray('r_robot.tif')
B=mmimg2se(Bimg)
mmshow(mmseshow(B))
Br=mmsereflect(B)
mmshow(mmseshow(Br))
mmseshow(B) mmseshow(Br)

Dilation

C=mmdil(A,B)
mmshow(C,mmgradm(A))
C,mmgradm(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(Br),mmsebox()))))
Bg=mmunion(mmdil(Ba,mmsecross(2)),Bg)
mmshow(Bg)
Bg

Illustration

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

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