A novel feature based algorithm for soil type classification

Agriculture is the backbone of Bangladesh’s economy and it is one of the largest employment sectors. In Bangladesh, the population is increasing rapidly and at the same time, the total cultivable land is decreasing significantly. To ensure maximum crop production using the limited land resources, it is essential to identify and select the appropriate type of soil because different crops need different soil types. Currently, there are two types of methods available to determine the soil type, namely chemical and image analysis. Although the first one is accurate, it is expensive and time consuming. On the other hand, image based soil classification is much cheaper and faster but its accuracy level is low. In this study, we present a novel feature based algorithm that combines quartile histogram oriented gradients (Q-HOG), most frequent φ\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varphi $$\end{document}-Pixels and a new feature selection method for classifying soil types. We have used four machine learning algorithms and evaluated the performance with different sets of features. We have also compared our work with two prominent and recent works on image-based soil classification systems. The experimental results show that the performance of our proposed method in terms of four standard evaluation metrics, namely accuracy, precision, F1_score, and recall scores are higher than the existing image-based soil classification systems.


Introduction
Our life depends on food and this food comes directly or indirectly from the crop. Soil is the most important component for any type of crop production. But not every type of soil is perfect for every type of crop. Because different soils have different types of properties suitable for different crops. For example, sandy soil needs a huge amount of water. On the other hand, clay soil needs less water because of its good water storage capacity. Hence, soil type identification and selection are the primary steps before starting any crop cultivation. Soil type can be identified in two ways, namely using chemical analysis and image analysis. The chemical analysis is generally performed in a lab with different chemicals B Machbah Uddin machbah.csm@bau.edu.bd Md. Rakib Hassan rakib@bau.edu.bd 1 Department of Computer Science and Mathematics, Bangladesh Agricultural University, Mymensingh 2202, Bangladesh which is expensive, time consuming [15,16,30] and difficult to access for the general farmers.
On the other hand, soil type identification using image analysis is based on the color and texture of the soil. Soil color and texture can describe different physical, chemical and biological properties of soil. It has a strong relationship with water storage capacity, iron content, soil physical structure, and soil health [18]. White color soil shows good drainage capacity whereas black soil contains a high level of nitrogen [44]. Again, soil color and texture change with different environmental effects, therefore it can describe natural events in different areas [51]. It can also indicate the necessary amount of fertilizer needed for cultivation in a specific land [2,26,39,56].
A few works have been done to classify soil type based on image analysis. For example, soil type was classified from the color property of soil by digital image processing technique in [21]. Soil image spectrum analysis has been used in [21,58]. Rossel et al. used Munsell color chart with nine different color space modes to identify the soil type [44]. They also analyzed the relationship between soil color and organic carbon. Munsell color chart has also been used for archaeology analysis [35][36][37][38].
RGB image processing has been used for iron and carbon detection from soil images in [18,45]. Vibhute et al. developed soil classification system based on hyperspectral image data [57]. The hyperspectral image was also used in [43] and [8]. But the hyper-spectral imaging camera is very expensive in comparison to a smartphone camera. Stiglitz et al. used CMYK (Cyan, Magenta, Yellow, and Black) color conversion from Munsell color [18] and developed a software that can identify soil type in real time [51].
In [52], moisture content of the soil was identified using the CIEL*a*b* mode, and the depth of soil was measured by L*a*b* mode. RGB image processing based android application has been developed in [20] to find the soil color type. It converted RGB images to CIExyz and Munsell HVC mode. Another study was performed to classify dry and moisture sample images captured using GPS enabled devices [53]. They also used RGB, CMYK, CIElab, and XYZ mode image processing.
Ibáñez-Asensio et al. [26] performed a study to predict eighteen soil variables including carbon, nitrogen, iron, sand, and clay by using RGB image processing. Bogrekci et al. [6] used visible, near-infrared and ultraviolet reflectance of soil images to find phosphorus (P) concentration. A research was conducted for soil classification using multi-expression programming [2] which is a variant of genetic programming. Another study applied four different machine learning algorithms on a private soil attribute dataset [23]. They used 10 different attributes including specific gravity (GS), Altenberg limit (LL, PL, IP), etc. They found SVM works better than the neural network, decision tree, and k-means clustering.
In [12], the authors classified the soil image using RGB histogram processing of the surface image. Melo et al. proposed image segmentation-based multivariate image analysis technique for clay and sandy soil type identification [15,16,25]. Soil micromorphology based image analysis was used for soil classification in [49]. Liu et al. proposed a support vector machine (SVM) based prediction system for classification of urban soil [33].
These works indicate that soil type classification using image processing techniques are getting popular for their faster results and cheaper costs compared to the lab based chemical oriented techniques. But to the best of our knowledge, all of these existing works lack accuracy level. Besides, none of these works have a large dataset of soil images. Therefore, in this research, we have prepared a sufficiently large dataset and proposed a novel feature based algorithm for soil classification using the SVM model trained with multiple heterogeneous features and compared it with other machine learning algorithms and existing works. The experimental results of this proposed work also show promising accuracy levels compared to the existing works. Thus, this system can help to maximize crop production through the proper identification of soil types.
The main contributions of this work are: 1. We have proposed two new features: quartile histogram oriented gradients (Q-HOG) and most frequent ϕ-Pixels, 2. We have also introduced a novel dimensionality reduction technique for finding the most suitable features from three different feature selection algorithms, 3. We have prepared a public dataset consisting of 608 annotated soil images (38,912 augmented images dataset) that can be used as a benchmark, 4. We have compared the performance of our proposed algorithm with two recent works and found promising results of our system in terms of different evaluation metrics.
This work is organized as follows. We present the details of our proposed method to identify soil type in Section."Proposed methodology". In Section."Experiments and evaluation", we discuss experimental results and evaluation. Finally, in Section. "Conclusion", we summarize our work and draw some conclusions and future directions.

