Skip to main content
. 2021 May 26;21(11):3703. doi: 10.3390/s21113703
Algorithm 2. Filtering based on NKNN
Input:Sf(nf×3points)
Output:So(no×3points),Sg(ng×3points)
 1: ConstructtheKDtreeofSf
 2: for eachpoint do
 3:   Calculatetheknearestneighbors
 4:   pi=(x1,x2,,xn)
 5: end for
 6: for neighborsofeachpoint do
 7:   μj=1kj=1kxj
 8:   x˜j=xjμj
 9:   C=[x˜1,x˜2,,x˜k]
10:   ComputeSVD:UΣVT=CCT
11:   viTheeigenvectoroftheminimumeigenvalueinU
12: end for
13: for pickviΩatrandom do
14:   for eachvjΩ do
15:     θ=vivj||vi||||vj||
16:     if θ<δ then
17:       xiSameclass
18:       removeviinΩ
19:     end if
20:   end for
21:   if Ωisnone then
22:     break
23:   end if
24: end for
25: for eachpointxi do
26:   nclassthemostclassintheneighborhood
27:   xinclass
28: end for
29: if nclassismax then
30:   GroundSgthepointsofnclass
31: else
32:   NoiseSoothernclass
33: end if