Skip to main content
. 2019 Dec 31;20(1):237. doi: 10.3390/s20010237
Algorithm 2 Segmentation
Input: Range image Rng, segmentation threshold ϵ, Label=1
Output: L
  •  1:

    functionLabelrangeimage(Rng,Label,L,ϵ)

  •  2:

        L=zeros(Rrowsng×Rcolsng)

  •  3:

        for r=1;rRrowsng;r++ do

  •  4:

            for c=1;cRcolsng;c++ do

  •  5:

               if L(r,c)=0 then

  •  6:

                   queue.push(r,c)

  •  7:

                   while queue is not empty do

  •  8:

                       (r,c)=queue.top()

  •  9:

                       L(r,c)=Label

  • 10:

                       for (rn,cn)Neighborhood(r,c) do

  • 11:

                           d1=max(Rng(r,c),Rng(rn,cn))

  • 12:

                           d2=min(Rng(r,c),Rng(rn,cn))

  • 13:

                           if arctand2sinαd1d2cosα>ϵ then

  • 14:

                              queue.push(rn,cn)

  • 15:

                           end if

  • 16:

                       end for

  • 17:

                       queue.pop()

  • 18:

                   end while

  • 19:

                   Label=Label + 1

  • 20:

               end if

  • 21:

            end for

  • 22:

        end for

  • 23:

    end function