# Testing a Vision-Based Autonomous Drone Navigation Model in a Forest Environment
## 3 The Proposed Method
### Masking
Since our goal is to find the largest clear path in the scene that the drone can fly through, the corresponding image areas are masked based on the specific range of the pixel values in the HSV color space. In this case, the HSV color space for the obscured red areas shown in Figure 9a are lower = [0,100,100] and upper = [18,255,255]. The particular weighted average of the image intensities shown in Figure 9b are obtained by using masking operations. In the drone FOV, when a detected screen is filled with many obstacles, to find a clear path for the drone to navigate, the red area can be specified through a binary mask. There are two bitmaps in each scene: the actual scene and an additional mask. The unused areas from the actual scene are assigned a pixel value with all bits set to '0'. For the additional mask, the red areas are assigned a pixel value with the bits set to '1'. For instance, the image in Figure 9b is a binary image that has two possible intensity values for each pixel, i.e., '0' for black and '1' for white. When an obstacle, i.e., a detected tree object, appears over the background, masking is performed on the overlapping scene pixels in the red area in Figure 9a. Hence, the free and open areas of the scene are preserved. The masked areas of a clear path with pixel intensities of '1' are obscured by the overlapped unused '0' areas, as in Figure 9b. Then, the system combines the original image pixels with the background pixels using the bitwise OR operation. The original image pixels are appropriately placed while keeping the masked region. To be precise, the largest red area is calculated using the image moments. The properties of the image determined via the image moments include the area (or total intensity),  
Figure 8: Image masking process  
Figure 9: Segmented regions based on the HSV color space. centroid, and information about the orientation. The \(n\) area of the nonzero pixels is calculated based on the image moments. We consider the first moment as follows:  
\[sum_{x}=\sum_{x=0}^{w}\sum_{y=0}^{h}xf(x,y) \tag{1}\]  
The \(x\) coordinates of all the white pixels (where \(f(x,y)=1\)) are summed up. In addition, the sum of the \(y\) coordinates of all the white pixels is calculated as follows:  
\[sum_{y}=\sum_{x=0}^{w}\sum_{y=0}^{h}yf(x,y) \tag{2}\]  
The area of the binary image is calculated as follows:  
\[M_{0,0}=\sum_{x=0}^{w}\sum_{y=0}^{h}f(x,y) \tag{3}\]  
When there is more than one area of white pixels in the image, the centroid is somewhere in between. Hence, we need to extract each white pixel area separately to obtain the centroid. Given that \(A\) is an array used to store all the white-pixel areas found in the image as follows:  
\[A=[n_{i},n_{i+1},...] \tag{4}\]  
to find the largest \((b)\) area, we calculate the following:  
\[if\quad A=[n_{i+1}]>A=[b_{i}];\quad b_{i}=n_{i+1} \tag{5}\]  
Technically, the largest white-pixel area is selected as the final clear path because this is the largest empty area between the obstacles. When we have the sums of all the \(x\) and \(y\) pixel coordinates, to find the average in the binary image, the values obtained are divided by the number of pixels in the respective area in the image. Thus,  
Figure 6:0  
Finally,  
Figure 6:1  
Therefore, the centroid obtained serves as the guided waypoint for the drone. From the drone FOV, the drone navigates to the largest red region. By combining all the layers, given that the layers do not have the same colors, the semantic color-based segmentation forms a comprehensive description of the scene. Essentially, the contextualized information is used to solve the problem of self-navigation in the scene.