# Image Classification for Automated Image Cross-Correlation Applications in the Geosciences
## 2 Methods
### Image Classification  
As previously mentioned, using images acquired in conditions that are diffusely illuminated enables a reduction in the apparent motion caused by changes in shadow shapes in relation to surface roughness. To this aim, it is fundamental that images are categorized in accordance with their visual appearance. In this study, three classes of visual and illumination states are considered: (i) Direct illumination (SunLight), (ii) diffuse illumination (DiffLight), and (iii) blocked or limited view (NoVis).  
To identify the class of the images, SVMs are trained based on defining optimal decision hyper-planes that separate objects belonging to different classes [38]. In addition, the SVM assigns an a posteriori probability that each image belongs to a particular class. The objects are represented as vectors in an \(n\)-dimensional space, where the axes correspond to specific features that describe the objects. The elements of vectors represent feature values of each object that will be classified (for a didactic description of the SVM methods, please see [PERSON] [39]).  
To describe the images, seven different features are identified as follows: (i) The number of RGB triplets (i.e., the values for R, G, and B bands) (_colorNum_), where the number of triplets is divided by the number of pixels in the image. The division is conducted to make the datum comparable for different image resolutions; (ii-iii) the number of pixels in the range 0-63 (_blackNum_) and 64-127 (_greyNum_) of the intensity histogram, which are determined using an 8-bit colour chart; (iv-v) the mean value of the hue (_hueMean_) and saturation (_satMean_) channels in the HSV colour space; (vi) the value of the maximum peak in the image intensity histogram (_maxPeak_), and (vii) the corresponding bin position (_posPeak_) (Figure 1). The image intensity (or greyscale) is defined as the mean value of the RGB channels.  
We choose features that could be informative about the image appearance, and that were not correlated among them. Specifically, _colorNum_ should be directly associated with the amount of light in the image, which enhances the colour contrast, while _blackNum_ and _greyNum_ indicate different levels of image darkness. _hueMean_ is the average colour shade, and can be related to ambient skylight (i.e., diffuse illumination) [40], while _satMean_ is high when the colours are vivid, and low when they tend toward grey. _posPeak_ represents the dominant colour, while _maxPeak_ is the magnitude of the dominant colour. Figure 1a shows an 8-bit (256 colour bins per RGB channel) NoVis class image. Only 0.5% of the possible RGB triplets are present, which is evident from the narrow spatial distribution of the RGB values shown in Figure 1d. The upper portion of the picture has an almost uniform and grey colour that implies low _satMean_ (Figure 1b); this produces a prominent dark peak (high _maxPeak_, low _posPeak_) (Figure 1e).  
To reduce the dimensionality of the decision plane (i.e., to reduce the number of features used to train the SVM), a Monte Carlo cross-validation is conducted [41; 42], with the aim of selecting a group of features (i.e., the estimator) that minimize misclassification errors. The fundamental of that approach is to randomly divide the available known data into two groups, one to train the SVM (training set) and one to evaluate the misclassification error (test set), and the feature selection procedure is repeated many times. Features are sequentially added to the candidate estimator by selecting the feature or group of features that minimize the misclassification error (averaged on the multiple iterates). This procedure guarantees a higher generality of the SVM and enables overfitting to be avoided.  
To maintain generality no a priori information on the probability of class occurrence is introduced during the tuning of the SVM.