Soil color identification and related attribute rapid prediction method based on smart phone
Obtain soil sample images through smartphones and combine them with Munsell color cards to establish a linear correction model for soil color. The multiple linear stepwise regression method is used to solve the problems of subjectivity and cumbersome operation of traditional soil color measurement methods, and achieve soil color measurement. Rapid prediction of attributes reduces errors and costs, and has universal applicability and potential for popularization and application.
Patent Information
- Application Number
- CN202411048064.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2024-10-25
AI Technical Summary
Traditional soil color measurement methods are highly subjective and cumbersome, and require specific instruments, which limits their wide application.
Using a smartphone as a sensor, by acquiring soil sample images, the k-means algorithm and Munsell color card are used to establish a linear correction model for soil color, combined with the multivariate linear stepwise regression method to achieve rapid prediction of soil properties.
It achieves rapid and convenient prediction of soil color identification and related attributes, reduces errors and experimental costs, and has universal applicability and potential for popularization and application.
Smart Images

Figure CN118840569A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a soil color recognition and related attribute rapid prediction method based on a smart phone, belonging to the technical field of soil color recognition and related attribute prediction. Background Art
[0002] Soil color is an important morphological feature that characterizes many properties of soil. It is an important indicator for determining soil type, dividing occurrence layers, evaluating development degree, and studying soil properties. Various changes in color reflect changes in the intrinsic properties of soil materials. Among them, organic matter and free iron are important components of soil and are also important factors affecting soil color changes. At the same time, changes in soil color are an important indicator for evaluating the degree of soil development. The depth of soil color also most intuitively reflects the fertility of the soil. Therefore, quantitative extraction and identification of soil color can achieve indirect measurement and prediction of related attributes, which has important theoretical significance and application value.
[0003] The traditional soil color determination method is the visual colorimetry method, in which the operator compares the soil sample with the standard colorimetric card to obtain the soil color. Due to individual differences among operators, this method is easily affected by environmental factors, weather factors, light factors, and humidity factors, resulting in misjudgment. It is highly subjective and time-consuming and labor-intensive. Using a spectrophotometer to measure soil color is more objective and accurate than traditional methods, but the spectrophotometer used is not easy to carry and inconvenient to operate, which limits its wide application. At the same time, the prediction of soil properties, such as establishing an organic matter estimation model by measuring soil reflectance with a spectrometer, can quickly determine the organic matter content, but the spectrometer is relatively expensive and has strong professional operability, which limits its wide application to a certain extent.
[0004] In order to improve the efficiency of soil color measurement, researchers at home and abroad have conducted many explorations, trying to optimize algorithms and improve soil color acquisition methods from different angles. Although the error has been effectively reduced compared to traditional color recognition prediction, it has not yet solved the problems of the soil color measurement process requiring specific instruments to collect data, and the cumbersome data acquisition and operation methods. Summary of the invention
[0005] The technical problem to be solved by the present invention is to provide a method for quickly predicting soil color and related attributes based on a smart phone, using the mobile phone as a convenient sensor to quickly and conveniently solve the problem of soil color recognition and related attribute prediction.
[0006] The present invention adopts the following technical solutions to solve the above technical problems:
[0007] A method for rapid soil color recognition and related attribute prediction based on a smartphone includes the following steps:
[0008] Step 1, obtain a soil sample, place the soil sample in a black box equipped with an LED light bar, set the shooting parameters of a smartphone, use the smartphone to shoot an image of the soil sample, and ensure that the image shot by the smartphone is under a preset stable LED light source;
[0009] Step 2, randomly selecting a number of pixel points on the soil sample image, marking the selected pixel points on the RGB coordinates, using the k-means algorithm to find the central pixel point of the selected pixel points, and using the RGB color value of the central pixel point as the RGB color value of the soil sample image;
[0010] Step 3, placing the Munsell colorimetric card in the same black box as the soil sample, and taking a picture of the colorimetric card using a smart phone, and obtaining the RGB color value of the colorimetric card image using the same method as step 2;
[0011] Step 4, based on the RGB color value of the colorimetric card image and the actual RGB color value of the colorimetric card, a soil color linear correction model is established, and the RGB color value of the soil sample image is corrected using the soil color linear correction model to obtain a corrected RGB color value;
[0012] Step 5, converting the corrected RGB color values from the RGB color space into color values in HIS, CIELAB, CIELCH, and CIELUV color spaces in turn, thereby obtaining values of 13 color parameters, namely, R, G, B, H, I, S, L, A, B, C, H, U, and V;
[0013] Step 6, using 13 color parameters as independent variables and soil properties as dependent variables, adopting the multivariate linear stepwise regression method to build and train the model, obtain the soil property prediction model, and use the soil property prediction model to realize the prediction of soil properties.
[0014] As a preferred embodiment of the present invention, the specific process of step 1 is as follows:
[0015] The collected soil was air-dried and ground, and the soil obtained after passing through a 60-mesh sieve was used as a soil sample. The soil sample was placed at the bottom center of a black box with an LED light strip inside. The color temperature of the LED light strip was 6000K, and the incident angle of the light from the LED light strip on the surface of the soil sample was 45°. The shooting parameters of the smartphone were adjusted to ensure that the image taken by the smartphone was in a white balanced state. The soil sample was photographed using the smartphone with adjusted parameters to obtain a soil sample image.
[0016] As a preferred solution of the present invention, in step 2, an image of 800×800 pixels is cropped from the soil sample image, the center of the image of 800×800 pixels coincides with the center of the soil sample image, a number of pixels are selected from the image of 800×800 pixels, and the selected pixels are marked on RGB coordinates, and the selected pixels are clustered into one category using the k-means algorithm to obtain the cluster center pixel point, and the RGB color value of the cluster center pixel point is used as the RGB color value of the soil sample image.
[0017] As a preferred embodiment of the present invention, in step 3, the Munsell colorimetric card is placed in a black box with an LED light strip installed inside, and the Munsell colorimetric card is photographed using a smart phone with adjusted parameters to obtain a colorimetric card image, and an image of 200×200 pixels is cropped from the colorimetric card image, the center of the image of 200×200 pixels coincides with the center of the colorimetric card image, a number of pixels are selected from the image of 200×200 pixels, and the selected pixels are marked on RGB coordinates, and the k-means algorithm is used to cluster the selected pixels into one category to obtain cluster center pixels, and the RGB color value of the cluster center pixels is used as the RGB color value of the colorimetric card image.
[0018] As a preferred solution of the present invention, the specific process of step 4 is as follows:
[0019] Based on the RGB color value of the colorimetric card image and the actual RGB color value of the colorimetric card, a soil color linear correction model is established as follows:
[0020] Y=X·β+b
[0021] Wherein, Y represents the actual RGB color value of the colorimetric card, X represents the RGB color value of the colorimetric card image obtained in step 3, β is the coefficient matrix, and b is the intercept term; β and b are solved using the known X and Y to obtain the soil color linear correction model, and the RGB color value of the soil sample image is substituted into the model as X to calculate the corrected RGB color value.
[0022] As a preferred embodiment of the present invention, in step 6, the 13 color parameters corresponding to a soil sample and the attributes of the soil sample are taken as a data sample in a data set to obtain a data set, and the data set is divided into a training set and a validation set. The 13 color parameters are used as independent variables, and the soil attributes are used as dependent variables. A multivariate linear stepwise regression method is used to build and train the model to obtain a soil attribute prediction model, and the soil attributes include soil organic matter content and soil free iron content.
[0023] As a preferred solution of the present invention, in step 5, after the corrected RGB color value is converted from the RGB color space to the color value under the CIELAB color space, the color sensor is used to judge the accuracy of the corrected RGB color value obtained in step 4, and the formula is as follows:
[0024]
[0025] Where, ΔE ab Indicates the color difference in the CIELAB color space, ΔL* indicates the difference in brightness between the color sensor and the CIELAB color space, Δa* indicates the difference in component values from green to red, and Δb* indicates the difference in component values from blue to yellow; ΔE ab When <3, it means that the color of the soil sample identified by the soil color linear correction model is close to the color of the soil sample identified by the color sensor.
[0026] Compared with the prior art, the present invention adopts the above technical solution and has the following technical effects:
[0027] 1. The present invention uses a mobile phone camera as a sensor to quickly and conveniently obtain soil color information through matching and conversion of color space, thereby reducing the error caused by visual identification and the high cost of traditional laboratory spectral analysis.
[0028] 2. Based on the relationship between soil color and "staining" properties (organic matter, free iron, etc.), the present invention establishes a rapid prediction model for the above properties, which is both convenient and universal and has the potential for popularization and application. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 is a flow chart of a method for soil color recognition and related attribute prediction based on a smart phone of the present invention;
[0030] Figure 2 It is a black box model designed by the present invention;
[0031] Figure 3 is a selection diagram of target soil and color card images in an embodiment of the present invention, wherein (a) is a target soil image, and (b) is a color card image;
[0032] Figure 4 It is a color difference comparison between the soil color obtained by the mobile phone in the embodiment of the present invention and the color sensor Nix Pro2;
[0033] Figure 5 is a scatter plot of predicted organic matter content and measured organic matter content in soil in an embodiment of the present invention;
[0034] Figure 6It is a scatter plot of predicted free iron content and measured free iron content in soil in an embodiment of the present invention. DETAILED DESCRIPTION
[0035] The embodiments of the present invention are described in detail below, and examples of the embodiments are shown in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be interpreted as limiting the present invention.
[0036] The present invention proposes a method for realizing soil color recognition and rapid prediction of related attributes based on a smart phone, which is used to realize the color recognition of the soil to be detected in the target soil area and the prediction of color-related soil attributes, taking soil organic matter content and free iron content as examples. Figure 1 As shown, the specific steps are as follows:
[0037] Step 001: Soil data collection: The collected soil samples are air-dried, ground and passed through a 60-mesh sieve, and the obtained soil samples are placed in a container, keeping the surface flat.
[0038] Step 002: Preparation for shooting black box: Figure 2 As shown, the images were taken in a special black box (19cm×19cm×10cm), with an LED light bar inside the black box and a dark room to prevent light diffusion. The soil sample (90mm in diameter) was placed in a fixed position at the bottom center of the black box. The color temperature of the LED was 6000K, and the light intensity provided was stable. The incident angle of the light on the soil surface was approximately 45°, the soil sample was about 8cm away from the camera, and the soil sample was located at the center of the image.
[0039] Step 003: Mobile phone shooting settings: The model of the mobile phone does not need to be fixed. When shooting, the mode is adjusted to professional mode, and the mobile phone parameters are adjusted. The fixed parameters are shutter speed (S): 30 / 1, sensitivity (ISO): 320, exposure compensation (EV): 0, focus (F): 1.79, and focal length 23mm. The mobile phone is placed in a fixed position on the black box.
[0040] Step 004: Selection of target soil image: Identify the center of the culture dish and crop 800×800 pixels for further analysis, such as Figure 3 As shown in (a).
[0041] Step 005: Soil color extraction: Extract pixel points from the target soil image and mark them on the RGB coordinates. Use k-means clustering with a category value of 1 to find the central accumulation point of the scattered pixel points as the RGB color value of the current image.
[0042] Step 006: Munsell colorimetric card color extraction: Place a black box in the middle of the black box, take a picture of the colorimetric card, and crop the center of the colorimetric card picture to 200×200 pixels, such as Figure 3 As shown in (b), the color of the colorimetric card is extracted using the method of step 005.
[0043] Step 007: Soil color correction based on the Munsell colorimetric chart: By comparing the standard color on the Munsell colorimetric chart with the color in the colorimetric chart photo after shooting, a linear model soil color is established. The specific formula is as follows:
[0044] Y=X·β+b
[0045] Among them, Y is the corrected color value matrix, whose dimension is m×3, m is the number of samples, and 3 is the dimension of the color space; X is the input color value matrix, whose dimension is m×3; β is the coefficient matrix of the model, whose dimension is 3×3; b is the intercept term, whose dimension is 1×3, which contains the intercept value of each color space dimension.
[0046] Step 009: Conversion to different color spaces: The colors of soil samples and colorimetric cards are converted from the RGB color space model to other color space models, including HIS, CIEL*a*b*, CIEL*c*h*, and CIEL*u*v*.
[0047] Step 008: Evaluation of soil color recognition results: Use the color sensor Nix pro2 to evaluate the accuracy of color recognition. The color difference calculation formula is as follows:
[0048]
[0049] In the CIELAB color space, ΔL* represents the difference in brightness between the color sensor and the color extracted from the image, Δa* represents the difference in component values from green to red, and Δb* represents the difference in component values from blue to yellow. ab The smaller the difference between the two color measurement results, the smaller the difference between the two color measurement results. ab <3 means that the difference between the two is relatively subtle to the human eye. Figure 4 shown.
[0050] Step 010: Prediction of soil properties based on soil color: The color parameter data of soil samples in different color spaces are divided into training sets and validation sets, of which two-thirds of the samples are training sets and one-third of the samples are validation sets. The multivariate linear stepwise regression method (SMLR) is used to build a model, with 13 color parameters as independent variables, soil organic matter content and soil free iron content as dependent variables, and linear models of soil organic matter content and free iron content are established respectively. The specific formula is as follows:
[0051] SOM=75.066-0.931R+1.429h*
[0052] FI=-3.047+2.916b*-0.542R+0.478B
[0053] Step 011: Evaluate the accuracy of the model prediction results: Conduct laboratory analysis on soil samples, use potassium dichromate oxidation-external heating method to determine soil organic matter content, and use inductively coupled plasma emission spectrometry to determine soil free iron content. Select the coefficient of determination (R 2 ), root mean square error (RMSE) and relative percentage difference (RPD) were used as evaluation parameters to evaluate the difference between the attribute prediction results and the laboratory analysis results, where R 2 The larger the value, the smaller the RMSE and the larger the RPD, which indicates the higher the modeling accuracy. Figure 5 and Figure 6 Scatter plots of predicted and measured values of organic matter content and free iron content, respectively.
[0054] The above embodiments are only for illustrating the technical idea of the present invention, and cannot be used to limit the protection scope of the present invention. Any changes made on the basis of the technical solution in accordance with the technical idea proposed by the present invention shall fall within the protection scope of the present invention.
Claims
1. A method for rapid prediction of soil color and related attributes based on a smartphone, characterized in that: The steps include: Step 1, obtain a soil sample, place the soil sample in a black box equipped with an LED light bar, set the shooting parameters of a smartphone, use the smartphone to shoot an image of the soil sample, and ensure that the image shot by the smartphone is under a preset stable LED light source; Step 2, randomly selecting a number of pixel points on the soil sample image, marking the selected pixel points on the RGB coordinates, using the k-means algorithm to find the central pixel point of the selected pixel points, and using the RGB color value of the central pixel point as the RGB color value of the soil sample image; Step 3, placing the Munsell colorimetric card in the same black box as the soil sample, and taking a picture of the colorimetric card using a smart phone, and obtaining the RGB color value of the colorimetric card image using the same method as step 2; Step 4, based on the RGB color value of the colorimetric card image and the actual RGB color value of the colorimetric card, a soil color linear correction model is established, and the RGB color value of the soil sample image is corrected using the soil color linear correction model to obtain a corrected RGB color value; Step 5, converting the corrected RGB color values from the RGB color space into color values in HIS, CIELAB, CIELCH, and CIELUV color spaces in turn, thereby obtaining values of 13 color parameters, namely, R, G, B, H, I, S, L, A, B, C, H, U, and V; Step 6, using 13 color parameters as independent variables and soil properties as dependent variables, adopting the multivariate linear stepwise regression method to build and train the model, obtain the soil property prediction model, and use the soil property prediction model to realize the prediction of soil properties.
2. The method for rapid prediction of soil color and related attributes based on a smart phone according to claim 1, characterized in that: The specific process of step 1 is as follows: The collected soil was air-dried and ground, and the soil obtained after passing through a 60-mesh sieve was used as a soil sample. The soil sample was placed at the bottom center of a black box with an LED light strip inside. The color temperature of the LED light strip was 6000K, and the incident angle of the light from the LED light strip on the surface of the soil sample was 45°. The shooting parameters of the smartphone were adjusted to ensure that the image taken by the smartphone was in a white balanced state. The soil sample was photographed using the smartphone with adjusted parameters to obtain a soil sample image.
3. The method for rapid prediction of soil color and related attributes based on a smart phone according to claim 1 is characterized in that: In the step 2, an image of 800×800 pixels is cropped from the soil sample image, the center of the image of 800×800 pixels coincides with the center of the soil sample image, a number of pixels are selected from the image of 800×800 pixels, and the selected pixels are marked on RGB coordinates, and the selected pixels are clustered into one category using the k-means algorithm to obtain the cluster center pixel point, and the RGB color value of the cluster center pixel point is used as the RGB color value of the soil sample image.
4. The method for rapid prediction of soil color recognition and related attributes based on a smart phone according to claim 2, characterized in that: In the step 3, the Munsell colorimetric card is placed in a black box with an LED light strip installed inside, and the Munsell colorimetric card is photographed using a smart phone with adjusted parameters to obtain a colorimetric card image, and an image of 200×200 pixels is cropped from the colorimetric card image, the center of the image of 200×200 pixels coincides with the center of the colorimetric card image, a number of pixels are selected from the image of 200×200 pixels, and the selected pixels are marked on RGB coordinates, and the selected pixels are clustered into one category using a k-means algorithm to obtain a cluster center pixel, and the RGB color value of the cluster center pixel is used as the RGB color value of the colorimetric card image.
5. The method for rapid prediction of soil color and related attributes based on a smart phone according to claim 1, characterized in that: The specific process of step 4 is as follows: Based on the RGB color value of the colorimetric card image and the actual RGB color value of the colorimetric card, a soil color linear correction model is established as follows: Y=X·β+b Wherein, Y represents the actual RGB color value of the colorimetric card, X represents the RGB color value of the colorimetric card image obtained in step 3, β is the coefficient matrix, and b is the intercept term; β and b are solved using the known X and Y to obtain the soil color linear correction model, and the RGB color value of the soil sample image is substituted into the model as X to calculate the corrected RGB color value.
6. The method for rapid prediction of soil color and related attributes based on a smart phone according to claim 1, characterized in that: In step 6, the 13 color parameters corresponding to a soil sample and the properties of the soil sample are taken as a data sample in the data set to obtain a data set, and the data set is divided into a training set and a validation set. The 13 color parameters are used as independent variables and the soil properties are used as dependent variables. A multivariate linear stepwise regression method is used to build and train the model to obtain a soil property prediction model, and the soil properties include soil organic matter content and soil free iron content.
7. The method for rapid prediction of soil color and related attributes based on a smart phone according to claim 1, characterized in that: In step 5, after the corrected RGB color value is converted from the RGB color space to the color value under the CIELAB color space, the color sensor is used to determine the accuracy of the corrected RGB color value obtained in step 4, and the formula is as follows: Where, ΔE ab Indicates the color difference in the CIELAB color space, ΔL* indicates the difference in brightness between the color sensor and the CIELAB color space, Δa* indicates the difference in component values from green to red, and Δb* indicates the difference in component values from blue to yellow; ΔE ab When <3, it means that the color of the soil sample identified by the soil color linear correction model is close to the color of the soil sample identified by the color sensor.
Citation Information
Cited By
Soil profile map feature extraction method based on multi-color space
CN121904493A