Proposed methodology
We have taken RGB images of soils and the details of this dataset are described in Section "Dataset collection". These images are then processed in several stages which are shown as a block diagram in Fig. 1. First, each RGB image is converted into two color modes, namely HSV and CIEL*a*b*. Second, all of these three modes are then partitioned into channels. Third, a total of 1,364 features are extracted from different channels. Fourth, different feature selection algorithms are applied to all the features to select the best features and prepare feature descriptors. Fifth, SVM and other machine learning models are trained by feeding the values of the feature descriptor. Sixth, the test image set is fed into the trained models for testing the soil type identification accuracy. In the last step, these results are analyzed and compared with two prominent and recent works on soil classification to show the performance of this proposed model. These steps are described in detail in the following sections.

Image mode conversion
As mentioned earlier, the soil images are taken in RGB mode. Therefore, we have to convert our RGB image into two different modes: HSV and CIE L * a * b * to extract different image features. A sample image with different modes is depicted in Fig. 2. To convert the RGB image to HSV and CIEL*a*b*, we have used the functions rgb2hsv and rgb2lab of MAT-LAB 2020b. HSV mode is useful for minimizing the noise and representing the actual color in a sharp way. On the other hand, CIEL*a*b* mode is suitable for texture representation [9,24,46].

Channel partition
An RGB image consists of three channels (red, green, blue). We have converted this RGB image into a gray channel using rgb2gray function by eliminating the hue and saturation and keeping luminance only [34]. HSV and CIEL*a*b* images are obtained from an RGB image using rgb2hsv and rgb2lab functions, respectively. in Fig. 3, we have shown the functions used for partitioning the images into different channels. Output images of different channels are also shown in this figure.
Partitioning the images into these channels will enable us to obtain different characteristics of a soil image [16,24,48]. Because every color space has different channels which measure different properties of light. For example, RGB is the combination of red, green and blue channels which are related to the color luminance. HSV defines the hue, saturation and values which are used to separate image luminance from color information. On the other hand, CIELab (or CIELAB, or CIE L*a*b) color space, defined by the International Commission on Illumination (CIE), has three channels which are luminance (black to white), a (green to red) and b (blue to yellow) [13]. Using different color channels reveals different properties of an image from different angles which can be used to effectively identify the various regions of interest resulting in more robust analysis.

Feature extraction
Feature extraction is a very important part of image processing because it extracts useful information from an image. It is a type of dimensionality reduction that discards the redundant information and obtains the relevant information using a reduced dimension or space [31]. In this work, we have extracted two types of features, namely textural and color features from soil images. Both the textural and color features are important for soil classification. Because both of them help to differentiate the soil types from one another. They can describe different physical, chemical, biological properties, water storage capacity, iron content, physical structure, amount of phosphorus, and soil health [6,18].
In this study, we have extracted three different textural features, namely Q-HOG, Haralick and LBP. For color features, we have used ϕ-Pixels, Mean, Median, Mode, Standard Deviation, Skewness and Kurtosis. In the following subsections, we describe only the new ones proposed in this work.

