# Monitoring Safron Crops with UAVs
## 3 Field Study Design Methodology
### Application of Machine Learning Techniques  
Smart Farming produces and analyzes a huge amount of data in order to create the necessary information to help boost agricultural production [21, 22]. It is for this reason that scientists and practitioners working in this field have begun to take an interest in machine learning methods. One significant advantage of machine learning technology is that we can create a program (model) and train it in solving autonomously large non-linear problems by utilizing data from many different sources. Machine learning techniques are usually classified into two broad categories (supervised learning and unsupervised learning), depending on the nature of the training \"signal\" or \"feedback\" available in a learning system [23, 24]. The goal of this study was to train a machine learning model so that it can recognize key features of saffron cultivation, such as saffron flowers, weeds, and mammals. We decided, for comparison reasons, to use two very common machine learning techniques for image classification in Smart Farming, the pixel-based and the object-based image analysis. Both of them take the results of the photogrammetry procedure as input and produce datasets that can be used for the model training. * **Pixel-based image analysis:** This method is based on classifying images pixel by pixel, using a set of rules to decide whether different pixels can be grouped according to similar characteristics. Code was developed in Python to export the RGB and NDVI values of the pixels from the images, and an Attribute-Relation File Format (ARFF) dataset was created. ARFF files are ASCII text files that describe a list of instances that have a set of attributes in common. The data that served as input were orthophotos in an RGB and NDVI spectrum. In addition, a separate image was created with the annotations for each pixel, essentially representing the actual data (ground truth) of the image. The python PIL library was used for the analysis of each image, which is suitable for collecting pixel values from an image file. For the image annotation, we used the Computer Vision Annotation Tool (CVAT) [25], an open-source software. * **Object-based image analysis (OBIA):*
* OBIA, in contrast to pixel-based analysis that categorizes each pixel, groups small pixels on a common vector object. This process uses the image segmentation method suggested by [PERSON] [26], which divides the pixels into homogeneous parts. Then these sections/objects are arranged in classes based on shape, spectrum, texture, and other features. In more detail, the analysis is based on objects that are built as pixel groups (raster clumps). The properties of each clump are stored in one raster attribute table (RAT), while each object is associated with an ID. For the creation, storage, display, and sorting within the RAT, the following software packages were used:
* Remote Sensing and GIS software library (RSGISLib): For the image segmentation. * GDAL: A library for translating and processing raster and vector geospatial data formats. * Raster I/O Simplification (RIOS): For reading, writing, and sorting the created objects. * KEA image format: For saving image objects with their attributes. Figure 4: NDVI example. \(\circ\) Tuiview: For viewing KEA files. The produced ARFF datasets from both methods were used as inputs for the model training procedure. After a review of the literature, we concluded that _Random Forests_ and _Multilayer Perceptron_ (artificial neural networks) were the most efficient algorithms for our purposes. * **Random Forest (RF):** RF is a machine learning algorithm for solving regression and classification problems. Its name derives from the use of a large number of decision trees, a fact that results in minimizing the occurrence of overtraining phenomena in each tree. **Scipy.io** library was utilized for ARFF file reading, and **scikit-learn** was used for the _RandomForestClassifier_ function, which applies the RF algorithm in pandas data format.