# Automated Tree Detection Using Image Processing and Multisource Data
## 5 Numerical Experiments  
This project involved the city of Katowice, which is 165 square kilometers. The location was divided into rectangular regions measuring 500 m by 800 m, resulting in a total of 562 regions. All data used in each region were saved as separate files (.asc and.tif). Our proposed approach was evaluated in selected regions of the city, encompassing various types of terrain.  
All experiments were conducted on a Jupyter Notebook installed on a Vertex AI service provided by the Google Cloud Platform (GCP). The notebook was hosted on a virtual machine (named n1-standard-16 on GCP) with 16 vCPUs and 60 GB of RAM.  
In the numerical experiments, we employed well-known measures, such as accuracy, precision, the Jaccard index, and the conformity index. The following classes were proposed:  
* Tree--represented by red on the NDVI sample;
* Other objects--indicated by green or blue on the sample.  
We assumed the following:  
* High vegetation--red on the NDVI sample and a height of at least 15 m;
* Vegetation--red on the NDVI sample and a height of below 15 m;
* Other objects--green or blue on the NDVI sample.  
By a single sample, we mean the smallest fragment on the map. The following assumptions were made:  
* _TP_ (true positive)--sample considered a tree in both the original NDVI map and the result using our proposed algorithm;
* _TN_ (true negative)--sample not considered a tree in both the original NDVI map and the result using our proposed algorithm;
* _FP_ (false positive)--sample considered a tree in the original NDVI map but not recognized as high vegetation using our approach;
* _FN_ (false negative)--sample not considered a tree in the original NDVI map but eventually recognized as high vegetation using our approach.  
The formulas for the aforementioned metrics are as follows:  
\[ACC=\frac{TP+TN}{TP+FP+FN+TN}, \tag{5}\]  
\[PREC=\frac{TP}{TP+FP}, \tag{6}\]  
\[REC=\frac{TP}{TP+FN}. \tag{7}\]  
Since the occurrence of a situation in which a false negative (FN) greater than 0 was unlikely, we omitted this metric in our further calculations. Eventually, we selected accuracy and precision as the classification metrics. Further, we selected two different similarity metrics to estimate the dependence between the area indicated as vegetation (red on the map) and the height of the samples. These metrics are described as follows:  
* Conformity index (CC), which is the relation between the TPs, FNs, and FPs: \[CC=(1-\frac{FP+FN}{TP})\cdot 100;\] (8) The interpretation of this metric is as follows: higher values indicate a better solution. Values below zero indicate a situation in which many samples initially assigned to the vegetation class were not considered trees after including the height data.
* Jaccard index, which indicates the similarity between two areas. In our case, we assume that \(A\) represents an area of vegetation, whereas \(B\) represents samples with a height greater than 15 m. Thus, the equation is expressed as follows: \[JI=\frac{A\cap B}{A\cup B}.\] (9) In this case, values close to zero are better. However, the vast number of samples initially estimated to be vegetation (without including the height data) is expected to be omitted. Thus, this value should be closer to zero than to one.