Quartile histogram oriented gradients (Q-HOG)
Q-HOG is the new surface textural feature that we have proposed in this work. It is a modified version of the histogram oriented gradients (HOG) feature. HOG is already used in various agricultural applications [28,40,55]. It is calculated from the intensity distribution (histogram) and the gradients of the pixels using extractHOGFeatures function in MAT-LAB 2020b. Generally, HOG returns a large vector which requires more time and space to compute. It is invariant with the scale and rotation of objects. Alex et al. used HOG for situ leaf classification [40] and they found this feature is promising for agricultural machine learning. Other studies also used HOG for leaf and weed classification [27,60].
Srisamosorn et al. [50] developed an improved HOG named Fisheye HOG (FEHOG) where they reduced the computational time in several stages. Ghaffari et al. [19] performed a comparative study for FPGA based HOG feature implementations and they mentioned that FPGA-HOG features are computationally faster than the traditional HOG. Sharma et al. [47] proposed a transformed version of HOG where they used only magnitude information rather than orientation information, and they also claimed it to be faster than the traditional HOG. However, the above-mentioned HOG  modifications generate a vector that is of equal length to the conventional HOG vector. But in this work, we have proposed Quartile-HOG or Q-HOG where we have reduced the size of the HOG vector by selecting a portion of the most frequent pixels using Algorithm 1. First, we determine the histogram of the HOG vector. Second, we sort the bins of the histogram in descending order based on the frequencies of bin values. Third, we select the first quartile (Q) pixels having the most frequencies. Lastly, we use these Q pixels in feature selection algorithms. As a result, Q-HOG is more efficient than the original HOG in terms of computational speed and storage space because it will provide a small set of features to the machine learning algorithm. Based on the background study, we believe that our proposed work based on Q-HOG is new in the field of soil classification and type identification.

Haralick and LBP
Haralick textual features [22] are used to describe the textures in an image. It is calculated from the gray-level co-occurrence matrix (GLCM) [1,41] that describes how frequently the Two sample image pixels 4 × 4. a contains zero and one pixels only b pixels from zero to three different patterns exist including correlation, roughness, orientation, structure, and entropy of an image. It creates a tabular form of probabilities. In this paper, we have used 14 Haralick texture features [3,42]. These features are calculated using the gray level co-occurrence matrix (GLCM). Local Binary Pattern (LBP) feature is suitable for defining soil textures [54]. It computes the texture pattern using a sliding window with the eight-neighbor algorithm technique. In each window, the neighbor elements are compared with the center element and produce an eight-bit string. After that, the process counts the frequencies of each pattern and produces a vector. We have computed the LBP feature using extractLBPFeatures function in MATLAB 2020b which returns 59 values for 8 neighbors.

Most frequent '-Pixels
In an RGB 8-bit image, a pixel value varies from 0 to 255. As described in Section "Channel partition", a channel image visualizes only one type of pixel among red, green or blue ones. In Fig. 4, there are two sample images. In the first image, 9 pixels have 0 values and 7 have 1. Hence, the most frequent pixel is zero. In the second image, the number of pixels having 0, 1, 2 and 3 are 6, 3, 4 and 3, respectively. Thus, the most frequent pixel here is also 0. In the first case, within 16 pixels, the frequency of 0:1 is 9:7, where 7 is not considered for representing an image. In the second one, there are pixels having values other than 0. But 0 is also the most frequent one. If we consider only a single most frequent pixel, the representation will not be accurate. So, in this work, we propose to select the most frequent ϕ-Pixels by using Algorithm 2 which can represent an image effectively. In this algorithm, we count the frequencies of each pixel. A pixel is selected if it occurs at least 4% of the total number of pixels. Thus we form a set of ϕ-Pixels by selecting the most frequent pixels. For example, if we use this algorithm in the first image of Fig. 4, both 0 and 1 pixels will be selected because they occur 56.25% and 43.75%, respectively. Similarly, in the latter image of Fig. 4, all the pixels will be selected because they represent at least 4% of the image. Algorithm 2: Algorithm for finding the most frequent ϕ-Pixels from a channel Input: channel image C img Output: a set of most frequent pixels ϕ 1 Vector C hist = histogram(C img ) C hist size is S dimensional where S ranges from 1 − 255 2 Form a set of pixels ϕ by selecting the most frequent pixels, where m i is the number of occurrences of i th pixel and k is the number of bins in the histogram C hist 3 Return ϕ

