Skip to main content
. 2020 Jan 10;20(2):392. doi: 10.3390/s20020392
Algorithm 3 Connected Domain Filtering Method
Part I 1: Give a gray binary image Gd or a gradient binary image Gw.
2: Process and get Gd’s anti-color image Gdc.
3: Get the connected domain set Q and the number k of the connected domain.
4: fori = 1, …, k do
5:   Get the area Si of the connected domain QiQ, the minimum bounding rectangle Ti (with length Hi and width Wi).
6:   Set each value of (Twh,Rwh,Th,Tw,Ts).
7:   if condition is satisfied
8:     Qi is judged to be a defect.
9:   end
10: end
11: Output the results.
Part II 1: Given a gradient binary image Gw.
2: Get the width W of Gw.
3: Set the step length step and a rectangular search box Sbox with a width of wb and a length of hb. Set number of connected domains Ni=0.
4: fori = 1, …wb+istep, …, W do
5:  Use Sbox to traverse Gw from top to bottom in steps of step.
6:  For the ith Sbox, get k connected domains.
7: for j = 1, …, k do
8:   Get the area Sj of the connected domain QjQ, the minimum bounding rectangle Tj (with length Hi and width Wj).
9:   Set each value of (Twh,Rwh,Th,Tw,Ths,Tss).
10:   if condition1 is satisfied.
11:      Ni+=1 and save the coordinate of the connected domain (xj,yj).
12:   end
13:   end
14:   Set Tn and Ths.
15:   if condition2 is satisfied.
16:   The ith Sbox contains defects.
17:   end
18: end
19: Output the results.