Figure 2.8 - Restoration of corrupted grain-type image
The filter effect becomes more transparent if we consider the uncorrupted circular grain-type image of Fig. 2.8(a), the noise image of Fig. 2.8(b), and the corrupted image of Fig. 2.8(c). Here, the largest noise grain is smaller than the smallest uncorrupted-image grain. Opening with a disk whose radius is between that of the largest noise grain and the smallest uncorrupted-image grain will yield close to perfect restoration so long as there is little grain overlap [See Fig. 2.8(d)]. In the absence of overlap, restoration is perfect.
1 import numpy as np 2 import ia870 as MT 3 from handson.lib import iabggmodel 4 5 n_overlap = iabggmodel((300, 200),MT.iasedisk(2),4,0.001) 6 7 f1 = iabggmodel((300, 200), MT.iasedisk(12),2,0.0001) 8 f2 = iabggmodel((300, 200), MT.iasedisk(16),2,0.00004) 9 10 B = MT.iasedisk(12) 11 12 f = MT.iaopen(MT.iaunion(f1,f2),B) 13 14 cor = MT.iaunion(f,n_overlap) 15 16 g = MT.iaopen(cor,B) 17 18 adshow(MT.iapad(MT.ianeg(f)), '(a) uncorrupted image S') 19 adshow(MT.iapad(MT.ianeg(n_overlap)), '(b) noise image N') 20 adshow(MT.iapad(MT.ianeg(cor)), '(c) corrupted image S union N') 21 adshow(MT.iapad(MT.ianeg(g)), '(d) restoration by opening')