Soil Nutrient Detection Using Genetic Algorithm: November 2019
Soil Nutrient Detection Using Genetic Algorithm: November 2019
net/publication/340893073
CITATIONS READS
0 115
6 authors, including:
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by John Carlo Velasco Puno on 21 July 2020.
Abstract—Genetic Algorithm is the method used in this study There are a lot of studies and applications that uses
in classifying the qualitative level of the soil nutrients. The data Genetic Algorithm for soil analysis. In [6], Genetic
set includes images coming from the result of the soil testing. Algorithm is used in predicting the Calcium and Magnesium
The extracted features were the HSV values and the LAB content in soil together with generalized regression neural
values color space. Out of the six extracted features from the
data set, the B from LAB color space is the most linear so with
networks. Another study predicts the soil moisture content
that, it is the input of genetic algorithm in identifying the as the basis of agriculture in saving water from the irrigation.
qualitative level of the soil nutrients. For the run of the It uses Genetic Neural Network based on Annealing
program using python programming language and pyCharm Algorithm [7]. In a separate study, detecting soil moisture is
CE as IDE, the values of each parameters follow: the being studied by combining finite element with genetic
population size is 10, mutation rate is 0.01, the number of cross algorithm [8]. Most of Genetic Algorithm applications for
over points is 2 and the maximum number of generations is soil concentrate on determining soil moisture and some
1000. The population’s final best fitness has 98.2609% that nutrient parameters stated above.
proves that Genetic Algorithm is an effective method in
classifying the qualitative level of the soil nutrients.
For soil nutrient detection, existing studies uses image
Index Terms—Soil, Genetic Algorithm, MATLAB, Python, processing techniques such as thresholding and masking to
Nutrients extract features and machine learning algorithm such as
neural network to identify or classify the nutrient level. In
I. INTRODUCTION [2], it uses a box that has a controlled light environment that
is used for data acquisition. The box also considers the
Soil Preparation is essential because with lacking or distance of camera so that the soil sample is fixed. The image
excessive use of fertilizer may harm the planted crop. The that will be captured from the module box will undergo
amount of fertilizer also affects the percentage yield [1]. Soil image processing to identify the qualitative level of nutrients
Nutrients can be subdivided into two groups namely: and pH level of the soil. In [9]–[11], different sensors such
Macronutrients (Nitrogen, Phosphorus, and Potassium) and as optical, electrochemical, and radiometric sensors were
Micronutrients (Zinc, Calcium, and Magnesium). The used as on-the-go sensor since it is portable. From these
former is the basis of common commercial fertilizer that sensors, electromagnetic sensors are widely used together
makes the management of the use of these fertilizers with electrical sensors. Combining Analog-to-Digital
essential [2]. Converter, Photodiodes, LED and Field Programmable Gate
Array (FPGA) were also used in determining nutrient level
There are a lot of ways on how to determine soil nutrients of the soil in a separate study [12]. Ion Selective Electrodes
and one of these is by using the Soil Test Kit (STK) invented (ISEs) are very common type of sensors used in detecting
by the Bureau of Soils and Water Management (BSWM). It certain parameter that it was used in [13]. Adding to these
is an organization in the Philippines under the Department existing studies, [14] uses color detector sensor in extracting
of Agriculture (DA) that caters the needs of our farmers by the RGB values of the result of soil testing then interpret its
providing new technologies that will help our farmers nutrient level. Lastly, RF spectroscopy is also now being
improve their yield [3]. Not only in the Philippines, STK used in determining the soil nutrients such as potassium and
was widely used in other countries including over 50 nitrogen [15]. Genetic Algorithm alone is not used in
locations in the United States [4]. STK uses chemicals that determining the soil nutrient level, it is always partnered
changes its color depending on the nutrient level present in with neural network. GA was generally used for
the sample. For Nitrogen and Phosphorus, it can be Low, optimization of parameters [16], [17]. In general, this study
Medium or High, while for Potassium, it can be Deficient or aims to use Genetic Algorithm in identifying the qualitative
Sufficient. The result of this test will be the basis for the level of the nutrient of the soil. Specifically, this paper
fertilizer recommendation computed by the soil technician focuses on the development of a program that identify the
[5]. qualitative level of Potassium, Phosphorus, and using
genetic algorithm via python programming language.
(a)
The general structure shows the stages that the system Figure 3. (a) Design of the Image Acquisition Box (b) Web camera
will undergo to identify the qualitative level of soil nutrient.
First the captured image will be the input of the system taken The box has a physical dimension of 9.5” x 8” x 5”
from the sample acquisition box. The image will undergo (LWH). To come up with these measurements, an
image processing where in it will be cropped with the setting experiment was conducted that considers the distance of the
of the region of interest. Thresholding and Masking will also camera and the sample with good focus. The height of the
take place in this stage. After this, the extracted feature will test tube from the STK was also considered for the height of
be generated. Six features will be extracted namely: Hue, the box. The width considers the spaces between the test
Saturation, Value (from the HSV colorspace), Lightness, A, tubes being used in data acquisition. An image will be
and, B (From LAB colorspace) [18]. One feature will be the acquired from the box that will undergo image processing
input of the genetic algorithm. Choosing the best feature from the result of the soil testing. A specific spot in the box
depends on what feature among the six is the most linear. is allotted for each test tube with sample and chemicals to be
And finally, the genetic algorithm will generate the analyzed before image acquisition.
optimized genotype values that will identify the qualitative
level of the soil nutrients. B. Image Processing
C. Feature Extraction
Table 1
Extracted Features Values from the Data Set
Hue Saturation Value Lightness A (green-red) B (blue-yellow) Output
0.12134542 0.68493809 0.75923074 171.713299 134.8569862 2.2506 0
0.11215798 0.64827186 0.79513425 178.327265 136.5039821 2.2448 0
0.10305924 0.77199426 0.59952233 124.115814 144.1264641 2.2304 0.5
0.10305924 0.77199426 0.59952233 124.115814 144.1264641 2.2304 0.5
0.11911921 0.47210589 0.6100488 147.141608 130.1967846 2.1953 1
0.13941705 0.38207285 0.65903802 165.209968 126.3918676 2.1943 1
0.14331611 0.28621919 0.6079092 156.039663 125.8943338 2.1695 1.5
0.14454301 0.33996554 0.45111107 116.096634 126.3925358 2.1695 1.5
0.26319809 0.23388569 0.36483279 96.3220065 121.02589 2.1416 2
0.26319809 0.23388569 0.36483279 96.3220065 121.02589 2.1416 2
0.53082889 0.06333821 0.60716562 157.454028 130.4744601 2.113 2.5
0.57804457 0.06305313 0.59997807 156.823595 129.7232186 2.1107 2.5
0.57900937 0.22964307 0.52506363 128.023666 123.5312311 2.0775 3
0.61087501 0.23975916 0.51466893 121.214881 126.147322 2.0724 3
0.64988685 0.52740648 0.40379337 70.5724729 135.1198938 2.0178 3.5
0.61756202 0.48380261 0.52320037 100.767923 129.0790533 2.0138 3.5
Legend: 0 – Potassium Deficient, 0.5 – Potassium Sufficient, 1 – Nitrogen Low, 1.5 – Nitrogen Medium, 2 – Nitrogen High, 2.5 – Phosphorus Low,
3 – Phosphorus Medium, 3.5 – Phosphorus High
The values of the most linear among the extracted The GA finds individuals with optimal parameters for a
features (B) undergone natural logarithm function to lower linear function whose output is a number near 0 to 3.5 with
its numerical value. The output is the numerical value increment of 0.5; whichever of those numbers the output is
corresponding to the nutrient level of the soil. closest to, the classification is that number. More
specifically, the function is f[B(Blue-Yellow)] = (173 +
D. Genetic Algorithm (A/B) * [B(Blue-Yellow)]^3) - (1131 + (C/D) * [B(Blue-
Yellow)]^2) + (2443 + (E/F)* [B(Blue-Yellow)]) – 1745.2,
The Genetic Algorithm codes were inspired from a Mini- and the parameters are A, B, C, D, E, F. These parameters
Project to build a classifier for Fisher’s Iris Data Set [26]. are allowed to have the integer range -100 and 100
(inclusive). Other extracted features were not considered
because other extracted features were non-linear and can be III. DESIGN CONSIDERATIONS
named as “noisy data”.
MATLAB was used for image processing. It includes
E. Result image pre-processing, image segmentation, and feature
extraction. The most linear extracted feature (B (Blue-
The Result of the Genetic Algorithm after run are 6 Yellow)) will be the input for Genetic Algorithm that uses
different integers correspond to the values of the 6 python programming language and pyCharm CE as the IDE.
parameters (A, B, C, D, E, and F). Substituting these
parameters will lead to a numerical value from 0 to 3.5.
A. Preferences Setting
Before the run of the Genetic Algorithm some to 20. These values can be changed with your own
parameters for GA must be set. For the population size, it is preference but for this run, it has a Population’s Best Fitness
set to 10. For the mutation rate, 0.01 is the value being input. of 98.2609% with Genotype values of -18, -67, -29, 106, -
Cross over rate has a value of 0.6. the cross over points is set 39, and 105. The Result of the run from #1 to #20 is shown
to 2. Then the maximum number of generation is 1000. The in table 2.
number of times to run the GA with these parameters is set
Table 2
Summary of test Run of GA with the Best Fitness and Genotype Values
B. Validation substituted to function above and must have the same value
By cross-checking the correctness of the genotype values for the output. Figure 7 shows some of the comparison of the
produced by the genetic algorithm, the values were output and the value of the function.
Figure 7. Comparison of the Result the output vs the value of the function after substitution of genotypes