## 2 Materials and Methods
### Image Processing Method and Feature Extraction  
In this section, the methods for the extraction of the various features used by the classification method are discussed. First of all, the background and the photograph pixels belonging to the plant part have to be separated. As already mentioned, it is assumed for convenience that the plant part has been photographed with a background much brighter or darker than the examined plant part. This prerequisite would not be necessary if, for example, a citrus fruit had to be photographed on the tree since its yellow color would make it easy to distinguish it from the green leaves. However, isolating a single leaf of a tree in a photograph would be much harder requiring an image processing technique potentially more complicated than, for example, the segmentation technique used for the rest of the image regions. Two methods are supported for the identification of the white background. In the first, (background separation method 1, BSM1), the gray version of the photograph is used and the pixels with a gray level higher than a threshold \(B_{g}\) are assumed to be the background. In the second method (BSM2) it is assumed that the three color levels of the RGB background pixels are very close and have a relatively high value (e.g., \(>\)200). The pure white color is generated if R = 255, G = 255 and B = 255. However, if a photograph is taken under a shadow, the background is slightly darker and these color levels are lower but even in this case they are approximately equal. The BSM2, marks a pixel \(i\) with color levels: \(R_{i}\), \(G_{i}\), \(B_{i}\) as the background if all the following conditions hold:  
\[R_{i}>c_{1},G_{i}>c_{1},B_{i}>c_{1},\ |R_{i}-G_{i}|<c_{2},\ |R_{i}-B_{i}|<c_{2},\ |B_{i}-G_{i}|<c_{2}, \tag{1}\]  
The precise values of the constants \(c_{1}\) and \(c_{2}\) are not critical. For example, selecting \(c_{1}\) = 200 and \(c_{2}\) = 30 worked satisfactorily for all the tested cases. Similarly, if the background is darker (black for simplicity) compared to the examined plant part, it could be identified if its pixel's gray or color levels are close to 0. The drawback of these low complexity background separation methods is that a region of the plant part can be confused and recognized as the background if its color is similar to the color of the background. If the confused region does not reach the boundary of the plant part, the ambiguity of whether it belongs to the plant part or the background can be easily solved by checking if it exists within the perimeter of the examined leaf or fruit. Assuming that the background (BG) pixels have been identified and the rest of the pixels are marked as normal plant part (LF), then a portion of the image may be represented as shown in Figure 1a. Each cell in Figure 1 corresponds to a single pixel. If a pixel internal to the plant part region has been mistakenly interpreted as background (as the central red BG pixel of Figure 1a) then the following check can (in most of the cases) reveal the error and correct it: all the pixels up to the image border, in each one of the four directions (up, down, left, right) are examined. In each one of these directions, if only LF or both BG and LF pixels are found, then it is likely that this pixel belongs to the normal plant part (e.g., leaf). The correction of such BG pixels can be performed with higher confidence if the pixels of the four diagonals are also examined in the same way. A different method would first map the plant part perimeter and then check the coordinates of a pixel to verify if it is located within this perimeter. After this first step, let us assume that the spot pixels (SP) have been identified as shown in Figure 1b. The area of the spots (\(A_{s}\)) as a fraction of the overall leaf area can simply be estimated as the ratio of the number of spot pixels to the number of both the spot and the leaf pixels. True dimensions can also be estimated as described in [28] if the distance of the camera from the plant part is known.