[hofig4s2] [Up] [hofig4s4] Chapter 4 - Hit-or-Miss Transform

hofig4s3
Object recognition using hit-or-miss

Description

This figure illustrates the recognition of the ground symbol in a circuit drawing using the hit-or-miss transform.

Demo Script

.

from morph import *
f=mmreadgray('circuit_bw.tif')
hit=mmbinary([
 [0,0,0,0,0,0,0,1,0,0,0,0,0,0,0],
 [0,0,0,0,0,0,0,1,0,0,0,0,0,0,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [0,0,0,1,1,1,1,1,1,1,1,1,0,0,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [0,0,0,0,1,1,1,1,1,1,1,0,0,0,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]])
miss=mmbinary([
 [0,1,1,1,0,0,0,0,0,0,0,1,1,1,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [1,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
 [1,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
 [1,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]])
D=mmimg2se(mmunion(hit,1))
Warning: Converting input image from int32 to binary uint8.
I=mmse2hmt(mmimg2se(hit),mmimg2se(miss))
y=mmcdil(mmsupgen(f,I),f,D)
fig_a=mmbshow(mmunion(hit,miss),hit)
fig_b=mmunion(mmgray(y),mmgray(f,'uint8',140))
mmshow(fig_a)
mmshow(fig_b)
fig_a fig_b

[hofig4s2] [Up] [hofig4s4] http://www.python.org