Toolbox ia870 | List of Figures | Fig. 6.14 | Fig. 6.16

Figure 6.15 - Flat zones

A maximal connected component of a gray-scale image with the same pixel values is called a flat zone. Flat zones are connected regions of constant gray values. A flat zone can be a single pixel or can be the entire image.

Description

The synthetic image has four flat zones: a triangle, a circle around the triangle, an annular ring around the circle and a square background. A typical real image has a large number of flat zones, depending on the number of gray levels used in the digitalization of the image. The real image has 2,471 flat zones.

Demo Script

 1 import ia870 as MT
 2 import ia636 as ia
 3 import numpy as np
 4 
 5 f = MT.iabinary(np.zeros((100,100)))
 6 f[50,50] = 1
 7 
 8 d = MT.iadist(MT.ianeg(f),MT.iasebox(),'EUCLIDEAN')
 9 
10 g1 = MT.iathreshad(d, 0, 45)
11 g2 = MT.iathreshad(d, 0, 30)
12 g3 = MT.iadil(f, MT.iasesum(MT.iaimg2se(MT.iabinary([[0,1,0],[0,1,0],[1,1,1]])),17))
13 
14 g = MT.iaaddm(MT.iagray(MT.iasymdif(g1,g3),'uint8',1),
15      MT.iagray(g2,'uint8',2));
16 
17 adshow(MT.iapad(ia.ianormalize(MT.ianeg(g))),'(a) synthetic image')
18 
19 g_flat = MT.ialabelflat(g,MT.iasebox())
20 adshow(MT.ianeg(ia.ianormalize(MT.iaglblshow(g_flat))), '(b) synthetic image has 4 flat zones')
21 
22 f = adreadgray('pcb_gray.tif')
23 f = f[:60,-60:]
24 f_flat = MT.ialabelflat(f,MT.iasebox())
25 
26 adshow(f,'(c) real image ')
27 adshow(MT.iaglblshow(f_flat), '(d) real image has 2,471 flat zones')

(a) synthetic image

(b) synthetic image has 4 flat zones

(c) real image

(d) real image has 2,471 flat zones