Figure 4.9 - Reconstruction of pruned skeleton
There are problems with the preceding cleaning method. Parts of the lines near the tips of the scissors are erroneously eliminated together with spurious pixels [See Fig. 4.9(a)]. One corrective approach is reconstruction by geodesic dilation. Perform one more set of hit-or-miss transformations with the endpoint template collection, but instead of performing thinning with these operations, simply save the eight outputs. This will give the endpoints of the already pruned image. To reconstruct the desired image (hopefully without the undesirable spurs), perform a geodesic dilation of this endpoint set using the structuring element relative to the initial image upon which the pruning was performed and with three times the number of iterations as pruning cycles.The reason we need more geodesic dilations than pruning cycles is that each pruning cycle can remove up to three pixels with the eight compass templates. Finally, union this geodesic dilation with the pruned image.
Figure 4.9 illustrates this reconstruction: (a) sequentially thinned scissors with 15 cycles of pruning, (b) endpoints detection, (c) 15 cycles of reconstruction applied to the skeleton image, and (d) the union of the reconstruction with the pruned skeleton resulting in a clean skeleton image.
1 import ia870 as MT 2 import ia636 as ia 3 4 S = adreadgray('scissors.tif') > 0 5 T = MT.iathin(S,MT.iahomothin()) 6 P15 = MT.iathin(T, MT.iaendpoints(),15) 7 EP = MT.iasupcanon(P15,MT.iaendpoints()) 8 EPR = MT.iacdil(EP,T,MT.iasebox(),45) 9 E = MT.iaunion(P15,EPR) 10 11 fig_a = MT.iaunion(MT.iagray(S,'uint8',80),MT.iagray(T,'uint8',150),MT.iagray(P15)) 12 fig_b = MT.iaunion(MT.iagray(T,'uint8',100),MT.iagray(mmdil(EP,MT.iasebox()))) 13 fig_c = MT.iaunion(MT.iagray(T,'uint8',100),MT.iagray(EPR)) 14 fig_d = MT.iaunion(MT.iagray(S,'uint8',100),MT.iagray(E)) 15 16 adshow(MT.ianeg(fig_a), '(a)') 17 adshow(MT.ianeg(fig_b), '(b)') 18 adshow(MT.ianeg(fig_c), '(c)') 19 adshow(MT.ianeg(fig_d), '(d)')