Traditional color features
We also used the traditional features for color representation, for example, brightness, mean, median, mode, standard deviation, skewness, and kurtosis. In the following sections, we have described the feature selection and descriptor processes.

Feature selection
It is a process of selecting an efficient subset of features that are most relevant for modeling and representing an image. Feature selection is important because all the variables are not equally influential for predicting the final result. Besides, some of them can have a negative impact on the result. Feature selection is also termed dimensionality reduction which helps to build a good model by reducing problem complexity. There are different types of feature analysis techniques such as univariate, bivariate and multivariate. In this research, we used the Random Forest (RF) [7,11,17], Lasso (LS) [10,14,29], and Pairwise Correlation (PC) [59] multivariate techniques to find the important features. We use Matlab TreeBagger function for RF with default settings. Also, we use lasso function for LS with Alpha = 0.5, cross validation = "resubstitution", number of Monte Carlo repetitions = 1, and Rho = 2. In case of PC, we use corrcoef function with alpha = 0.05 and rows = "pairwise". The number of selected features from three techniques are not similar as represented in Table 1. Then we finally selected the feature set FS by applying the union and intersection of all features found from FS RF , FS LS , and FS PC techniques using Eq. 1. We considered only those features which are selected by at least two of the techniques using this equation. From Table 1, we see the number of selected features by FS RF , FS LS , and FS PC are 262, 192, and 316 respectively. And the final number of features after applying the equation is 207. The details of selected features can be found from here.

Machine learning algorithms
We have used four machine learning algorithms in this work. They are support vector machine (SVM), artificial neural network (ANN), multiple regression (MR) and decision tree (DT). SVM is a machine learning algorithm that is used for classification, pattern recognition, and prediction of different problems of both linear and non-linear types. The main focus of this algorithm is to generate a hyperplane that divides the given dataset into two equal parts which are suitable for binary classification problems. Several techniques can further enhance a traditional binary class SVM to solve multiclass problems [61]. In case of SVM, we used Matlab multiclass model with default settings where the kernel function was gaussian. ANN is also a machine learning algorithm that works based on the human neural system. It is mainly comprised of input, hidden, and output layers. ANN can solve multiclass problems. We configured ANN with 3 hidden layers with tansig activation function, 1 output layer with sigmoid activation function, and the input layer is equal to number of features. On the other hand, the MR algorithm is an extension and modification of existing linear regression. It is most suitable for supervised learning [32]. We used mvregress function with default settings where estimation algorithm was maximum likelihood estimation via the ECM algorithm, initial estimate for the variance-covariance matrix was sigma, type of variance-covariance matrix was full, and the maximum number of iterations was 1000. DT algorithm works by formulating many trees from the given dataset where a leaf node represents a decision, and the internal nodes represent the pairwise correlations. The technique works well when the extracted feature numbers are small in size [32]. It was configured with K Fold = 10, Max N um Splits = 4, optimizer was bayesopt, acquisition function to expected improvement and repartition status to false. Bisgin et al. [5] shows that SVM performs well rather than ANN for agricultural genus identification and classification. Liakos et al. [32] compared the performance of different machine learning models applied in the agricultural domain and they mentioned that in most of the cases, SVM is the high performing algorithm. Therefore, we also used SVM along with these three other algorithms to measure the performance of our proposed work.
In this research, we used supervised training which means we are providing labeled data with input feature data. All these machine learning algorithms are used with different sets of features for testing our proposed Q-HOG, ϕ-Pixels set, and the feature selection process of Eq. 1.

Experiments and evaluation
In this section, we discuss dataset preparation, machine learning models and their validation, error analysis and sensitivity of the model. This section also discusses classification accuracy, comparison between different settings and with existing works.

