Automatic plant leaf recognition method and system based on hyperspectral images
By selecting the optimal three-wavelength combination and spectral angle judgment in hyperspectral images and combining them with the OTSU method to segment hyperspectral images, the problem of low recognition accuracy caused by background interference is solved, and efficient plant leaf target segmentation is achieved.
Patent Information
- Application Number
- CN202311103163.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-30
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2043-08-30
AI Technical Summary
The existing OTSU method is affected by the interference background when identifying ginseng leaf hyperspectral images, resulting in unclear separation of target and background and low recognition accuracy.
By calculating the average spectral information and shape information of the hyperspectral image, the optimal three-wavelength combination is selected to form the grayscale image with the highest contrast. The OTSU method is used for threshold segmentation. The target and background are judged by combining the spectral angle. The image is further divided into blocks and the optimal wavelength combination is selected for threshold segmentation.
The accuracy of ginseng leaf target recognition is improved, background interference close to the leaves is eliminated, and efficient target segmentation is achieved.
Smart Images

Figure CN117274796B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of hyperspectral image processing, and in particular to a method and system for automatically identifying plant leaves based on hyperspectral images. Background Art
[0002] Hyperspectral image data, characterized by its "unified image and spectrum," rapidity, and non-invasiveness, is often used in material analysis. However, in addition to containing the target, hyperspectral image data also contains a significant amount of interfering background that can affect data analysis. Therefore, when using hyperspectral imaging technology for material analysis, the target must be identified first to facilitate subsequent target extraction and data processing.
[0003] Ginseng is an important traditional Chinese medicine. Chlorophyll content and leaf area index (LAI) in ginseng leaves can reflect the plant's growth status. Hyperspectral imaging technology can rapidly and non-destructively detect chlorophyll and LAI in ginseng leaves. However, hyperspectral image data of ginseng leaves collected using a hyperspectral imager is subject to significant background interference. Therefore, data analysis requires identifying ginseng leaves from the hyperspectral image data to facilitate subsequent extraction and further data processing, improving analysis efficiency.
[0004] The OTSU method is a commonly used target recognition method and is the best approach for determining the global threshold of an image. It is suitable for most applications requiring this. The existing OTSU method divides an image into two components, background and target, based on its grayscale characteristics and selects an appropriate threshold for target recognition. However, when there is significant grayscale overlap between the target and background in an image, the method cannot accurately separate the two components, resulting in low recognition accuracy. Summary of the Invention
[0005] In order to solve the above problems, the present invention provides a method and system for automatic plant leaf recognition based on hyperspectral images.
[0006] The first object of the present invention is to provide a method for automatically identifying plant leaves based on hyperspectral images, comprising the following steps:
[0007] S1, select a plant leaf hyperspectral image data, and calculate the average spectral information X1 of the hyperspectral image data;
[0008] S2, read in the hyperspectral image data of plant leaves and obtain the shape information of the hyperspectral image data of the leaves; select the optimal three-wavelength combination in the hyperspectral image data of plant leaves to form the grayscale image I with the highest contrast, and perform threshold segmentation processing using the OTSU method to obtain a binary image consisting of the target object and the background;
[0009] S3, determine the target and background based on the average spectral information X1 and the binary image, and obtain the preliminary target recognition result diagram Q1;
[0010] S4, respectively obtain the pixel coordinates of the first target object in the width direction and the last target object in the length direction in the preliminary target recognition result image Q1 to obtain the area to be recognized Q2;
[0011] S5, dividing the area to be identified Q2 into M×N image blocks, and performing threshold segmentation on each small image block again using the OTSU method to obtain the identified small image block;
[0012] S6. Combine all recognized small image blocks in the original order to obtain a recognized image.
[0013] Preferably, the method for determining the target object and the background in step S3 includes: calculating the spectral angles of the spectra corresponding to the average spectral information X1 in step S1 and the two threshold images in the binarized image obtained in step S2, wherein the one with the smallest spectral angle is set as the target object, and the remaining categories are set as the background; the spectral angle formula is as follows:
[0014]
[0015] Where: X* represents the unknown spectrum; X1 represents the average spectral curve of the plant leaves obtained in step S1, that is, the spectral curve of the target object; θ is the spectral angle. The smaller the spectral angle, the more similar the spectra are. That is, the threshold image with the smallest spectral angle with X1 is the target, and the remaining threshold images are the background; T represents the vector transpose.
[0016] Preferably, the shape information in step S2 includes Width, Length, and Bands.
[0017] Preferably, the calculation formula of the contrast in step S2 is as follows:
[0018]
[0019] Where C represents the contrast of the image block, δ(i, j) = |ij| represents the grayscale difference between adjacent pixels, and P δ (i, j) represents the pixel distribution probability when the grayscale difference between adjacent pixels is δ.
[0020] Preferably, the pixel coordinates of the first target object in the width direction of the Q1 image in step S4 are (x firstw ,y firstw ), the last target pixel coordinate is (x endw ,y endw ), the pixel coordinates of the first target object in the length direction are (x firstl ,y firstl), the last target pixel coordinate is (x endl ,y endl ); the coordinates of the area to be identified Q2 are (x firstw :x endw ,y firstl :y endl , Bands).
[0021] Preferably, the values of M and N in step S5 are determined by Q2; the width and length of each small image block are Δx and Δy respectively, and the formula is as follows:
[0022] Δx=(x endw -x firstw ) / m; Δy=(y endl -y firstl ) / n;
[0023] Where m and n are integers from 1 to 10, which are determined by learning the first plant leaf hyperspectral image data, that is, the value of m when the plant leaf recognition effect is best when the first data is acquired, and Δx and Δy are both integers.
[0024] Preferably, the first small image block area to be analyzed in step S5 is (x firstw :x firstw +Δx,y firstl :y firstl +Δy, Bands), if the area (x firstw :x firstw +Δx,y firstl :y firstl +Δy) contains only background, then this image block is set as background and the next small image block is analyzed; if there is both background and target, or only target, the optimal three-wavelength combination is selected to convert this small image block into a grayscale image I1.
[0025] Preferably, the plant is ginseng.
[0026] The first object of the present invention is to provide a plant leaf automatic recognition system based on hyperspectral images, which is used to execute the plant leaf automatic recognition method based on hyperspectral images, comprising:
[0027] Data acquisition module, used to obtain hyperspectral image data of plant leaves;
[0028] The data processing module is used to preprocess the plant leaf hyperspectral image data to obtain the optimal three-wavelength combination to form the grayscale image with the highest contrast, and perform threshold segmentation processing using the OTSU method to obtain a binary image consisting of the target object and the background;
[0029] The data analysis module is used to extract the target and background in the binary image to obtain the recognition result image, further segment the recognition result image into small image blocks, and then perform threshold segmentation processing on the small image blocks according to the OTSU method;
[0030] The image output module is used to combine the analyzed small image blocks in the original order to output the recognized image.
[0031] Compared with the prior art, the present invention can achieve the following beneficial effects:
[0032] The present invention introduces spectral information into the process of plant leaf recognition, searches for a suitable wavelength combination to form a grayscale image with the highest contrast, uses the OTSU method to separate the plant leaves from the background close to the leaves, completes preliminary target recognition, divides the image into blocks, selects the most suitable wavelength combination for each block to maximize the contrast, performs threshold segmentation, eliminates the background close to the plant leaves in the hyperspectral image data, completes leaf target recognition, and solves the problem of low target recognition accuracy of the OTSU method due to the presence of background close to the plant leaves. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 This is a flow chart of a method for automatically identifying plant leaves based on hyperspectral images according to an embodiment of the present invention. DETAILED DESCRIPTION
[0034] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. In the following description, identical modules are denoted by identical reference numerals. In the case of identical reference numerals, their names and functions are also identical. Therefore, their detailed description will not be repeated.
[0035] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and do not constitute a limitation of the present invention.
[0036] The present invention provides a method for automatically identifying plant leaves based on hyperspectral images, comprising the following steps:
[0037] S1, manually select a plant leaf hyperspectral image data, calculate the average spectral information of the hyperspectral image data (i.e., the spectral curve of the target object), and record it as X1;
[0038] S2. Read in the hyperspectral image data of plant leaves and obtain the shape of the hyperspectral image data, namely, Width, Length, and Bands. Select the optimal three-wavelength combination in the hyperspectral image data of plant leaves to form the grayscale image I with the highest contrast. Use the OTSU method to perform threshold segmentation processing to obtain a binary image consisting of the target object and the background. The contrast is calculated as follows:
[0039]
[0040] Where C represents the contrast of the image block, δ(i, j) = |ij| represents the grayscale difference between adjacent pixels, and P δ (i, j) represents the pixel distribution probability when the grayscale difference between adjacent pixels is δ;
[0041] S3, calculate the spectral angles of the spectra corresponding to the average spectral information X1 in step S1 and the two threshold images in the binarized image obtained in step S2, wherein the one with the smallest spectral angle is set as the target object, and the remaining categories are set as the background, to obtain the preliminary target recognition result diagram Q1; the spectral angle formula is as follows:
[0042]
[0043] Where: X * represents the unknown spectrum; X1 represents the average spectral curve of the plant leaves obtained in step S1, that is, the spectral curve of the target object; θ is the spectral angle. The smaller the spectral angle, the more similar the spectra are. That is, the threshold image with the smallest spectral angle to X1 is the target, and the remaining threshold images are the background; T represents the vector transpose;
[0044] S4, obtain the pixel coordinates (x firstw ,y firstw ) and the last target pixel coordinate (x endw ,y endw ), and the pixel coordinates of the first target object in the length direction (x firstl ,y firstl ) and the last target pixel coordinate (x endl ,y endl ), and get the area to be identified Q2(x firstw :x endw ,y firstl :y endl , Bands);
[0045] S5. Divide the area to be identified Q2 into M×N image blocks, where the values of M and N are determined by Q2; the width and length of each small image block are Δx and Δy respectively, and the formula is as follows:
[0046] Δx=(xendw -x firstw ) / m; Δy=(y endl -y firstl ) / n;
[0047] Where m and n are integers from 1 to 10, determined by learning from the first plant leaf hyperspectral image data. That is, the value of m when the plant leaf recognition effect is best in the first data. The value of N is the value of this algorithm. Δx and Δy are both integers (if the result is 3.23, then 3 is used. If the remaining pixel value is less than one Δx or Δy, such as 2, then 2 is used).
[0048] The first image block to be analyzed is (x firstw :x firstw +Δx,y firstl :y firstl +Δy, Bands), if in the area corresponding to Q1 (x firstw :x firstw +Δx,y firstl :y firstl +Δy) contains only background, this image block is set as background, and the next image block is analyzed. If it contains both background and target, or only target, the optimal three-wavelength combination is selected to convert this image block into a grayscale image I1, at which the contrast is the highest. The OTSU method is used again to perform threshold segmentation on I1, and the spectral angle of the corresponding spectrum of X1 and the two images after threshold segmentation is calculated. The one with the smallest spectral angle is set as the target, and the remaining categories are set as background to obtain the recognized image I'1, and the next image block is analyzed.
[0049] S6. After analyzing each small image block (M×N image blocks), the identified image blocks I'1 to I' M×N Combine them in the original order to obtain the recognized image I'.
[0050] The present invention also provides a plant leaf automatic recognition system based on hyperspectral images, which is used to perform the above-mentioned recognition method, comprising:
[0051] Data acquisition module, used to obtain hyperspectral image data of plant leaves;
[0052] The data processing module is used to preprocess the plant leaf hyperspectral image data to obtain the optimal three-wavelength combination to form the grayscale image with the highest contrast, and perform threshold segmentation processing using the OTSU method to obtain a binary image consisting of the target object and the background;
[0053] The data analysis module is used to extract the target and background in the binary image to obtain the recognition result image, further segment the recognition result image into small image blocks, and then perform threshold segmentation processing on the small image blocks according to the OTSU method;
[0054] The image output module is used to combine the analyzed small image blocks in the original order to output the recognized image.
[0055] Example 1
[0056] This embodiment takes ginseng leaves as an example and provides a method for automatically identifying ginseng leaves based on hyperspectral images, including the following steps:
[0057] S1, manually select a ginseng leaf hyperspectral image data, calculate the average spectral information of the hyperspectral image data, and record it as X1;
[0058] S2. Read the ginseng leaf hyperspectral image data and obtain the shape Width, Length, and Bands of the ginseng leaf hyperspectral image data. Select the optimal three-wavelength combination in the ginseng leaf hyperspectral image data to form the grayscale image I with the highest contrast. Use the OTSU method to perform threshold segmentation processing to obtain a binary image consisting of the target object and the background. The contrast is calculated as follows:
[0059]
[0060] Where C represents the contrast of the image block, δ(i, j) = |ij| represents the grayscale difference between adjacent pixels, and P δ (i, j) represents the pixel distribution probability when the grayscale difference between adjacent pixels is δ;
[0061] S3, calculate the spectral angles of the spectra corresponding to the average spectral information X1 in step S1 and the two threshold images in the binarized image obtained in step S2, wherein the one with the smallest spectral angle is set as the target object, and the remaining categories are set as the background, to obtain the preliminary target recognition result diagram Q1; the spectral angle formula is as follows:
[0062]
[0063] Where: X * represents the unknown spectrum; X1 represents the average spectral curve of ginseng leaves obtained in step S1, i.e., the spectral curve of the target object; θ is the spectral angle. The smaller the spectral angle, the more similar the spectra are. That is, the threshold image with the smallest spectral angle to X1 is the target, and the remaining threshold images are the background; T represents vector transposition;
[0064] S4, obtain the pixel coordinates (x firstw ,y firstw ) and the last target pixel coordinate (x endw ,y endw ), and the pixel coordinates of the first target object in the length direction (x firstl ,y firstl) and the last target pixel coordinate (x endl ,y endl ), and get the area to be identified Q2(x firstw :x endw ,y firstl :y endl , Bands);
[0065] S5. Divide the area to be identified Q2 into M×N image blocks, where the values of M and N are determined by Q2; the width and length of each small image block are Δx and Δy respectively, and the formula is as follows:
[0066] Δx=(x endw -x firstw ) / m; Δy=(y endl -y firstl ) / n;
[0067] Where m and n are integers from 1 to 10, determined by learning from the first ginseng leaf hyperspectral image data. That is, the value of m when the ginseng leaf recognition effect is best in the first data set, and the value of N is the value of this algorithm. Δx and Δy are both integers (if the result is 3.23, then 3 is used; if the remaining pixel value is less than one Δx or Δy, such as 2, then 2 is used);
[0068] The first image block to be analyzed is (x firstw :x firstw +Δx,y firstl :y firstl +Δy, Bands), if in the area corresponding to Q1 (x firstw :x firstw +Δx,y firstl :y firstl +Δy) contains only background, this image block is set as background, and the next image block is analyzed. If it contains both background and target, or only target, the optimal three-wavelength combination is selected to convert this image block into a grayscale image I1, at which the contrast is the highest. The OTSU method is used again to perform threshold segmentation on I1, and the spectral angle of the corresponding spectrum of X1 and the two images after threshold segmentation is calculated. The one with the smallest spectral angle is set as the target, and the remaining categories are set as background to obtain the recognized image I'1, and the next image block is analyzed.
[0069] S6. After analyzing each small image block (M×N image blocks), the identified image blocks I'1 to I' M×N Combining them in the original order, the recognized ginseng leaf image I' is obtained.
[0070] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in the present disclosure can be achieved. This is not limited herein.
[0071] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.
Claims
1. A method for automatic plant leaf recognition based on hyperspectral images, characterized in that: The steps include: S1, select a plant leaf hyperspectral image data, and calculate the average spectral information X1 of the hyperspectral image data; S2, read in the hyperspectral image data of plant leaves and obtain the shape information of the hyperspectral image data of the leaves; select the optimal three-wavelength combination in the hyperspectral image data of plant leaves to form the grayscale image I with the highest contrast, and perform threshold segmentation processing using the OTSU method to obtain a binary image consisting of the target object and the background; S3, determine the target and background based on the average spectral information X1 and the binary image, and obtain the preliminary target recognition result diagram Q1; S4, respectively obtain the pixel coordinates of the first target object in the width direction and the last target object in the length direction in the preliminary target recognition result image Q1 to obtain the area to be recognized Q2; S5, dividing the area to be identified Q2 into M×N image blocks, and performing threshold segmentation on each small image block again using the OTSU method to obtain the identified small image block; S6. Combine all recognized small image blocks in the original order to obtain a recognized image.
2. The method for automatic plant leaf recognition based on hyperspectral images according to claim 1, characterized in that: The method for determining the target and background in step S3 includes: calculating the spectral angles of the spectra corresponding to the average spectral information X1 in step S1 and the two threshold images in the binarized image obtained in step S2, wherein the one with the smallest spectral angle is set as the target, and the remaining categories are set as the background; the spectral angle formula is as follows: Where: X* represents the unknown spectrum; X1 represents the average spectral curve of the plant leaves obtained in step S1, that is, the spectral curve of the target object; θ is the spectral angle. The smaller the spectral angle, the more similar the spectra are. That is, the threshold image with the smallest spectral angle with X1 is the target, and the remaining threshold images are the background; T represents the vector transpose.
3. The method for automatic plant leaf recognition based on hyperspectral images according to claim 2, characterized in that: The shape information in step S2 includes Width, Length, and Bands.
4. The method for automatic plant leaf recognition based on hyperspectral images according to claim 3, characterized in that: The calculation formula of the contrast in step S2 is as follows: Where C represents the contrast of the image block, δ(i, j) = |ij| represents the grayscale difference between adjacent pixels, and P δ (i, j) represents the pixel distribution probability when the grayscale difference between adjacent pixels is δ.
5. The method for automatic plant leaf recognition based on hyperspectral images according to any one of claims 1 to 4, characterized in that: The pixel coordinates of the first target object in the width direction of the Q1 image in step S4 are (x firstw ,y firstw ), the last target pixel coordinate is (x endw , Y endw ), the pixel coordinates of the first target object in the length direction are (x firstl ,y firstl ), the last target pixel coordinate is (x endl , Y endl ); the coordinates of the area to be identified Q2 are (x firstw :x endw ,y firstl :Y endl , Bands).
6. The method for automatic plant leaf recognition based on hyperspectral images according to claim 5, characterized in that: The values of M and N in step S5 are determined by Q2; the width and length of each small image block are Δx and Δy respectively, and the formula is as follows: Δx=(x endw -x firstw ) / m;Δy=(y endl -Y firstl ) / n; Where m and n are integers from 1 to 10, determined by learning the first plant leaf hyperspectral image data, that is, the example values when the plant leaf recognition effect of the first data is the best, and Δx and Δy are both integers.
7. The method for automatic plant leaf recognition based on hyperspectral images according to claim 6, characterized in that: The first small image block area to be analyzed in step S5 is (x firstw :x firstw +Δx,Y firstl :Y firstl +Δy, Bands), if the area (x firstw :x firstw +Δx,y firstl :Y firstl +Δy) contains only background, then this image block is set as background and the next small image block is analyzed; if there is both background and target, or only target, the optimal three-wavelength combination is selected to convert this small image block into a grayscale image I1.
8. The method for automatic plant leaf recognition based on hyperspectral images according to claim 7, characterized in that: The plant is ginseng.
9. The plant leaf automatic recognition system based on hyperspectral images is characterized by: The method for automatically identifying plant leaves based on hyperspectral images according to claim 1 comprises: Data acquisition module, used to obtain hyperspectral image data of plant leaves; The data processing module is used to preprocess the plant leaf hyperspectral image data to obtain the optimal three-wavelength combination to form the grayscale image with the highest contrast, and perform threshold segmentation processing using the OTSU method to obtain a binary image consisting of the target object and the background; The data analysis module is used to extract the target and background in the binary image to obtain the recognition result image, further segment the recognition result image into small image blocks, and then perform threshold segmentation processing on the small image blocks according to the OTSU method; The image output module is used to combine the analyzed small image blocks in the original order to output the recognized image.
Citation Information
Patent Citations
Fusarium graminearum diagnosis method based on hyperspectral imaging
CN107527326A
Hyperspectral image-based tea origin identification method and system
CN112699756A