Figure 2.2 - Opening top-hat
In Fig. 2.1, the opening top-hat consists of input-image corners that protrude into the background, and it can be employed for recognition purposes. Figure 2.2 shows another example of the opening top-hat to detect the teeth of a gear. Use of a disk is common because its shape-effect is rotationally invariant; however, there are many instances when it is beneficial to employ other kinds of structuring elements.
1 import numpy as np 2 import ia870 as MT 3 import ia636 as ia 4 from handson.lib import draw_se_axis 5 6 F = adreadgray('gear.tif') 7 adshow(MT.ianeg(F), '(a) Structuring element') 8 9 B = MT.iasedisk(10) 10 adshow(MT.ianeg(draw_se_axis(MT.iaseshow(B))), '(b) input image') 11 12 E = MT.iaopen(F,B) 13 adshow(MT.ianeg(E), '(c) opening') 14 15 O = MT.iaopenth(F,B) 16 adshow(MT.ianeg(O), '(d) opening top-hat')