A method and system for detecting heavy metal cadmium in rice
Through spectral imaging technology and image processing methods, the problem of cumbersome, time-consuming and low sensitivity of rice cadmium detection in the prior art is solved, and fast, automated and lossless cadmium detection is achieved, which improves detection efficiency and accuracy.
Patent Information
- Application Number
- CN202210852369.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-19
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2042-07-19
AI Technical Summary
The prior art is complicated to operate, time-consuming and labor-intensive when detecting heavy metal cadmium in rice, with low sensitivity and low degree of automation, making it difficult to meet the requirements of fast and non-destructive testing.
By obtaining the overall image information of the sample station area, extracting the characteristic parameters of the sample to be detected, generating the scanning path information of the spectral imaging system, controlling the spectral imaging system to scan the samples to be detected according to the preset scanning path, obtaining the reflected spectral image, and performing correction processing to extract the average spectral reflectance value of the preset area of interest, and determining the content value of heavy metal cadmium.
The cadmium content is realized at one time for each part of the rice, which improves the detection efficiency, simplifies the detection process, and realizes automatic adjustment of detection parameters and non-destructive detection functions.
Smart Images

Figure CN115406846B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of agricultural detection, and in particular to a method and a system for detecting heavy metal cadmium in rice. Background Art
[0002] Cadmium is a silvery-white toxic metal pollutant widely spread through industrial production and agricultural practice. It is mainly used in the production of batteries and pigments. It is non-degradable and accumulative, and is one of the most toxic heavy metals in the environment. Cadmium is widely present in the environment and enters the ecosystem through water sources, soil, air flow, etc. Cadmium in the soil can be absorbed into the body by rice roots, seriously affecting the normal growth of rice and causing harm to human health through the food chain. In addition, the cumulative effect of heavy metal cadmium in different rice parts is also different. Therefore, in the process of detecting heavy metal cadmium in rice, it is often necessary to detect the corresponding cadmium content in different parts of rice. However, conventional detection methods are cumbersome, time-consuming and labor-intensive, with low sensitivity and low degree of automation, and it is difficult to meet the requirements of rapid and non-destructive detection. Therefore, rapid, efficient and accurate detection of heavy metals in crops is of great significance for effectively monitoring crop growth, early detection and early prevention of crop toxicity stress, cultivating high-yield and high-quality crops, and realizing green agricultural development. Summary of the invention
[0003] The invention overcomes the shortcomings of the prior art and provides a method and system for detecting heavy metal cadmium in rice.
[0004] In order to achieve the above object, the technical solution adopted by the present invention is:
[0005] The first aspect of the present invention discloses a method for detecting heavy metal cadmium in rice, comprising the following steps:
[0006] Acquire the overall image information of the sample stage area, and extract the characteristic parameters of the sample to be detected from the overall image information;
[0007] generating scanning path information of the spectral imaging system based on the characteristic parameters, and transmitting the scanning path information to a control terminal of the spectral imaging system;
[0008] Based on the scanning path information, the spectral imaging system is controlled to scan the sample to be detected according to a preset scanning path, so as to obtain a reflection spectrum image of the sample to be detected;
[0009] Correcting the reflected spectrum image, and extracting the average spectral reflectance of a preset area of interest from the corrected reflected spectrum image;
[0010] The heavy metal cadmium content value of each preset area of interest is determined according to the average spectral reflectance value.
[0011] Furthermore, in a preferred embodiment of the present invention, extracting characteristic parameters of the sample to be detected from the overall image information specifically includes the following steps:
[0012] Acquire image information of preset test samples through a big data network, establish a database, and import the image information of the preset test samples into the database to obtain an image information database of the preset test samples;
[0013] Importing the overall image information of the sample platform area into the image information database of the preset detection sample for identification, and obtaining an identification result;
[0014] Determine whether there is a preset detection sample in the sample station area according to the recognition result;
[0015] If it exists, the characteristic parameters of the sample to be detected are extracted based on the overall image information.
[0016] Furthermore, in a preferred embodiment of the present invention, the scanning path information of the spectral imaging system is generated based on the characteristic parameters, and the scanning path information is transmitted to the control terminal of the spectral imaging system, which specifically includes the following steps:
[0017] Acquire the maximum scanning area range of the spectral imaging system during scanning, and divide the sample to be detected into a plurality of sub-scanning areas based on the maximum scanning area range;
[0018] Determine the center position points of a plurality of the sub-scanning areas respectively, generate one or more scanning path information according to the center position points and the sub-scanning areas, and obtain path values of the one or more scanning paths;
[0019] Establishing a size arrangement chart, importing the path values of the one or more scanning paths into the size arrangement chart, and extracting the scanning path with the minimum path value from the size arrangement chart;
[0020] The scanning path of the minimum path value is transmitted to the control terminal of the spectral imaging system as the final scanning path information.
[0021] Furthermore, in a preferred embodiment of the present invention, before the step of controlling the spectral imaging system to scan the sample to be detected according to the preset scanning path based on the scanning path information, the step also includes the step of debugging the spectral imaging system:
[0022] Obtaining an actual distance value between the lower surface of a CCD camera in a spectral imaging system and the upper surface of a sample to be detected, and calculating a difference between the actual distance value and a preset distance value to obtain a distance difference;
[0023] Determining whether the distance difference is within a preset threshold range;
[0024] If it is not located, generating first correction information to correct the position of the CCD camera;
[0025] If it is located, the sample stage is controlled to move at a preset speed, and the debugging image information of each sub-scanning area is obtained through the CCD camera;
[0026] Extracting contour shape information of the sample to be detected in each sub-scanning area from the debugging image information;
[0027] Determine whether the contour shape information is the same as the preset contour;
[0028] If they are different, second correction information is generated to correct the preset moving speed of the sample stage.
[0029] Furthermore, in a preferred embodiment of the present invention, the reflectance spectrum image is corrected, and the average spectral reflectance of the preset area of interest is extracted from the corrected reflectance spectrum image, which specifically includes the following steps:
[0030] Correcting the reflection spectrum image to obtain a high-spectral reflectance image of a preset area of interest;
[0031] Obtain reflectance spectral curves of a target area and a background area in a preset area of interest according to the spectral reflectance image, and compare the two reflectance spectral curves to obtain a first spectral wavelength with the largest difference and a second spectral wavelength with the smallest difference between the target area and the background area;
[0032] Performing ratio processing on the first spectral wavelength and the second spectral wavelength, thereby obtaining a ratio image of a target area and a background area in a preset area of interest;
[0033] Performing threshold segmentation on the ratio image to obtain a grayscale mask image, and performing shadow removal processing on the grayscale mask image to obtain a binary mask image;
[0034] Applying the binary mask image to the reflectance spectrum image to obtain the reflectance spectrum image of the preset region of interest after masking;
[0035] The average spectral reflectance of the preset region of interest is obtained based on the reflectance spectrum image of the preset region of interest after the mask.
[0036] Furthermore, in a preferred embodiment of the present invention, the content of heavy metal cadmium in each preset region of interest is determined according to the average value of the spectral reflectance, which specifically includes the following steps:
[0037] Obtain the standard heavy metal cadmium content values corresponding to different spectral reflectance averages in different areas of interest through the big data network, and establish a prediction database;
[0038] Obtain the average spectral reflectance values of different preset regions of interest respectively;
[0039] The average values of the spectral reflectances of the different preset regions of interest are imported into the prediction database, so as to determine the content values of the heavy metal cadmium corresponding to the different preset regions of interest.
[0040] Another aspect of the present invention discloses a system for detecting heavy metal cadmium in rice, the system comprising a storage device and a processor, the storage device comprising a method program for detecting heavy metal cadmium in rice, when the method program for detecting heavy metal cadmium in rice is executed by the processor, the following steps are implemented:
[0041] Acquire the overall image information of the sample stage area, and extract the characteristic parameters of the sample to be detected from the overall image information;
[0042] generating scanning path information of the spectral imaging system based on the characteristic parameters, and transmitting the scanning path information to a control terminal of the spectral imaging system;
[0043] Based on the scanning path information, the spectral imaging system is controlled to scan the sample to be detected according to a preset scanning path, so as to obtain a reflection spectrum image of the sample to be detected;
[0044] Correcting the reflected spectrum image, and extracting the average spectral reflectance of a preset area of interest from the corrected reflected spectrum image;
[0045] The heavy metal cadmium content value of each preset area of interest is determined according to the average spectral reflectance value.
[0046] Furthermore, in a preferred embodiment of the present invention, extracting characteristic parameters of the sample to be detected from the overall image information specifically includes the following steps:
[0047] Acquire image information of preset test samples through a big data network, establish a database, and import the image information of the preset test samples into the database to obtain an image information database of the preset test samples;
[0048] Importing the overall image information of the sample platform area into the image information database of the preset detection sample for identification, and obtaining an identification result;
[0049] Determine whether there is a preset detection sample in the sample station area according to the recognition result;
[0050] If it exists, the characteristic parameters of the sample to be detected are extracted based on the overall image information.
[0051] Furthermore, in a preferred embodiment of the present invention, the scanning path information of the spectral imaging system is generated based on the characteristic parameters, and the scanning path information is transmitted to the control terminal of the spectral imaging system, which specifically includes the following steps:
[0052] Acquire the maximum scanning area range of the spectral imaging system during scanning, and divide the sample to be detected into a plurality of sub-scanning areas based on the maximum scanning area range;
[0053] Determine the center position points of a plurality of the sub-scanning areas respectively, generate one or more scanning path information according to the center position points and the sub-scanning areas, and obtain path values of the one or more scanning paths;
[0054] Establishing a size arrangement chart, importing the path values of the one or more scanning paths into the size arrangement chart, and extracting the scanning path with the minimum path value from the size arrangement chart;
[0055] The scanning path of the minimum path value is transmitted to the control terminal of the spectral imaging system as the final scanning path information.
[0056] Furthermore, in a preferred embodiment of the present invention, the reflectance spectrum image is corrected, and the average spectral reflectance of the preset area of interest is extracted from the corrected reflectance spectrum image, which specifically includes the following steps:
[0057] Correcting the reflection spectrum image to obtain a high-spectral reflectance image of a preset area of interest;
[0058] Obtain reflectance spectral curves of a target area and a background area in a preset area of interest according to the spectral reflectance image, and compare the two reflectance spectral curves to obtain a first spectral wavelength with the largest difference and a second spectral wavelength with the smallest difference between the target area and the background area;
[0059] Performing ratio processing on the first spectral wavelength and the second spectral wavelength, thereby obtaining a ratio image of a target area and a background area in a preset area of interest;
[0060] Performing threshold segmentation on the ratio image to obtain a grayscale mask image, and performing shadow removal processing on the grayscale mask image to obtain a binary mask image;
[0061] Applying the binary mask image to the reflectance spectrum image to obtain the reflectance spectrum image of the preset region of interest after masking;
[0062] The average spectral reflectance of the preset region of interest is obtained based on the reflectance spectrum image of the preset region of interest after the mask.
[0063] The present invention solves the defects existing in the background technology and can achieve the following technical effects:
[0064] The present invention obtains the overall image information of the sample platform area, and extracts the characteristic parameters of the sample to be detected from the overall image information; generates the scanning path information of the spectral imaging system based on the characteristic parameters, and transmits the scanning path information to the control terminal of the spectral imaging system; controls the spectral imaging system to scan the sample to be detected according to the preset scanning path based on the scanning path information, so as to obtain the reflection spectrum image of the sample to be detected; performs correction processing on the reflection spectrum image, and extracts the average spectral reflectance of the preset area of interest from the reflected spectrum image after the correction processing; determines the content value of heavy metal cadmium of each preset area of interest according to the average spectral reflectance. In this way, the cadmium content of each part of the rice can be detected at one time, which is beneficial to improving the detection efficiency. The detection process is simple, and the detection parameters can be automatically adjusted, and the function of non-destructive detection is also realized. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, drawings of other embodiments can be obtained based on these drawings without paying creative work.
[0066] Figure 1 An overall method flow chart of a method for detecting heavy metal cadmium in rice is shown;
[0067] Figure 2 A first part of a method flow chart of a method for detecting heavy metal cadmium in rice is shown;
[0068] Figure 3 A second method flow chart of a method for detecting heavy metal cadmium in rice is shown;
[0069] Figure 4 A third method flow chart of a method for detecting heavy metal cadmium in rice is shown;
[0070] Figure 5 A system block diagram for detecting heavy metal cadmium in rice is shown. DETAILED DESCRIPTION
[0071] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0072] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.
[0073] Figure 1 An overall method flow chart of a method for detecting heavy metal cadmium in rice is shown.
[0074] The first aspect of the present invention discloses a method for detecting heavy metal cadmium in rice, comprising the following steps:
[0075] S102: Acquire overall image information of the sample stage area, and extract characteristic parameters of the sample to be detected from the overall image information;
[0076] S104: generating scanning path information of the spectral imaging system based on the characteristic parameters, and transmitting the scanning path information to a control terminal of the spectral imaging system;
[0077] S106: controlling the spectral imaging system to scan the sample to be detected according to a preset scanning path based on the scanning path information, so as to obtain a reflection spectrum image of the sample to be detected;
[0078] S108: performing correction processing on the reflection spectrum image, and extracting the average spectral reflectance of a preset area of interest from the reflected spectrum image after correction processing;
[0079] S110: Determine the heavy metal cadmium content value of each preset area of interest according to the average spectral reflectance value.
[0080] It should be noted that under the irradiation of the excitation light source, the spectrum emitted by the biological substance contains a lot of qualitative or quantitative information about the object to be tested, and the spectral imaging system can be used to determine the changes in the substance and the content of various components. The spectral imaging system usually includes a C-type zoom lens, a CCD camera, a hyperspectral imager, a halogen light source, a fiber optic catheter, a sample stage, a stepper motor, a linear slide module, a light source intensity controller, a control system, a display, etc.
[0081] It should be noted that the overall image information of the sample platform area is obtained by a CCD camera, and the overall image information of the sample platform area includes the sample platform background image and the detection sample image. The characteristic parameters include the overall contour information of the sample to be detected, the root area position information, the stem area position information, the leaf area position information, the ear area position information, etc. The preset area of interest includes the root area, stem area, leaf area, ear area, etc. of the sample to be detected.
[0082] Figure 2 A flow chart of the first part of a method for detecting heavy metal cadmium in rice is shown.
[0083] Furthermore, in a preferred embodiment of the present invention, extracting characteristic parameters of the sample to be detected from the overall image information specifically includes the following steps:
[0084] S202: Acquire image information of a preset detection sample through a big data network, establish a database, and import the image information of the preset detection sample into the database to obtain an image information database of the preset detection sample;
[0085] S204: importing the overall image information of the sample platform area into the image information database of the preset detection sample for recognition, and obtaining a recognition result;
[0086] S206: judging whether there is a preset detection sample in the sample station area according to the recognition result;
[0087] S208: If it exists, extract the characteristic parameters of the sample to be detected based on the overall image information.
[0088] It should be noted that the image information of the preset detection sample is the standard image information of rice in each growth period. The image information of the preset detection sample is trained through machine learning algorithms, deep learning algorithms, convolutional neural networks, etc., so as to obtain an image information database of the preset detection sample. In this way, the overall image information of the sample platform area is imported into the image information database of the preset detection sample for identification, so that it can be determined whether the sample to be detected placed on the current sample platform is a rice sample. The identification process is to use the unique texture characteristics, shape characteristics, reflectivity under the spectrum, etc. of each area of rice to identify the sample to be detected on the sample platform. When it is identified that the sample to be detected on the sample platform is rice, the characteristic parameters of the rice to be detected are extracted from the overall image information.
[0089] It should be noted that in rice fields, there are usually weeds with similar shapes to rice, and these weeds are often difficult to distinguish from rice. Therefore, in the detection process, in order to prevent the staff from testing these weeds as rice samples, it is necessary to automatically determine whether the sample to be tested on the sample table is rice through S202 to S208 determination steps. If not, the control system will generate an alarm message to remind the staff to discard the weeds on the sample table, so as to avoid the situation where the weeds are tested as test samples, and then the weed detection data is regarded as rice inspection data, which affects the reliability and accuracy of the detection data.
[0090] Figure 3 A second method flow chart of a method for detecting heavy metal cadmium in rice is shown.
[0091] Furthermore, in a preferred embodiment of the present invention, the scanning path information of the spectral imaging system is generated based on the characteristic parameters, and the scanning path information is transmitted to the control terminal of the spectral imaging system, which specifically includes the following steps:
[0092] S302: Acquire the maximum scanning area range when the spectral imaging system is scanning, and divide the sample to be detected into a plurality of sub-scanning areas based on the maximum scanning area range;
[0093] S304: respectively determining the center position points of a plurality of the sub-scanning areas, and generating one or more scanning path information according to the center position points and the sub-scanning areas, and obtaining path values of the one or more scanning paths;
[0094] S306: establishing a size arrangement chart, importing the path values of the one or more scanning paths into the size arrangement chart, and extracting the scanning path with the minimum path value from the size arrangement chart;
[0095] S308: Transmitting the scanning path of the minimum path value as final scanning path information to the control terminal of the spectral imaging system.
[0096] It should be noted that when the light emitted by the halogen light source in the spectral imaging system is used to scan the sample to be detected, its scanning range is limited. Therefore, we can determine the maximum scanning area range of the spectral imaging system at a single time during scanning and detection, and then use the maximum scanning area range to divide the sample to be detected into several sub-scanning areas, and extract the center position points of each sub-scanning area. Then, one or more scanning paths are planned through algorithms such as ant colony algorithms and genetic algorithms, and the path values of each scanning path are calculated. Then, we select the shortest path value as the final scanning path, thereby maximizing the detection efficiency.
[0097] Furthermore, in a preferred embodiment of the present invention, before the step of controlling the spectral imaging system to scan the sample to be detected according to the preset scanning path based on the scanning path information, the step also includes the step of debugging the spectral imaging system:
[0098] Obtaining an actual distance value between the lower surface of a CCD camera in a spectral imaging system and the upper surface of a sample to be detected, and calculating a difference between the actual distance value and a preset distance value to obtain a distance difference;
[0099] Determining whether the distance difference is within a preset threshold range;
[0100] If it is not located, generating first correction information to correct the position of the CCD camera;
[0101] If it is located, the sample stage is controlled to move at a preset speed, and the debugging image information of each sub-scanning area is obtained through the CCD camera;
[0102] Extracting contour shape information of the sample to be detected in each sub-scanning area from the debugging image information;
[0103] Determine whether the contour shape information is the same as the preset contour;
[0104] If they are different, second correction information is generated to correct the preset moving speed of the sample stage.
[0105] It should be noted that the preset distance value is 0.5 meters, and the preset threshold range is 0.015 to 0.02 meters. The actual distance value between the lower surface of the CCD camera and the upper surface of the sample to be detected is calculated by the reflection time of the laser emitted by the halogen light source. If the distance difference is not within the preset threshold range, the camera height of the CCD camera needs to be corrected to ensure that the CCD camera can fully capture the image of each sub-scanning area while ensuring the clarity of the image.
[0106] It should be noted that before the formal scanning and testing of the samples to be tested on the sample stage, the moving speed of the sample stage needs to be calibrated to avoid distortion of the sample image obtained. Specifically, after the position of the CCD camera is calibrated, the sample stage is controlled to move at a preset moving speed, wherein the preset moving speed is 4.58 mm / s, and the debugging image information of each sub-scanning area is obtained through the CCD camera, and the contour shape information of the samples to be tested in each sub-scanning area is extracted from the debugging image information. If the moving speed of the sample stage is too fast, the extracted contour shape information of the samples to be tested will have distortions such as overlapping and blurred shape boundaries. Therefore, in order to ensure the image quality obtained in the subsequent actual scanning test, it is necessary to calibrate the moving speed of the sample stage, and the calibration formula is as follows:
[0107] ,
[0108] Among them, the represents the moving speed of the sample stage after correction; Represents the preset moving speed of the sample stage; is the number of pixels of the sample to be tested in the moving direction of the sample stage; Represents the number of pixels of the sample to be tested that is perpendicular to the direction of movement of the sample stage.
[0109] Furthermore, in a preferred embodiment of the present invention, the reflectance spectrum image is corrected, and the average spectral reflectance of the preset area of interest is extracted from the corrected reflectance spectrum image, which specifically includes the following steps:
[0110] Correcting the reflection spectrum image to obtain a high-spectral reflectance image of a preset area of interest;
[0111] Obtain reflectance spectral curves of a target area and a background area in a preset area of interest according to the spectral reflectance image, and compare the two reflectance spectral curves to obtain a first spectral wavelength with the largest difference and a second spectral wavelength with the smallest difference between the target area and the background area;
[0112] Performing ratio processing on the first spectral wavelength and the second spectral wavelength, thereby obtaining a ratio image of a target area and a background area in a preset area of interest;
[0113] Performing threshold segmentation on the ratio image to obtain a grayscale mask image, and performing shadow removal processing on the grayscale mask image to obtain a binary mask image;
[0114] Applying the binary mask image to the reflectance spectrum image to obtain the reflectance spectrum image of the preset region of interest after masking;
[0115] The average spectral reflectance of the preset region of interest is obtained based on the reflectance spectrum image of the preset region of interest after the mask.
[0116] It should be noted that after the spectral imaging system scans each sub-scanning area of the sample to be detected according to the preset scanning path, in order to reduce the influence of environmental factors and improve the signal-to-noise ratio, it is necessary to correct the reflection spectrum image of the sample to be detected, and the formula is as follows:
[0117] ,
[0118] in, represents the corrected reflectance spectrum image expressed as relative reflectance; Represents the original acquired reflectance spectrum image; It means that a dark image is recorded by completely closing the aperture of the CCD camera; represents the white reference image obtained by the white calibration tile; Indicates the exposure time of the CCD camera to the sample to be tested; Indicates the exposure time of the CCD camera to the white reference image; Indicates the exposure time of the CCD camera to the dark image.
[0119] It should be noted that the target area is the position area of each part of the rice in the spectral reflectance image, for example, the position area of the rice leaf area in the spectral reflectance image; and the background area is the background plate area of each part of the rice in the spectral reflectance image. The main reason for the difference between the reflectance spectra of each part of the rice and the background plate is that: the background plate is mainly black, its reflectance spectrum value is generally low and the curve is stable, without significant peaks and troughs; while the rice is green or brown, and the reflectance spectrum of the area presented by the internal pigment has significant peaks and troughs such as green peaks, red valleys, and red edges. Therefore, after comparing the two reflectance spectrum curves, the first spectral wavelength with the largest difference between the target area and the background area and the second spectral wavelength with the smallest difference can be obtained. In addition, the threshold selection in the threshold segmentation is mainly based on the boundary critical values of the regions of each part of the rice and the interfering background plate region. The optimal segmentation threshold can be determined by comparing the image after threshold segmentation.
[0120] It should be noted that the grayscale mask image is de-shadowed by using the expansion, closing and corrosion processing operations in mathematical morphology to obtain a binary mask image.
[0121] Figure 4 The third part of the method flow chart of a method for detecting heavy metal cadmium in rice is shown.
[0122] Furthermore, in a preferred embodiment of the present invention, the content of heavy metal cadmium in each preset region of interest is determined according to the average value of the spectral reflectance, which specifically includes the following steps:
[0123] S402: Obtain the standard heavy metal cadmium content values corresponding to different spectral reflectance average values of different areas of interest through a big data network, and establish a prediction database;
[0124] S404: Obtaining the average spectral reflectance values of different preset regions of interest respectively;
[0125] S406: Importing the average values of the spectral reflectances of the different preset regions of interest into the prediction database, thereby determining the content values of heavy metal cadmium corresponding to the different preset regions of interest.
[0126] It should be noted that since the spectral reflectance average values of different heavy metal contents in different parts of rice are different, the standard heavy metal cadmium content values corresponding to different spectral reflectance average values of various parts of rice can be obtained in advance in the big data network, and a prediction database can be established; then the obtained spectral reflectance average values corresponding to different parts of rice can be imported into the preset database, so that the heavy metal cadmium content values corresponding to different parts of rice can be quickly predicted through big data.
[0127] Figure 5 A system block diagram for detecting heavy metal cadmium in rice is shown.
[0128] Another aspect of the present invention discloses a system for detecting heavy metal cadmium in rice, the system comprising a storage 41 and a processor 62, the storage 41 comprising a method program for detecting heavy metal cadmium in rice, when the method program for detecting heavy metal cadmium in rice is executed by the processor 62, the following steps are implemented:
[0129] Acquire the overall image information of the sample stage area, and extract the characteristic parameters of the sample to be detected from the overall image information;
[0130] generating scanning path information of the spectral imaging system based on the characteristic parameters, and transmitting the scanning path information to a control terminal of the spectral imaging system;
[0131] Based on the scanning path information, the spectral imaging system is controlled to scan the sample to be detected according to a preset scanning path, so as to obtain a reflection spectrum image of the sample to be detected;
[0132] Correcting the reflected spectrum image, and extracting the average spectral reflectance of a preset area of interest from the corrected reflected spectrum image;
[0133] The heavy metal cadmium content value of each preset area of interest is determined according to the average spectral reflectance value.
[0134] It should be noted that under the irradiation of the excitation light source, the spectrum emitted by the biological substance contains a lot of qualitative or quantitative information about the object to be tested, and the spectral imaging system can be used to determine the changes in the substance and the content of various components. The spectral imaging system usually includes a C-type zoom lens, a CCD camera, a hyperspectral imager, a halogen light source, a fiber optic catheter, a sample stage, a stepper motor, a linear slide module, a light source intensity controller, a control system, a display, etc.
[0135] It should be noted that the overall image information of the sample platform area is obtained by a CCD camera, and the overall image information of the sample platform area includes the sample platform background image and the detection sample image. The characteristic parameters include the overall contour information of the sample to be detected, the root area position information, the stem area position information, the leaf area position information, the ear area position information, etc. The preset area of interest includes the root area, stem area, leaf area, ear area, etc. of the sample to be detected.
[0136] Furthermore, in a preferred embodiment of the present invention, extracting characteristic parameters of the sample to be detected from the overall image information specifically includes the following steps:
[0137] Acquire image information of preset test samples through a big data network, establish a database, and import the image information of the preset test samples into the database to obtain an image information database of the preset test samples;
[0138] Importing the overall image information of the sample platform area into the image information database of the preset detection sample for identification, and obtaining an identification result;
[0139] Determine whether there is a preset detection sample in the sample station area according to the recognition result;
[0140] If it exists, the characteristic parameters of the sample to be detected are extracted based on the overall image information.
[0141] It should be noted that the image information of the preset detection sample is the standard image information of rice in each growth period. The image information of the preset detection sample is trained through machine learning algorithms, deep learning algorithms, convolutional neural networks, etc., so as to obtain an image information database of the preset detection sample. In this way, the overall image information of the sample platform area is imported into the image information database of the preset detection sample for identification, so that it can be determined whether the sample to be detected placed on the current sample platform is a rice sample. The identification process is to use the unique texture characteristics, shape characteristics, reflectivity under the spectrum, etc. of each area of rice to identify the sample to be detected on the sample platform. When it is identified that the sample to be detected on the sample platform is rice, the characteristic parameters of the rice to be detected are extracted from the overall image information.
[0142] It should be noted that in rice fields, there are usually weeds with similar shapes to rice, and these weeds are often difficult to distinguish from rice. Therefore, in the detection process, in order to prevent the staff from testing these weeds as rice samples, it is necessary to automatically determine whether the sample to be tested on the sample table is rice through S202 to S208 determination steps. If not, the control system will generate an alarm message to remind the staff to discard the weeds on the sample table, so as to avoid the situation where the weeds are tested as test samples, and then the weed detection data is regarded as rice inspection data, which affects the reliability and accuracy of the detection data.
[0143] Furthermore, in a preferred embodiment of the present invention, the scanning path information of the spectral imaging system is generated based on the characteristic parameters, and the scanning path information is transmitted to the control terminal of the spectral imaging system, which specifically includes the following steps:
[0144] Acquire the maximum scanning area range of the spectral imaging system during scanning, and divide the sample to be detected into a plurality of sub-scanning areas based on the maximum scanning area range;
[0145] Determine the center position points of a plurality of the sub-scanning areas respectively, generate one or more scanning path information according to the center position points and the sub-scanning areas, and obtain path values of the one or more scanning paths;
[0146] Establishing a size arrangement chart, importing the path values of the one or more scanning paths into the size arrangement chart, and extracting the scanning path with the minimum path value from the size arrangement chart;
[0147] The scanning path of the minimum path value is transmitted to the control terminal of the spectral imaging system as the final scanning path information.
[0148] It should be noted that when the light emitted by the halogen light source in the spectral imaging system is used to scan the sample to be detected, its scanning range is limited. Therefore, we can determine the maximum scanning area range of the spectral imaging system at a single time during scanning and detection, and then use the maximum scanning area range to divide the sample to be detected into several sub-scanning areas, and extract the center position points of each sub-scanning area. Then, one or more scanning paths are planned through algorithms such as ant colony algorithms and genetic algorithms, and the path values of each scanning path are calculated. Then, we select the shortest path value as the final scanning path, thereby maximizing the detection efficiency.
[0149] Furthermore, in a preferred embodiment of the present invention, the reflectance spectrum image is corrected, and the average spectral reflectance of the preset area of interest is extracted from the corrected reflectance spectrum image, which specifically includes the following steps:
[0150] Correcting the reflection spectrum image to obtain a high-spectral reflectance image of a preset area of interest;
[0151] Obtain reflectance spectral curves of a target area and a background area in a preset area of interest according to the spectral reflectance image, and compare the two reflectance spectral curves to obtain a first spectral wavelength with the largest difference and a second spectral wavelength with the smallest difference between the target area and the background area;
[0152] Performing ratio processing on the first spectral wavelength and the second spectral wavelength, thereby obtaining a ratio image of a target area and a background area in a preset area of interest;
[0153] Performing threshold segmentation on the ratio image to obtain a grayscale mask image, and performing shadow removal processing on the grayscale mask image to obtain a binary mask image;
[0154] Applying the binary mask image to the reflectance spectrum image to obtain the reflectance spectrum image of the preset region of interest after masking;
[0155] The average spectral reflectance of the preset region of interest is obtained based on the reflectance spectrum image of the preset region of interest after the mask.
[0156] It should be noted that after the spectral imaging system scans each sub-scanning area of the sample to be detected according to the preset scanning path, in order to reduce the influence of environmental factors and improve the signal-to-noise ratio, it is necessary to correct the reflection spectrum image of the sample to be detected, and the formula is as follows:
[0157] ,
[0158] in, represents the corrected reflectance spectrum image expressed as relative reflectance; Represents the original acquired reflectance spectrum image; It means that a dark image is recorded by completely closing the aperture of the CCD camera; represents the white reference image obtained by the white calibration tile; Indicates the exposure time of the CCD camera to the sample to be tested; Indicates the exposure time of the CCD camera to the white reference image; Indicates the exposure time of the CCD camera to the dark image.
[0159] It should be noted that the target area is the position area of each part of the rice in the spectral reflectance image, for example, the position area of the rice leaf area in the spectral reflectance image; and the background area is the background plate area of each part of the rice in the spectral reflectance image. The main reason for the difference between the reflectance spectra of each part of the rice and the background plate is that: the background plate is mainly black, its reflectance spectrum value is generally low and the curve is stable, without significant peaks and troughs; while the rice is green or brown, and the reflectance spectrum of the area presented by the internal pigment has significant peaks and troughs such as green peaks, red valleys, and red edges. Therefore, after comparing the two reflectance spectrum curves, the first spectral wavelength with the largest difference between the target area and the background area and the second spectral wavelength with the smallest difference can be obtained. In addition, the threshold selection in the threshold segmentation is mainly based on the boundary critical values of the regions of each part of the rice and the interfering background plate region. The optimal segmentation threshold can be determined by comparing the image after threshold segmentation.
[0160] It should be noted that the grayscale mask image is de-shadowed by using the expansion, closing and corrosion processing operations in mathematical morphology to obtain a binary mask image.
[0161] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0162] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0163] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0164] A person of ordinary skill in the art can understand that: all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: a mobile storage device, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0165] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the methods of each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
[0166] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for detecting heavy metal cadmium in rice, characterized in that: The steps include: Acquire the overall image information of the sample stage area, and extract the characteristic parameters of the sample to be detected from the overall image information; generating scanning path information of the spectral imaging system based on the characteristic parameters, and transmitting the scanning path information to a control terminal of the spectral imaging system; Based on the scanning path information, the spectral imaging system is controlled to scan the sample to be detected according to a preset scanning path, so as to obtain a reflection spectrum image of the sample to be detected; Correction processing is performed on the reflectance spectrum image, and the average spectral reflectance of a preset area of interest is extracted from the corrected reflectance spectrum image, which specifically includes the following steps: Correcting the reflectance spectrum image to obtain a high-spectral reflectance image of a preset area of interest; Obtain reflectance spectral curves of a target area and a background area in a preset area of interest according to the spectral reflectance image, and compare the two reflectance spectral curves to obtain a first spectral wavelength with the largest difference and a second spectral wavelength with the smallest difference between the target area and the background area; Performing ratio processing on the first spectral wavelength and the second spectral wavelength, thereby obtaining a ratio image of a target area and a background area in a preset area of interest; Performing threshold segmentation on the ratio image to obtain a grayscale mask image, and performing shadow removal processing on the grayscale mask image to obtain a binary mask image; Applying the binary mask image to the reflectance spectrum image to obtain the reflectance spectrum image of the preset region of interest after masking; Obtaining an average spectral reflectance value of the preset region of interest based on the reflectance spectrum image of the preset region of interest after the mask; The heavy metal cadmium content value of each preset area of interest is determined according to the average spectral reflectance value.
2. A method for detecting heavy metal cadmium in rice according to claim 1, characterized in that: Extracting characteristic parameters of the sample to be detected from the overall image information specifically includes the following steps: Acquire image information of preset test samples through a big data network, establish a database, and import the image information of the preset test samples into the database to obtain an image information database of the preset test samples; Importing the overall image information of the sample platform area into the image information database of the preset detection sample for identification, and obtaining an identification result; Determine whether there is a preset detection sample in the sample station area according to the recognition result; If it exists, the characteristic parameters of the sample to be detected are extracted based on the overall image information.
3. The method for detecting heavy metal cadmium in rice according to claim 1, characterized in that: Generating scanning path information of the spectral imaging system based on the characteristic parameters and transmitting the scanning path information to a control terminal of the spectral imaging system specifically includes the following steps: Acquire the maximum scanning area range of the spectral imaging system during scanning, and divide the sample to be detected into a plurality of sub-scanning areas based on the maximum scanning area range; Determine the center position points of a plurality of the sub-scanning areas respectively, generate one or more scanning path information according to the center position points and the sub-scanning areas, and obtain path values of the one or more scanning paths; Establishing a size arrangement chart, importing the path values of the one or more scanning paths into the size arrangement chart, and extracting the scanning path with the minimum path value from the size arrangement chart; The scanning path of the minimum path value is transmitted to the control terminal of the spectral imaging system as the final scanning path information.
4. The method for detecting heavy metal cadmium in rice according to claim 1, characterized in that: The step before controlling the spectral imaging system to scan the sample to be detected according to the preset scanning path based on the scanning path information also includes the step of debugging the spectral imaging system: Obtaining an actual distance value between the lower surface of a CCD camera in a spectral imaging system and the upper surface of a sample to be detected, and calculating a difference between the actual distance value and a preset distance value to obtain a distance difference; Determining whether the distance difference is within a preset threshold range; If it is not located, generating first correction information to correct the position of the CCD camera; If it is located, the sample stage is controlled to move at a preset speed, and the debugging image information of each sub-scanning area is obtained through the CCD camera; Extracting contour shape information of the sample to be detected in each sub-scanning area from the debugging image information; Determine whether the contour shape information is the same as the preset contour; If they are different, second correction information is generated to correct the preset moving speed of the sample stage.
5. The method for detecting heavy metal cadmium in rice according to claim 1, characterized in that: Determining the heavy metal cadmium content value of each preset area of interest according to the average value of the spectral reflectance specifically includes the following steps: Obtain the standard heavy metal cadmium content values corresponding to different spectral reflectance averages in different areas of interest through the big data network, and establish a prediction database; Obtain the average spectral reflectance values of different preset regions of interest respectively; The average values of the spectral reflectances of the different preset regions of interest are imported into the prediction database, so as to determine the content values of the heavy metal cadmium corresponding to the different preset regions of interest.
6. A system for detecting heavy metal cadmium in rice, characterized in that: The system includes a storage device and a processor. The storage device includes a method program for detecting heavy metal cadmium in rice. When the method program for detecting heavy metal cadmium in rice is executed by the processor, the following steps are implemented: Acquire the overall image information of the sample stage area, and extract the characteristic parameters of the sample to be detected from the overall image information; generating scanning path information of the spectral imaging system based on the characteristic parameters, and transmitting the scanning path information to a control terminal of the spectral imaging system; Based on the scanning path information, the spectral imaging system is controlled to scan the sample to be detected according to a preset scanning path, so as to obtain a reflection spectrum image of the sample to be detected; Correction processing is performed on the reflectance spectrum image, and the average spectral reflectance of a preset area of interest is extracted from the corrected reflectance spectrum image, which specifically includes the following steps: Correcting the reflectance spectrum image to obtain a high-spectral reflectance image of a preset area of interest; Obtain reflectance spectral curves of a target area and a background area in a preset area of interest according to the spectral reflectance image, and compare the two reflectance spectral curves to obtain a first spectral wavelength with the largest difference and a second spectral wavelength with the smallest difference between the target area and the background area; Performing ratio processing on the first spectral wavelength and the second spectral wavelength, thereby obtaining a ratio image of a target area and a background area in a preset area of interest; Performing threshold segmentation on the ratio image to obtain a grayscale mask image, and performing shadow removal processing on the grayscale mask image to obtain a binary mask image; Applying the binary mask image to the reflectance spectrum image to obtain the reflectance spectrum image of the preset region of interest after masking; Obtaining an average spectral reflectance value of the preset region of interest based on the reflectance spectrum image of the preset region of interest after the mask; The heavy metal cadmium content value of each preset area of interest is determined according to the average spectral reflectance value.
7. A system for detecting heavy metal cadmium in rice according to claim 6, characterized in that: Extracting characteristic parameters of the sample to be detected from the overall image information specifically includes the following steps: Acquire image information of preset test samples through a big data network, establish a database, and import the image information of the preset test samples into the database to obtain an image information database of the preset test samples; Importing the overall image information of the sample platform area into the image information database of the preset detection sample for identification, and obtaining an identification result; Determine whether there is a preset detection sample in the sample station area according to the recognition result; If it exists, the characteristic parameters of the sample to be detected are extracted based on the overall image information.
8. The system for detecting heavy metal cadmium in rice according to claim 6, characterized in that: Generating scanning path information of the spectral imaging system based on the characteristic parameters and transmitting the scanning path information to a control terminal of the spectral imaging system specifically includes the following steps: Acquire the maximum scanning area range of the spectral imaging system during scanning, and divide the sample to be detected into a plurality of sub-scanning areas based on the maximum scanning area range; Determine the center position points of a plurality of the sub-scanning areas respectively, generate one or more scanning path information according to the center position points and the sub-scanning areas, and obtain path values of the one or more scanning paths; Establishing a size arrangement chart, importing the path values of the one or more scanning paths into the size arrangement chart, and extracting the scanning path with the minimum path value from the size arrangement chart; The scanning path of the minimum path value is transmitted to the control terminal of the spectral imaging system as the final scanning path information.
Citation Information
Patent Citations
Leaf cadmium content Vis-NIR spectral feature modeling method based on WT-LSSVR
CN108519339A
Visible light and terahertz fused spectrum technology-based detection device and method for heavy metal cadmium in leaves of leaf vegetables
CN108535200A