Method for improving dry land crop nutrient hyperspectral feature detection precision based on cos similarity
The spectral data are processed by cosine cos similarity to remove variability and complex information, which solves the problems of spectral variability and complexity in hyperspectral detection of dryland crop nutrients, improves detection accuracy, and provides simple and effective technical support.
Patent Information
- Application Number
- CN202410913860.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-09
- Publication Date
- 2024-10-11
AI Technical Summary
In hyperspectral detection of dryland crop nutrients, spectral information has spatial variability and complex ground information, making it difficult to improve detection accuracy.
The cosine cos similarity method is used to process spectral data. By calculating the cosine similarity within the spectral matrix, setting a threshold, removing variant spectra and classifying them, filtering out characteristic spectra, eliminating redundant ground object information, and reducing spectral variability.
It improves the accuracy of hyperspectral detection, provides a more convenient and faster technical support, effectively reduces spectral variability, and improves the accuracy of detection results.
Smart Images

Figure CN118762284A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to hyperspectral technology, and in particular to a method for improving the detection accuracy of hyperspectral features of dryland crop nutrients based on COS similarity. Background Art
[0002] At present, hyperspectral images (HSI) have a large number of spectral bands and contain rich ground object information in the spectrum, which is conducive to a more comprehensive understanding of the characteristics of different materials. By effectively describing the spectral distribution of each scene point and providing scene intrinsic and discriminative spectral information, it has been widely used in material identification, anomaly detection, medical image analysis and remote sensing. However, due to the influence of physical mechanisms and surface environment, in the actual acquisition of dryland crop nutrient hyperspectral, its spectral information is spatially variable, and the material is complexly distributed in space. Therefore, how to remove the complex ground object information in space and reduce the spectral variability is particularly important for improving the detection accuracy of hyperspectral technology.
[0003] Cosine cos similarity determines the similarity between two vectors by measuring the cosine value of the angle between them. In spectral analysis, each spectrum can be regarded as a vector in a multidimensional space, whose dimensions correspond to intensity or concentration values at different wavelengths or frequencies. The calculation of cosine similarity does not depend on the length of the vector (i.e. the intensity of the spectrum), but on their direction (i.e. the shape of the spectrum). This makes it very useful for comparing spectra with different overall intensities but similar shapes. In data analysis, data mining, and search engines, the concept of similarity is widely used to evaluate the similarity and category between individuals. In the field of spectral analysis, by calculating the cosine similarity between different spectra, spectra with highly similar features can be selected for further analysis or classification. The formula is:
[0004]
[0005] Among them A i and B i It is the component value of spectrum A and spectrum B at the i-th position. The value range of spectral cosine similarity is between [-1,1], where 1 means exactly the same, 0 means orthogonal (no correlation), and -1 means completely opposite.
[0006] When calculating the cosine similarity between 16 vectors, (C(16,2)) calculations are required, where (C(n,k)) represents the number of combinations of (k) elements taken from (n) different elements.
[0007] Summary of the invention
[0008] The main purpose of the present invention is to provide a method for improving the detection accuracy of hyperspectral features of dryland crop nutrients based on COS similarity, to process spectral data based on COS similarity, to select target spectra, thereby eliminating redundant ground object information and reducing spectral variability, to provide a more convenient, fast and effective technical support for this field, and to provide an efficient and simple processing method for improving spectral detection accuracy.
[0009] The technical solution adopted by the present invention is: a method for improving the detection accuracy of hyperspectral features of dryland crop nutrients based on cos similarity, comprising:
[0010] S1, acquisition and processing of spectral data, using airborne hyperspectral equipment to obtain hyperspectral images of farmland, and converting their DN values into reflectance through radiation correction;
[0011] S2, remove variant spectra, obtain the spectral information of each pixel in the hyperspectral image, and form a matrix of adjacent 4*4 pixels, calculate the cosine similarity of the spectra in the matrix, set the threshold to 20%, and retain the spectra with a cosine similarity of 20% as the characteristic spectra, and replace the spectra with a cosine similarity greater than 20% with the average spectrum of the retained spectrum, thereby removing the variant values in the spectrum;
[0012] S3, spectral classification, average the spectra in the matrix, and compare the cosine similarity of each matrix with its adjacent matrix, set the threshold to 50%, if the relative error between the cosine similarities is less than 50%, they are recorded as the same category of ground object spectra, otherwise they are different types of ground object spectra, so as to classify the spectral information in the hyperspectral spectrum;
[0013] S4, screening the spectra of specific objects, marking the spectral images of the specific objects, retaining the spectral information of this type according to the calculation result of step S3, and discarding the other spectra as other ground object information spectra;
[0014] S5, establishing a correlation model between the sample spectrum information and the substances measured in the sample, and detecting the substances measured in the sample.
[0015] Furthermore, the step S1 comprises:
[0016] The reflectivity is:
[0017]
[0018] Where DN represents the digital quantization value, D dark It represents the dark current, i.e. the digital quantized value when there is no light. L represents the radiation calibration coefficient, which is used to convert the DN value into the radiation brightness. sun represents the solar spectrum irradiance, θ sunIt represents the zenith angle, which is the angle of the sun relative to the vertical height of the observation point.
[0019] Furthermore, the step S2 comprises:
[0020] Define the local matrix, let M be a 4×4 pixel block matrix in a hyperspectral image, where each pixel contains the reflectance value of each band;
[0021] Calculate the spectral cosine similarity, for each pair of pixels p in the matrix M i and p j , calculate their spectral cosine similarity:
[0022]
[0023] where · represents the dot product and ||p i || and ||p j || is the modulus of the spectral vector;
[0024] Determine the threshold and characteristic spectrum, set the similarity threshold θ = 0.2, for each pixel spectrum in M, if the similarity with any other spectrum is less than or equal to θ, then retain this spectrum as the characteristic spectrum;
[0025] Replace the spectra. For spectra with similarity greater than θ, replace them with the average value of the characteristic spectra. Let S be the set of retained characteristic spectra. Then the replaced spectrum p new The is:
[0026]
[0027] Where |S| is the number of spectra in set S, and p is the number of spectra in set S.
[0028] Furthermore, the step S3 comprises:
[0029] Define the adjacent matrix and calculate the average value of the adjacent matrix. Let M i is a 4×4 hyperspectral matrix, where i is the index of the matrix. For each matrix M i , calculate the average spectrum of all pixel spectra in the matrix
[0030] Where n is the matrix M i The total number of pixels in the matrix, p is the spectral vector in the matrix;
[0031] Calculate the cosine similarity between matrices. For the adjacent matrix M i and M j , calculate the cosine similarity of their average spectra;
[0032]
[0033] Set the threshold and classify, set the similarity threshold θ = 0.5, if is greater than or equal to θ, then M i and M j They are recorded as the same type of ground object spectra, otherwise, they are regarded as different types of ground object spectra.
[0034] Furthermore, the step S4 comprises:
[0035] Spectral selection, set a screening condition or standard C to identify the spectra of a specific object, for each spectrum p i , if p i If condition C is satisfied, then p i It is considered to be the spectrum of a particular object;
[0036] Spectral labeling, the spectrum p that satisfies condition C i Marking indicates that these spectra belong to specific objects, and defining a function mark(p i ) to label these spectra:
[0037]
[0038] Among them, when p i When the condition C of a specific object is met, it is marked as 1, otherwise it is marked as 0;
[0039] Spectral information retention and elimination, according to the labeling results, the spectrum marked as 1 is retained as the spectral information of a specific object, while the spectrum marked as 0 is regarded as other ground object information and eliminated.
[0040] Advantages of the present invention:
[0041] The method of the present invention processes spectral data based on cos similarity, selects target spectra, thereby eliminating redundant ground object information and reducing spectral variability, providing a more convenient, fast and effective technical support for this field, and is an efficient and simple processing method for improving spectral detection accuracy.
[0042] In addition to the above-described purposes, features and advantages, the present invention has other purposes, features and advantages. The present invention will be further described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The drawings constituting a part of this application are used to provide a further understanding of the present invention. The illustrative embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0044] Figure 1 is a flow chart of the method of the present invention;
[0045] Figure 2 is a graph of removing outliers of the present invention;
[0046] Figure 3 It is the land feature classification map of the present invention;
[0047] Figure 4 It is a model comparison diagram of the present invention. DETAILED DESCRIPTION
[0048] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0049] refer to Figure 1 , a method for improving the detection accuracy of hyperspectral features of dryland crop nutrients based on cos similarity, comprising:
[0050] S1, acquisition and processing of spectral data, using airborne hyperspectral equipment to obtain hyperspectral images of farmland, and converting their DN values into reflectance through radiation correction;
[0051] S2, remove variant spectra, obtain the spectral information of each pixel in the hyperspectral image, and form a matrix of adjacent 4*4 pixels, calculate the cosine similarity of the spectra in the matrix, set the threshold to 20%, and retain the spectra with a cosine similarity of 20% as the characteristic spectra, and replace the spectra with a cosine similarity greater than 20% with the average spectrum of the retained spectrum, thereby removing the variant values in the spectrum;
[0052] S3, spectral classification, average the spectra in the matrix, and compare the cosine similarity of each matrix with its adjacent matrix, set the threshold to 50%, if the relative error between the cosine similarities is less than 50%, they are recorded as the same category of ground object spectra, otherwise they are different types of ground object spectra, so as to classify the spectral information in the hyperspectral spectrum;
[0053] S4, screening the spectra of specific objects, marking the spectral images of the specific objects, retaining the spectral information of this type according to the calculation result of step S3, and discarding the other spectra as other ground object information spectra;
[0054] S5, establishing a correlation model between the sample spectrum information and the substances measured in the sample, and detecting the substances measured in the sample.
[0055] The step S1 comprises:
[0056] The reflectivity is:
[0057]
[0058] Where DN represents the digital quantization value, D dark It represents the dark current, i.e. the digital quantized value when there is no light. L represents the radiation calibration coefficient, which is used to convert the DN value into the radiation brightness. sun represents the solar spectrum irradiance, θ sun It represents the zenith angle, which is the angle of the sun relative to the vertical height of the observation point.
[0059] refer to Figure 2 , the step S2 comprises:
[0060] Define the local matrix, let M be a 4×4 pixel block matrix in a hyperspectral image, where each pixel contains the reflectance value of each band;
[0061] Calculate the spectral cosine similarity, for each pair of pixels p in the matrix M i and p j , calculate their spectral cosine similarity:
[0062]
[0063] where · represents the dot product and ||p i || and ||p j || is the modulus of the spectral vector;
[0064] Determine the threshold and characteristic spectrum, set the similarity threshold θ = 0.2, for each pixel spectrum in M, if the similarity with any other spectrum is less than or equal to θ, then retain this spectrum as the characteristic spectrum;
[0065] Replace the spectra. For spectra with similarity greater than θ, replace them with the average value of the characteristic spectra. Let S be the set of retained characteristic spectra. Then the replaced spectrum p new The is:
[0066]
[0067] Where |S| is the number of spectra in set S, and p is the number of spectra in set S.
[0068] refer to Figure 3 , the step S3 comprises:
[0069] Define the adjacent matrix and calculate the average value of the adjacent matrix. Let M i is a 4×4 hyperspectral matrix, where i is the index of the matrix. For each matrix M i , calculate the average spectrum of all pixel spectra in the matrix
[0070] Where n is the matrix Mi The total number of pixels in the matrix, p is the spectral vector in the matrix;
[0071] Calculate the cosine similarity between matrices. For the adjacent matrix M i and M j , calculate the cosine similarity of their average spectra;
[0072]
[0073] Set the threshold and classify, set the similarity threshold θ = 0.5, if is greater than or equal to θ, then M i and M j They are recorded as the same type of ground object spectra, otherwise, they are regarded as different types of ground object spectra.
[0074] The step S4 comprises:
[0075] Spectral selection, set a screening condition or standard C to identify the spectra of a specific object, for each spectrum p i , if p i If condition C is satisfied, then p i It is considered to be the spectrum of a particular object;
[0076] Spectral labeling, the spectrum p that satisfies condition C i Marking indicates that these spectra belong to specific objects, and defining a function mark(p i ) to label these spectra:
[0077]
[0078] Among them, when p i When the condition C of a specific object is met, it is marked as 1, otherwise it is marked as 0;
[0079] Spectral information retention and elimination, according to the labeling results, the spectrum marked as 1 is retained as the spectral information of a specific object, while the spectrum marked as 0 is regarded as other ground object information and eliminated.
[0080] refer to Figure 4 By comparing the PLS and ANN models, the results show that after screening by cos similarity, the RMSE in both PLS and ANN models is improved by 0.009, indicating that cos similarity can effectively reduce the impact of the environment and its instruments and improve the detection accuracy of the model.
[0081] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for improving the detection accuracy of hyperspectral features of dryland crop nutrients based on cos similarity, characterized in that: include: S1, acquisition and processing of spectral data, using airborne hyperspectral equipment to obtain hyperspectral images of farmland, and converting their DN values into reflectance through radiation correction; S2, remove variant spectra, obtain the spectral information of each pixel in the hyperspectral image, and form a matrix of adjacent 4*4 pixels, calculate the cosine similarity of the spectra in the matrix, set the threshold to 20%, and retain the spectra with a cosine similarity of 20% as the characteristic spectra, and replace the spectra with a cosine similarity greater than 20% with the average spectrum of the retained spectrum, thereby removing the variant values in the spectrum; S3, spectral classification, average the spectra in the matrix, and compare the cosine similarity of each matrix with its adjacent matrix, set the threshold to 50%, if the relative error between the cosine similarities is less than 50%, they are recorded as the same category of ground object spectra, otherwise they are different types of ground object spectra, so as to classify the spectral information in the hyperspectral spectrum; S4, screening the spectra of specific objects, marking the spectral images of the specific objects, retaining the spectral information of this type according to the calculation result of step S3, and discarding the other spectra as other ground object information spectra; S5, establishing a correlation model between the sample spectrum information and the substances measured in the sample, and detecting the substances measured in the sample.
2. The method for improving the detection accuracy of hyperspectral features of dryland crop nutrients based on cos similarity according to claim 1, characterized in that: The step S1 comprises: The reflectivity is: Where DN represents the digital quantization value, D dark It represents the dark current, i.e. the digital quantized value when there is no light. L represents the radiation calibration coefficient, which is used to convert the DN value into the radiation brightness. sun represents the solar spectrum irradiance, θ sun It represents the zenith angle, which is the angle of the sun relative to the vertical height of the observation point.
3. The method for improving the detection accuracy of hyperspectral features of dryland crop nutrients based on cos similarity according to claim 1, characterized in that: The step S2 comprises: Define the local matrix, let M be a 4×4 pixel block matrix in a hyperspectral image, where each pixel contains the reflectance value of each band; Calculate the spectral cosine similarity, for each pair of pixels p in the matrix M i and p j , calculate their spectral cosine similarity: where · represents the dot product and ||p i || and ||p j || is the modulus of the spectral vector; Determine the threshold and characteristic spectrum, set the similarity threshold θ = 0.2, for each pixel spectrum in M, if the similarity with any other spectrum is less than or equal to θ, then retain this spectrum as the characteristic spectrum; Replace the spectra. For spectra with similarity greater than θ, replace them with the average value of the characteristic spectra. Let S be the set of retained characteristic spectra. Then the replaced spectrum p new The is: Where |S| is the number of spectra in set S, and p is the number of spectra in set S.
4. The method for improving the detection accuracy of hyperspectral features of dryland crop nutrients based on cos similarity according to claim 1, characterized in that: The step S3 comprises: Define the adjacent matrix and calculate the average value of the adjacent matrix. Let M i is a 4×4 hyperspectral matrix, where i is the index of the matrix. For each matrix M i , calculate the average spectrum of all pixel spectra in the matrix Where n is the matrix M i The total number of pixels in the matrix, p is the spectral vector in the matrix; Calculate the cosine similarity between matrices. For the adjacent matrix M i and M j , calculate the cosine similarity of their average spectra; Set the threshold and classify, set the similarity threshold θ = 0.5, if is greater than or equal to θ, then M i and M j They are recorded as the same type of ground object spectra, otherwise, they are regarded as different types of ground object spectra.
5. The method for improving the detection accuracy of hyperspectral features of dryland crop nutrients based on cos similarity according to claim 1, characterized in that: The step S4 comprises: Spectral selection, set a screening condition or standard C to identify the spectra of a specific object, for each spectrum p i , if p i If condition C is satisfied, then p i It is considered to be the spectrum of a particular object; Spectral labeling, the spectrum p that satisfies condition C i Marking indicates that these spectra belong to specific objects, and defining a function mark(p i ) to label these spectra: Among them, when p i When the condition C of a specific object is met, it is marked as 1, otherwise it is marked as 0; Spectral information retention and elimination, according to the labeling results, the spectrum marked as 1 is retained as the spectral information of a specific object, while the spectrum marked as 0 is regarded as other ground object information and eliminated.
Citation Information
Cited By
Method and equipment for predicting storage quality of chilled fresh pork based on visible spectrum reconstruction
CN121678557A
