# Automated Tree Detection Using Image Processing and Multisource Data
## 3 Background
### Image-Processing Tools and Techniques  
Image processing plays a vital role in automatically extracting objects from images. Several works have reported the application of this technique for urban area analysis, particularly focusing on green areas. The essential tasks in such classification systems are image segmentation and object detection. In image segmentation, the main idea is to divide the original image into small, consistent fragments representing different objects and elements. Segmentation can be used to extract areas, including vegetation, buildings, roads, or other important elements of city architecture. The quality of the classification in the next steps of an algorithm depends on the size of the fragments and the quality of the image. An example of such segmentation can be seen in Figure 3, where the original image is divided into segments (the three black rectangles in the figure). In contrast, the first and second examples (\"A\" and \"B\" in the figure) show road and field fragments visible in the segment, while the last segment presents parts of the road and field occupying a similar space on the fragment. The next problem that arises with these images is related to the quality of the image. Problems related to image quality may include the following:  
* A low image resolution;
* Noise (artifacts) in the image. \begin{table}
\begin{tabular}{c} \hline
**Structure of the.tfw File** \\ \hline
0.05 \\
0 \\ \(-\)0.05 \\
6569600.025 \\
5559999.975 \\ \hline \end{tabular}
\end{table} 
Table 2: Example world file for a.tif file. Figure 2: Type of data used in this project. The resolution strictly depends on the availability of the data, and obtaining the same image in high resolution may not be possible. In contrast, image denoising can be performed using selected filters. Thus, the initial adjustment of filters (focusing on blurring filters) should positively affect the segments containing fragments of analyzed objects. Image smoothing can be performed by convolving it with a Gaussian function representing a probability distribution over a continuous variable. It is characterized by two parameters: the mean and the variance. In addition, it represents the amount of blurring applied to each pixel in the image. The output of a Gaussian blur operation on an image can be represented mathematically as  
\[G(x,y)=\frac{1}{2\pi\sigma^{2}}\cdot\exp\left(-\frac{x^{2}+y^{2}}{2\sigma^{2} }\right)*I(x,y), \tag{1}\]  
where \(G(x,y)\) represents the blurred image, \(I(x,y)\) represents the original image, \(\sigma\) represents the standard deviation of the Gaussian function, and \(*\) represents the convolution operator. Examples of Gaussian filters for different kernel sizes are presented in Figure 4.  
Image segmentation and blurring are utilized to enhance the classification quality of image fragments. A decision class is assigned to every fragment of the map. For example, the average color of an image can be determined by calculating the mean values of the RGB (Red, Green, Blue) color channels for each pixel in the image [32]. Given an image \(I\) of size \(M\times N\), the average color \(\bar{C}\) can be computed as  
\[\bar{C}=\frac{1}{M\times N}\sum_{i=1}^{M}\sum_{j=1}^{N}[R_{i,j},G_{i,j},B_{i,j}], \tag{2}\]  
where \(R_{i,j}\), \(G_{i,j}\), and \(B_{i,j}\) denote the intensity values of the red, green, and blue channels, respectively, for the pixel at position \((i,j)\). The resulting vector \(\bar{C}\) signifies the image's average color across the channels. In our methodology, the dominant color is indicated by the maximum value among the calculated averages. The quality of the classification can be assessed using classical classification metrics, such as precision, recall, or F1 score. However, it is important to note that in the case of maps, more than just numerical data acquired from the image may be required, and additional  
Figure 3: Image segmentation analysis: (A) road fragment;(B) field fragment; (C) segment with objects of different types. information from various sources may be necessary.