Dataset collection
In this research, most of the soil samples are collected from different locations of Mymensingh division, Bangladesh and a few of the samples are collected from the online soil dataset. We collected the soil samples using a trowel in the depth of 0-15 cm of the surface and dried the samples at 105 degrees celsius in the laboratory. After that, the samples are properly grounded and placed on a paper surface. In the next step, a smartphone was set using a tripod stand at a 5cm distance and the images were captured. We took 76 images for a soil type by changing the orientation of the paper at different angles. The configuration of the smartphone was Samsung Galaxy A20 with a 13MP camera and the captured image resolution was (4160 × 3120) with the size of 5.48 MB. There were eight different classes of datasets, namely (i) Agronomy, (ii) Clay, (iii) Compost, (iv) EPI, (v) Loamy, (vi) SI, (vii) Sandy and (viii) Silt. These class names are ordered alphabetically. Hence, there are 76 × 8 = 608 images in the initial dataset. Later, we apply image augmentation technique to increase per class images using Matlab imageDataAugmenter function which augments images by resizing in 4 scaling levels with resolutions (4160 × 3120, 2080 × 1560, 1040×780 and 520×390), 4 rotational levels (0, 90, 180 and 270 degree), and 4 reflection levels (horizontal: on, off, and vertical: on, off) shown in Table 2. Hence, each soil class contains 76 × 64 = 4864 images. Therefore, our data set contains total 4864 × 8 = 38912 images of soil. The dataset snippet is shown in Fig. 5.

Experimental setup
To evaluate our system performance, we have trained our machine learning models by considering 17 different combinations of extracted features. We have also prepared 17 different experimental setups for these combinations. These configurations are described in Table 3. The detailed results of different settings and comparisons are described in the following section.

Experimental results
As mentioned earlier, for each set of feature combinations, four different machine learning (ML) models (SVM, ANN, MR, and DT) were trained and tested. We use Matlab's 10fold cross-validation technique to determine the evaluation result for each setting because this technique is more appropriate than manually dividing the dataset into training and testing. In this technique, the dataset is randomly divided into 90% for training and 10% for validation and this process is repeated 10 times. This technique provides the average accuracy from 10 experiments and we use this result. We have presented the experimental results in three sections. In Section "Evaluation results in different settings", the accuracy, precision, recall, and F1_score for different ML models in each setting are described. In Section "Performance using public dataset", we have tested the performance of our proposed methods using a publicly available soil dataset. We have also selected two prominent and recent works [4,54] in soil classification and compared their performance with ours. The comparison results are presented in "Comparison with Existing Studies".

Evaluation results in different settings
The detailed investigation results of different settings are depicted in Table 4. From this table, we can observe that the SVM model performs better than other algorithms in most of the settings. SVM obtained the highest performance in all evaluation matrices with our proposed selected features Sel_FS using Eq. 1. On the contrary, the lowest performance is observed in TCF setting which is comprised of traditional color features. The performance score differ-ences between these two configurations are 36.79%, 36.16%, 35.37%, and 36.35% for accuracy, precision, recall, and F1_score, respectively. Table 4 clearly demonstrates that our proposed Q-HOG, ϕ-Pixels set and selected features using Eq. 1 always perform better in terms of different performance metrics. Moreover, in Table 5, we present the inside result of 10-fold cross validation with its accuracy and standard deviation where we see that the deviations of both the accuracy and correctly identified images are low. It indicates the performance and stability of the proposed system.
Machine learning model selection: We conducted rigorous experiments in different settings which are presented in Table 4. In our experiment, we consider a total of 17 settings which are listed in Table 3. For each setting, we train and test the system with 4 ML models (SVM, ANN, MR, DT) and measure the performance in 4 evaluation metrics (accuracy, precision, recall, and F1_score). We observe that in each setting, there are performance differences within ML models. In the case of accuracy, we observe the highest difference of 3.39% in QHOG setting where the best score is achieved by the SVM model which is 80.74% and the lowest is 77.35%. On the other hand, we got the minimum accuracy difference in HLICK setting, but here too SVM provides the best result. The average accuracy difference within ML models is 1.60%. Moreover, we observe that in the majority of settings, SVM provides the best result. In addition, we also observe that in our best performing Sel_FS setting, the performance improved by 1.48% due to selecting the best ML model which is achieved by SVM. In case of precision score, maximum difference is 3.08% on AF setting, minimum is 0.47% on Lasso_FS setting, and average is 1.45%. This time we also observe that in the majority of settings, SVM model provides the highest precision score. In the case of a recall, the maximum difference is 3.50% and the minimum is 0.23%. However, we find a smaller range of variations (0.46% to 3.06%) on F1 score differences in different ML models. We observe that in the majority of cases SVM model provides the best recall and F1_score which follows a very similar, pattern to accuracy and precision. Therefore, we can conclude that among the 4 ML models, SVM model is very much suitable for soil classification.
Influence of feature selection: To find the influence of feature selection, we have considered two sets where the first one is composed of all extracted features without any filtering (AF) and the second one is comprised of selected features (Sel_FS). These are described in Table 3. We observed that the performance score varies from 88% to 99%. The maximum precision score difference between the two settings is 11.54% and the minimum difference is 8.34%. Sel_FS setting performs better in all of the evaluation metrics.
We have also analyzed the performance of three different feature selection algorithms, namely random forest (RF_FS), lasso (Lasso_FS) and pairwise correlation (PC_FS) settings.  ered. On the other hand, we introduced ϕ-Pixels to represent the color feature and it is represented in PPIX setting. The comparative results are shown in Table 4. We see that in all evaluation metrics, the textural category shows prominent results which are 84-85% whereas the color feature performance varies from 73 to 74%. Therefore, textural features perform better than color features in soil type classification and the score difference between the two features is 8-13%. Influential textural feature group: We found that textural features have more impact on soil classification in comparison to the color category. Now, we determine which textural feature group has more impact on model building. For this purpose, we considered three different feature group settings. The first group has Q-HOG features only in QHOG, the second group has Haralick features HLICK, and the third is LBP features in LBP setting. The comparative result is depicted in Table 4. We observed that the performance varies by almost 10% in different settings and Q-HOG feature performs the best compared to Haralick and LBP features. Hence, we deduce that the Q-HOG feature is highly influential among all textural features.

