Page 36 - Read Online
P. 36

Tang et al. Intell Robot 2022;2(2):130­44  I http://dx.doi.org/10.20517/ir.2022.07  Page 134


                                            //// The pseudo-code of the Mode Background Method ////

                                       Initialize the parameters; Input the prepared image to matrix I m;
                                      For    n = 1:N_Frame       % N_Frame is first few frames of videoĠ
                                       I y = Convert_gray ( I m )      % Convert the image I m to a gray image I y;
                                       Θ = Save_gray ( I y )            % Save the grayscale value of I y to the array;
                                      End for
                                      For    j = 1:N_Pixel                  % N_Pixel is the number of pixels in the image;
                                       C = Ceil ( Θ/E )
                                       % Ceil ( ) is a function to rounds the elements of the data to the nearest integers towards
                                       infinity; E is an integer number.
                                       Mf = Mode ( C )
                                       % Mode ( ) is a function to returns the sample mode of C, which is the most frequently
                                       occurring value in C;
                                       Num = Count ( C==Mf )
                                       %Count ( ) is a function to calculate the number of the pixel where C==Mf
                                       Mode_save = Mf
                                       % Save the mode value of Mf to the array;
                                       R (x, y) = Mode_save (x, y)*E
                                       % Calculate the value of the array;
                                      End for
                                      Return B (x, y) = R (x, y)
                                       % Output the initial background image I b, which is constructed by the pixel B(x, y);


                                        Figure 2. The pseudo-code of the mode background method.


               the background is calculated by
                                                               
                                                          ∑
                                                                  (  ode(  ))
                                                           =1
                                                  (  ,   ) =                                           (2)
                                                                     
               where         (  ) isafunctiontoreturnthemodenumberofthesample, whichisthemostfrequentlyoccurring
               value in this sample.        is the number of the mode numbers in the sample. Here,    is defined as follows:

                                                         =         (Θ/  )                              (3)
               where         (·) is a function to round the elements of the data to the nearest integers towards infinity. Θ is the
               grayscale value of the gray image obtained from the original image. To extract most of the numbers appearing
               in the array Θ by the function         (·), the range of Θ is reduced by dividing an integer   . In this study,    is
               set as 5, namely the grayscale images are separated with five grayscale levels, which can improve the contrast
               of different elements in the image and reduce the influence of small speckles on target extraction. The pseudo-
               code of the mode method for background modeling is shown in Figure 2.

               After the background of the video is established, the ViBe method is used to initialize the background model,

               which is based on the domain model. For each pixel   (  ,   ) of the background image, the sample set   (  ,   )
               of it is:
                                              (  ,   ) = {   1 ,   2 , · · ·      },    = 1, 2, · · ·     (4)
               where    is the number of the neighboring sample.       is the value of a sample that is randomly chosen from
               the 8-connected neighborhood of each pixel (see Figure 3a). When the sample sets of all the pixels in the
               background are obtained, a background model is set up.
   31   32   33   34   35   36   37   38   39   40   41