Toolbox ia870 | List of Figures | Fig. 2.6 | Fig. 2.8

Figure 2.7 - Restoration by opening

Description

To see the kind of restoration that can be effected by opening and closing, consider the rectangle degraded by pepper noise in Figure 2.7(a)

Opening by the disk has a restorative effect because the disk does not fit into the small components strewn about the background. Except for the rounded corners and the slight bubbles along the left and bottom edges, the rectangle has been restored.

Demo Script

 1 import numpy as np
 2 import ia870 as MT
 3 from handson.lib import iabggmodel, draw_se_axis
 4 
 5 f = MT.iabinary(np.ones((200,100)))
 6 f=  MT.iapad(f,MT.iasebox(25))
 7 n = iabggmodel(shape(f),MT.iasedisk(2),3,0.001)
 8 fbin = MT.iaunion(f,n)
 9 B = MT.iasedisk(7)
10 g = MT.iaopen(fbin,B)
11 adshow(MT.ianeg(fbin),'(a) input image')
12 adshow(MT.ianeg(draw_se_axis(MT.iaseshow(B))), '(b) disk structuring element')
13 adshow(MT.ianeg(g), '(c) opening.')

(a) input image

(b) disk structuring element

(c) opening.