Impact of brand new proposed features:
In this research, we have introduced two brand new features described in the feature extraction section. One of them is Q-HOG described in "Quartile histogram oriented gradients (Q-HOG)", and the other is ϕ-Pixels illustrated in "Most Frequent ϕ-Pixels". We examined the combined influence of these two features in overall model achievement by preparing QHOG_PPIX setting. We compared the performance of this setting with Sel_FS performance. We observe from Table 4 that this QHOG_PPIX setting achieved a 90-91% performance score. Hence, we can say that our new proposed feature has a notable influence on classification performance.
Finding the most influential feature: It is observed from Table 4 that Haralick textural feature setting is found to yield the lowest performance. To determine the performance of the remaining Q-HOG, ϕ-Pixels and LBP, we considered eight settings. Four of them are only Q-HOG (QHOG), only Haralick (HLICK), only ϕ-Pixels (PPIX), and only LBP textural (LBP). The last four of them include the features by excluding specific features from all of the feature sets. For example, excluding Q-HOG (AF_ExQHOG), excluding Haralick (AF_ExHLICK), excluding LBP (AF_ExLBP) and excluding ϕ-Pixels (AF_ExPPIX) from the set of all features (AF).
The comparison result of these eight settings is shown in Fig. 6. To better understand the figure, we have considered accuracy and precision only, skipping recall and F1_score but detail values are shown in Table 4. From this figure, we can see that the most influential is Q-HOG (QHOG), then ϕ-Pixels (PPIX), (LBP) and the last one is Haralick (HLICK) setting. On the other hand, we are obtaining the worst performance if we remove Q-HOG (AF_ExQHOG) which means that this is the most influential one, then the worst performance for removing ϕ-Pixels (AF_ExPPIX), omitting LBP (AF_ExLBP) and the last one is removing Haralick (AF_ExHLICK). In recapitulation, we can rank the features from the most influential to the least as Q-HOG, ϕ-Pixels, LBP, and Haralick. Interestingly, we observed that our newly proposed two features, namely Q-HOG and ϕ-Pixels are highly potential candidates for soil classification.  Bold values indicate the comparative best results of the four machine learning models for each evaluation metric in each setting

Model robustness:
We also investigated the model performance on the number of soil types. First, we tested the model with only two types of soils among the eight types. As a result, 8 C 2 = 28 combinations of classes (e.g., Agronomy, Clay, Agronomy, Compost, ..... , Sandy, Silt) are obtained. This combination is named as T2Type. SVM is used with the selected features to test all combinations with 10-fold crossvalidation and accuracy is measured. We then took three types from eight which creates 8 C 3 = 56 combinations and named as T3Type. Accuracy was determined like previous steps. Similarly, we tested all the remaining combinations. Those are 70, 56, 28, 8 and 1 combinations for 4 (T4Type), 5 (T5Type), 6 (T6Type), 7 (T7Type) and 8 (T8Type) types of soil, respectively. The overall result is depicted in Fig. 7. We observe that for all combinations, accuracy varies from 99.58% to 100% with a slight variation in each setting. Hence, we can conclude that our model is robust with the different number of soil types. It also implies that the model will perform better even if we add new soil types.

