Skip to main content
. 2020 Jan 10;20(2):392. doi: 10.3390/s20020392
Algorithm 2 Image Edge Removal Algorithm
Part I 1:  Given a grayscale image HRM×N.
2:  Process and get gray binary image Gd.
3:  for I = 0, …, M do
4:  Set the array of IEC to Left[i], set the array of OEC to Right[i].
5:  for j = 0, …, N − 2 do
6:   if Gd[i,j+k]==0(k=0,1,2)
7:       Get Left[i]=j.
8:   end
9:   end
10:     for j = Left[i], …, N − 4 do
11:   if Gd[i,j+k]==255(k=0,,4)
12:       Get Right[i]=j.
13:   end
14:  end
15:  for j = 0, …, N do
16:     if Left[i]jRight[i]
17:       Set Gd[i,j]=255
18:     end
19:   end
20: end
21: Output the edge-removed gray binary image Gd.
Part II 1: Given a grayscale image HRM×N.
2: Obtain a binary image Gd1 and an image Gh with high threshold binarization. Use Sobel operator to obtain gradient binary image Gw.
3: for i = 0, …, M do
4:     Set the array of IEC to TopL[i] , set the array of LEC Bot[i] and set the array of OEC to Top[i].
5:     for j = 0, …, N − 4 do
7:      if Gh[i,j+k]==0 (k=0,,4)
8:            Get TopL[i]=j.
9:      end
10:     end
11:     for j = TopL[i] , …, N − 4 do
13:      if Gh[i,j+k]==255 (k=0,,4)
14:            Get Bot[i]=j.
15:      if Gd1[i,j+k]==255 (k=0,,4)
16:            Get Top[i]=j.
17:      end
18:     end
19:     for j = 0, …, N do
20:      if 0jTop[i]+15 or |jBot[i]|20
21:            Set Gw[i,j]=0.
22:      end
23:     end
24: end
25: Output the edge-removed torus gradient image Gw.
Part III 1: Given a grayscale end face image HRM×N.
2: Process and get binary image Gh.
3: Create a white circle C1 with (Center(x,y),(Top+Bot),w1) as its center, radius and line width, respectively.
4: forj = y, y − 1, …,4 do
5:   Scan upward from Center(x,y).
6:   if Gh[x,jk]==0 (k=0,,4)
7:         Get R2=yj.
8:   end
9:  end
10: Create a white circle C2 with (Center(x,y),R2,w1) as its center, radius and line width, respectively.
11: Use C1 and C2 to remove edges.
12: Output the edge-removed grayscale end face image.