Toolbox ia870 | List of Figures | Fig. 3.9 | Fig. 3.11

Figure 3.10 - Reconstruction from markers using 36-connectivity

Description

An example using 36-connectivity is shown in Fig. 3.10. In part (a) the letter “t” of the first line and the letter “m” of the second line are marked. In part (b), reconstruction yields the word “to,” in the first line and the word “me” in the second line.

To find all the connected components of an image, one can iteratively find any pixel of the image, use it to reconstruct its connected component, remove the component from the image, and iteratively repeat the same extraction until no more pixels are found in the image. This operation is called labeling

Demo Script

 1 import ia870 as MT
 2 import numpy as np
 3 
 4 A = MT.iatext('to me')
 5 t = MT.iaintersec(A,0)
 6 t[3,3] = 1
 7 
 8 t = MT.iainfrec(t,A,MT.iasebox())
 9 m = MT.iaintersec(A,0);
10 m[5,28] = 1
11 
12 m = MT.iainfrec(m,A,MT.iasebox())
13 B36 = MT.iasedisk(3)
14 T = MT.iainfrec(t,A,B36)
15 M = MT.iainfrec(m,A,B36)
16 
17 a = MT.iaunion(MT.iagray(MT.iaconcat('H',t,m)),
18         MT.iagray(MT.iaconcat('H',A,A),'uint8',100))
19 
20 b = MT.iaunion(MT.iagray(MT.iaconcat('H',T,M)),
21         MT.iagray(MT.iaconcat('H',A,A),'uint8',100))
22 
23 adshow(MT.iapad(MT.ianeg(a)))
24 adshow(MT.iapad(MT.ianeg(b)))