Performance using public dataset
We applied our best setting to an online dataset of Kaggle available at the following URL. The dataset contains four types of soil (Alluvial, Black, Clay, and Red), where each class contains 175 images for training and 48 images for testing. Hence, there are total 700 images for training the model and we applied our best setup Sel_FS from table 3 and prepared a feature descriptor of dimension (700 × 207). The result is depicted in Fig. 8. The experimental results reveal that our extracted features are highly efficient for soil classification on public datasets because it achieved 99.81% accuracy using the SVM model. It also shows higher scores for other metrics.

Comparison with existing studies
To find out the true performance of our proposed system, we have selected two very recent and prominent works in soil classification and compared these works with our proposed one. The first work is done by Barman et al. [4]. They classified soil types using multi-class SVM. They used 50 and compared with our proposed selected features (Sel_FS) using Eq. 1, which is depicted in Fig. 9. We observe that the accuracy difference between the two models is 37.6%. But Barman et al. claimed their accuracy to be 91.37% on their soil dataset. This may happen due to the overfitting of their model. They also used a small number of images to measure their performance. As a result, they obtained a biased result of SVM. However, after applying their method to our dataset, we observed that the accuracy is 62.19%, which is a remarkable difference. The promising results of our work indicate the effectiveness of the proposed Q-HOG, ϕ-Pixels set and feature selection algorithm of Eq. 1.
We also compared our performance with Swetha et al. [54] where they used a dataset of 270 images from three soil types (e.g., clay, silt and sand). They extracted HSV color histogram (512 × 1), Hu moments (7 × 1), Haralick (13 × 1), LBP (26 × 1) and Scale-invariant feature transformation (SIFT) (100 × 1) features, and produced (668 × 1) feature space. They used SVM and Convolutional Neural Network (CNN) for soil classification. In CNN, they relied on automatic feature extraction from RGB images. To compare their results with ours, we extracted 668 features from our dataset. Then we trained CNN and SVM models using the extracted features. In the case of CNN, we used hand crafted 668 features instead of automatic feature extraction from RGB images. Besides, we trained CNN and SVM using our features of best setup (Sel_FS). The detailed analytical results are represented in Table 6 [54]. We have also compared the performance of four algorithms using our Sel_FS. The result is shown in Fig. 10 where we can see that our proposed system performs better than the work presented in [54].
Based on the presented experimental results, we can conclude that our combined feature selection technique with the SVM model achieved the highest performance. The textural features also had a huge influence on model building and among all textural features, Q-HOG contributes significantly. As an individual feature group, the Q-HOG has the highest impact, then ϕ-Pixels, LBP, Haralick and then traditional features. We also observed that the model building with our newly proposed Q-HOG, ϕ-Pixels and innovative dimensionality reduction technique (Sel_FS) have a great impact. The experimental results and comparison of our work with a public dataset and two prominent and recent works show the promising performance improvement of the proposed model. Lastly, our system is robust and dynamic on the number of soil type changes. The achieved scores prove the efficiency of our proposed work with these novel features.

Fig. 9
Performance comparison with Barman et al. [4] and our best performing setup Sel_FS using our dataset

Conclusion
Identification of the soil type is necessary for optimal crop production. In this research work, a computer vision-based automated soil classification system has been developed for predicting soil type. The experimental results show that this proposed system is more accurate than any other existing image-based soil analysis system. In this model, Q-HOG, ϕ-Pixels and novel feature selection method were proposed for the first time. Our selected features were heterogeneous in nature. We have investigated the performance of each individual feature in this research. The results indicate that every feature carries a reasonable impact in identifying the soil image. Since the accuracy of this proposed system is very high, it can contribute to increased crop production. There still remain many research challenges in this area. For example, many types of soil can be analyzed instead of 8 different soil types used in this work. Besides, soil with grass analysis can be explored in the future. Lastly, including seasonal  [54] and the proposed best performing setup Sel_FS using our dataset data with this model can provide more accurate predictions because crop cultivation also varies with seasonal parameters.