Foreign matter recognition method and device based on spectral feature selection, equipment and medium

By using a spectral feature selection method, risk spectral vectors are screened and feature matching is performed using the transformation matrix of the main dimension and the first dimension. This solves the problem of indistinct feature extraction in hyperspectral foreign object identification and improves identification accuracy and efficiency.

CN121564560BActive Publication Date: 2026-04-10INSPECTION & QUARANTINE TECH CENT SHANDONG ENTRY EXIT INSPECTION & QUARANTINE BUREAU +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-01-26
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

In existing hyperspectral foreign object identification technologies, feature extraction methods fail to effectively distinguish foreign objects from the background, resulting in low identification efficiency and requiring a large amount of manpower and equipment resources.

Method used

A method based on spectral feature selection is adopted. Risk spectral vectors are selected by transforming the main dimension and the first dimension, and spectral characteristics are matched. Finally, the image contour is extracted for foreign object identification.

Benefits of technology

It improves the accuracy and efficiency of foreign object identification, reduces the difficulty of modeling and applying the identification model, and achieves more accurate identification of foreign object types.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121564560B_ABST
    Figure CN121564560B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of foreign matter identification based on hyperspectrum, and particularly relates to a foreign matter identification method and device based on spectral feature selection, equipment and medium. The method of the present application first acquires a main dimension conversion matrix and a plurality of first dimension conversion matrices. Then, for each first spectral vector in a first spectral vector set, the main dimension conversion matrix is used for conversion, and a plurality of first risk spectral vectors are selected from the first spectral vector set according to the conversion result. Next, for each first risk spectral vector, the plurality of first dimension conversion matrices are used for conversion, and spectral characteristics are matched according to the conversion result. Finally, a first image contour is extracted from the target image according to the spectral characteristics, and the first image contour is input into an identification model for foreign matter identification. The present application has good pretreatment effect, and improves the identification efficiency and accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of hyperspectral-based foreign matter identification, and in particular to a foreign matter identification method and device based on spectral feature selection, equipment and a medium. BACKGROUND

[0002] Hyperspectral foreign matter identification technology is a precise detection scheme based on the development of hyperspectral imaging (HSI) technology, and the core is to identify trace, hidden or morphologically similar foreign matters from complex backgrounds by using the "spectral fingerprint" characteristics of substances (there are unique differences in the absorption / reflection / transmission characteristics of different substances to different wavelengths of light). This technology combines the "spatial positioning ability of image dimension" and the "substance identification ability of spectral dimension", and has been widely used in food detection, industrial quality inspection, environmental monitoring, security and other fields.

[0003] The complete process of hyperspectral foreign matter identification is: data acquisition → preprocessing → feature extraction → pattern recognition → result output, and "feature extraction" and "pattern recognition" are the key steps:

[0004] This is because the dimension of hyperspectral data is extremely high (hundreds of bands), and feature extraction is needed to reduce redundancy and retain the core differences between foreign matters and backgrounds. The current mainstream technologies include:

[0005] Principal Component Analysis (PCA): Project high-dimensional spectral data into a low-dimensional space, the first principal component retains the main information, and subsequent principal components often contain the differences between foreign matters and backgrounds (such as spectral abnormalities of foreign matters in food).

[0006] Locally Weighted Divergence Difference (LWDD): Highlight the foreign matter characteristics of specific bands, suitable for scenarios where the spectral differences between foreign matters and backgrounds are small (such as plastic foreign matters and food raw materials).

[0007] In the current technology, feature extraction is mainly used to retain the main data components, remove data redundancy, and reduce the difficulty of foreign matter identification. The identification of foreign matters is still mainly achieved by subsequent identification algorithms (such as artificial intelligence algorithms). That is, the current technology only converts the data dimension while retaining the features and reducing the data volume, and does not further analyze and process the information that the features may contain, thereby bringing certain difficulties to foreign matter identification.

[0008] The feature extraction method generally has the problems of wide feature processing and non-obvious features, and therefore, after extracting the features, further identification is needed to distinguish the foreign matters. In this way, the difficulty of identifying the foreign matters is increased, and the modeling process and the computing power need to consume more human and equipment resources.

[0009] Therefore, it is necessary to develop a foreign matter identification method based on spectral feature selection. SUMMARY

[0010] The embodiment of the present application provides a foreign matter identification method, device, equipment and medium based on spectral feature selection, which is used to solve the problem of low foreign matter identification efficiency caused by the fact that the hyperspectral preprocessing in the prior art does not perform feature distinction.

[0011] In a first aspect, the embodiment of the present application provides a foreign matter identification method based on spectral feature selection, comprising:

[0012] obtaining a main dimension conversion matrix and a plurality of first dimension conversion matrices, wherein the main dimension conversion matrix and the first dimension conversion matrix are respectively constructed according to spectral characteristics of objects;

[0013] for each first spectral vector in the first spectral vector set, respectively converting according to the main dimension conversion matrix, and screening a plurality of first risk spectral vectors from the first spectral vector set according to the conversion result, wherein the conversion result of the first risk spectral vector deviates from the vector before conversion by more than a deviation threshold, and each first spectral vector corresponds to a pixel of a target image;

[0014] for each first risk spectral vector, converting through the plurality of first dimension conversion matrices, and performing spectral characteristic matching according to the conversion result;

[0015] extracting a first image contour from the target image according to the spectral characteristics, and inputting the first image contour into an identification model to identify the foreign matter.

[0016] In a possible implementation manner, the main dimension conversion matrix and the first dimension conversion matrix are constructed according to a plurality of second spectral vectors, comprising:

[0017] for each matrix in the main dimension conversion matrix and the first dimension conversion matrix, the matrix is respectively constructed through the following steps:

[0018] obtaining a plurality of second dimension conversion matrices and a plurality of second spectral vectors, wherein each second spectral vector corresponds to a spectral label identifying the spectral characteristics of an object;

[0019] For each second-dimensional transformation matrix, the multiple second-spectral vectors are transformed using the second-dimensional transformation matrix respectively, and the fitness index is determined based on the multiple third-spectral vectors obtained, the multiple second-spectral vectors, and the spectral label of each vector;

[0020] If the number of iterations is reached, the second-dimensional transformation matrix with the largest fitness index is used as the main-dimensional transformation matrix or the first-dimensional transformation matrix, and the deviation threshold is determined based on the largest fitness index.

[0021] Otherwise, the fitness index is adjusted for each second-dimensional transformation matrix according to multiple fitness indices, and the process jumps to the step of transforming the multiple second-dimensional spectral vectors using the second-dimensional transformation matrix for each second-dimensional transformation matrix, and determining the fitness index based on the obtained multiple third-dimensional spectral vectors, the multiple second-dimensional spectral vectors, and the spectral label of each vector.

[0022] In one possible implementation, the transformation of the plurality of second spectral vectors using a second-dimensional transformation matrix, and the determination of the fitness index based on the obtained plurality of third spectral vectors, the plurality of second spectral vectors, and the spectral label of each vector, includes:

[0023] According to the first formula, each second spectral vector is transformed using the second-dimensional transformation matrix to obtain the third spectral vector, where the first formula is:

[0024]

[0025] In the formula, The third spectral vector, The second spectral vector, This is the second-dimensional transformation matrix. For the second dimension transformation matrix Line number Column elements, This represents the total number of elements in the second spectral vector;

[0026] The fitness index is determined based on the second formula, the obtained multiple third spectral vectors, the multiple second spectral vectors, and the spectral label of each vector, wherein the second formula is:

[0027]

[0028] In the formula, For fitness index, The total number of second spectral vectors. For label judgment value, This is the label extraction function for vectors. The spectral label of the second dimension conversion matrix.

[0029] In a possible implementation, the adjusting of each second dimension conversion matrix according to the plurality of fitness indexes comprises:

[0030] obtaining a plurality of fitness queues, wherein each fitness queue corresponds to a second dimension conversion matrix;

[0031] adding each fitness index into a fitness queue of the corresponding second dimension conversion matrix;

[0032] extracting a fitness index with the maximum value from each fitness queue as a first target fitness, and extracting a historical second dimension conversion matrix corresponding to the first target fitness as a first target conversion matrix;

[0033] extracting a maximum value in the plurality of fitness indexes as a second target fitness, and extracting a second dimension conversion matrix corresponding to the second target fitness as a second target conversion matrix;

[0034] for each second dimension conversion matrix, adjusting according to a third formula, the second target conversion matrix, and the corresponding first target conversion matrix, wherein the third formula is:

[0035]

[0036] wherein, is an element of the adjusted second dimension conversion matrix in the i th row and the j th column, is an element of the second dimension conversion matrix before adjustment in the i th row and the j th column, is the first adjustment coefficient, is an element of the first target conversion matrix in the i th row and the j th column, is the second adjustment coefficient, is an element of the second target conversion matrix in the i th row and the j th column. In a possible implementation, the adjusting of each second dimension conversion matrix according to the plurality of fitness indexes comprises: for each first spectral vector in the first spectral vector set, performing the following steps respectively: for each first spectral vector, performing the following steps respectively:

[0037]

[0038] for each first spectral vector in the first spectral vector set, performing the following steps respectively:

[0039] ​​​​​​The first spectrum vector is converted according to a fourth formula, and a deviation degree is obtained according to a conversion result, wherein the fourth formula is:

[0040]

[0041] In the formula, is a converted vector, is the first spectrum vector, is a main dimension conversion matrix, is the deviation degree;

[0042] If the deviation degree is greater than the deviation threshold, the first spectrum vector is taken as a first risk spectrum vector.

[0043] In a possible implementation manner, each first risk spectrum vector corresponds to a spectrum label representing a spectrum characteristic of an object, and for each first risk spectrum vector, spectrum characteristic matching is performed by conversion through the plurality of first dimension conversion matrices and according to a conversion result, including:

[0044] For each first risk spectrum vector, the following steps are respectively performed:

[0045] The plurality of first risk spectrum vectors are respectively converted by using the plurality of first dimension conversion matrices to obtain a plurality of fourth spectrum vectors;

[0046] For each fourth spectrum vector, a deviation degree is respectively calculated with the first risk spectrum vector;

[0047] A fourth spectrum vector with a deviation degree less than a deviation degree threshold is taken as a target spectrum vector;

[0048] A spectrum label corresponding to a first dimension conversion matrix of the target spectrum vector is taken as a spectrum label of a pixel corresponding to the first risk spectrum vector.

[0049] In a possible implementation manner, the risk pixels in the target image are identified with spectrum labels, the first image contour is extracted from the target image according to the spectrum characteristic, and the first image contour is input into the identification model to perform foreign matter identification, including:

[0050] For each spectrum label, the following steps are performed:

[0051] Pixels identified with the spectrum label are extracted from the target image;

[0052] The extracted pixels are constructed as a first image block, and a contour of the first image block is extracted as a first image contour;

[0053] The first image contour is input into the identification model constructed according to the artificial neural network model to perform identification;

[0054] determine the foreign matter category according to the output of the identification model.

[0055] In a second aspect, the embodiments of the present application provide a foreign matter identification device based on spectral feature selection, which is configured to implement the method for foreign matter identification based on spectral feature selection according to the first aspect or any possible implementation manner of the first aspect. The foreign matter identification device based on spectral feature selection comprises:

[0056] a conversion matrix obtaining module configured to obtain a main dimension conversion matrix and a plurality of first dimension conversion matrices, wherein the main dimension conversion matrix and the first dimension conversion matrices are respectively constructed according to spectral characteristics of an object;

[0057] a risk vector screening module configured to, for each first spectral vector in the first spectral vector set, respectively perform conversion according to the main dimension conversion matrix, and screen a plurality of first risk spectral vectors from the first spectral vector set according to the conversion results, wherein the conversion result of the first risk spectral vector deviates from the vector before conversion by more than a deviation threshold, and each first spectral vector corresponds to a pixel of a target image;

[0058] a spectral characteristic matching module configured to, for each first risk spectral vector, perform conversion through the plurality of first dimension conversion matrices, and perform spectral characteristic matching according to the conversion results;

[0059] and,

[0060] a foreign matter identification module configured to extract a first image contour from the target image according to the spectral characteristics, and send the first image contour to an identification model for foreign matter identification.

[0061] In a third aspect, the embodiments of the present application provide an electronic device, which comprises a memory and a processor. The memory stores a computer program capable of running on the processor. When the processor executes the computer program, the steps of the method according to the first aspect or any possible implementation manner of the first aspect are implemented.

[0062] In a fourth aspect, the embodiments of the present application provide a computer readable storage medium, which stores a computer program. When the processor executes the computer program, the steps of the method according to the first aspect or any possible implementation manner of the first aspect are implemented.

[0063] Compared with the prior art, the embodiments of the present application have the following beneficial effects:

[0064] The embodiment of the present application discloses a foreign matter identification method based on spectral feature selection, and the embodiment of the foreign matter identification method based on spectral feature selection of the present application first acquires a main dimension conversion matrix and a plurality of first dimension conversion matrices, wherein the main dimension conversion matrix and the first dimension conversion matrix are respectively constructed according to the spectral characteristics of an object; then for each first spectral vector in a first spectral vector set, the main dimension conversion matrix is used for conversion, and a plurality of first risk spectral vectors are screened from the first spectral vector set according to the conversion result, wherein the conversion result of the first risk spectral vector deviates from the vector before conversion by more than a deviation threshold, and each first spectral vector corresponds to a pixel of a target image; then for each first risk spectral vector, the plurality of first dimension conversion matrices are used for conversion, and spectral characteristic matching is performed according to the conversion result; finally, a first image contour is extracted from the target image according to the spectral characteristics, and the first image contour is input into an identification model for foreign matter identification. Since the spectral vector is analyzed by the dimension conversion matrix with spectral characteristics, the risk vector can be screened from the plurality of spectral vectors, and the spectral characteristics of the risk vector are matched, that is, during data processing, the characteristic matching is completed, the image contour is extracted based on the matching result, and finally the contour is recognized. In this way, since the feature is distinguished, the pretreatment effect is good, and the recognition efficiency and recognition accuracy are improved.

[0065] The present application identifies the abnormal spectral vector based on the main dimension conversion matrix, and performs spectral characteristic matching based on the first dimension conversion matrix, so that the abnormal spectral pixel can be accurately extracted, and the characteristics of the foreign matter are preliminarily determined. The present application finally combines the contour formed by the abnormal spectral pixel and the identification model to accurately complete the identification of the foreign matter type, improve the recognition accuracy, and reduce the modeling and application difficulty of the identification model. BRIEF DESCRIPTION OF DRAWINGS

[0066] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0067] Figure 1 It is a flowchart of the foreign matter identification method based on spectral feature selection provided by the embodiment of the present application;

[0068] Figure 2 It is a process principle diagram for constructing a dimension conversion matrix provided by the embodiment of the present application;

[0069] Figure 3is a function block diagram of the foreign matter recognition device based on spectrum feature selection provided by the embodiment of the present application.

[0070] Figure 4 is a function block diagram of the electronic device provided by the embodiment of the present application. DETAILED DESCRIPTION

[0071] In the following description, for the purpose of explanation and not limitation, specific details are set forth, such as particular system configurations, techniques, etc., in order to provide a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application can be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices and methods are omitted so as not to obscure the description of the present application with unnecessary detail.

[0072] In order to make the objects, technical solutions and advantages of the present application clearer, the following will be described in conjunction with the accompanying drawings and specific embodiments.

[0073] The following will be described in detail for the embodiments of the present application, and the present example is implemented on the premise of the technical solutions of the present application, and detailed implementation manners and specific operation processes are given, but the protection scope of the present application is not limited to the following embodiments.

[0074] Figure 1 is a flow chart of the foreign matter recognition method based on spectrum feature selection provided by the embodiment of the present application.

[0075] As shown in Figure 1 , it shows the implementation flow chart of the foreign matter recognition method based on spectrum feature selection provided by the embodiment of the present application, and the details are as follows:

[0076] In step 101, a main dimension conversion matrix and a plurality of first dimension conversion matrices are obtained, wherein the main dimension conversion matrix and the first dimension conversion matrix are respectively constructed according to the spectrum characteristics of the object.

[0077] In some embodiments, the main dimension conversion matrix and the first dimension conversion matrix are constructed according to a plurality of second spectrum vectors, comprising:

[0078] For each of the main dimension conversion matrix and the first dimension conversion matrix, it is respectively constructed by the following steps:

[0079] A plurality of second dimension conversion matrices and a plurality of second spectrum vectors are obtained, wherein each second spectrum vector corresponds to a spectrum label identifying the spectrum characteristics of the object;

[0080] For each second-dimensional transformation matrix, the multiple second-spectral vectors are transformed using the second-dimensional transformation matrix respectively, and the fitness index is determined based on the multiple third-spectral vectors obtained, the multiple second-spectral vectors, and the spectral label of each vector;

[0081] If the number of iterations is reached, the second-dimensional transformation matrix with the largest fitness index is used as the main-dimensional transformation matrix or the first-dimensional transformation matrix, and the deviation threshold is determined based on the largest fitness index.

[0082] Otherwise, the fitness index is adjusted for each second-dimensional transformation matrix according to multiple fitness indices, and the process jumps to the step of transforming the multiple second-dimensional spectral vectors using the second-dimensional transformation matrix for each second-dimensional transformation matrix, and determining the fitness index based on the obtained multiple third-dimensional spectral vectors, the multiple second-dimensional spectral vectors, and the spectral label of each vector.

[0083] In some implementations, the step of transforming the plurality of second spectral vectors using a second-dimensional transformation matrix, and determining the fitness index based on the obtained plurality of third spectral vectors, the plurality of second spectral vectors, and the spectral label of each vector, includes:

[0084] According to the first formula, each second spectral vector is transformed using the second-dimensional transformation matrix to obtain the third spectral vector, where the first formula is:

[0085]

[0086] In the formula, The third spectral vector, The second spectral vector, This is the second-dimensional transformation matrix. For the second dimension transformation matrix Line number Column elements, This represents the total number of elements in the second spectral vector;

[0087] The fitness index is determined based on the second formula, the obtained multiple third spectral vectors, the multiple second spectral vectors, and the spectral label of each vector, wherein the second formula is:

[0088]

[0089] In the formula, For fitness index, The total number of second spectral vectors. For label judgment value, This is the label extraction function for vectors. a spectral label of the second dimension conversion matrix.

[0090] In some embodiments, the adjusting each second dimension conversion matrix according to the plurality of fitness indexes comprises:

[0091] obtaining a plurality of fitness queues, wherein each fitness queue corresponds to a second dimension conversion matrix;

[0092] adding each fitness index into a fitness queue of the corresponding second dimension conversion matrix;

[0093] extracting a fitness index with the maximum value from each fitness queue as a first target fitness, and extracting a historical second dimension conversion matrix corresponding to the first target fitness as a first target conversion matrix;

[0094] extracting a maximum value in the plurality of fitness indexes as a second target fitness, and extracting a second dimension conversion matrix corresponding to the second target fitness as a second target conversion matrix;

[0095] for each second dimension conversion matrix, adjusting according to a third formula, the second target conversion matrix and the corresponding first target conversion matrix, wherein the third formula is:

[0096]

[0097] wherein, is an element of the adjusted second dimension conversion matrix in the i-th row and the j-th column, is an element of the second dimension conversion matrix before adjustment in the i-th row and the j-th column, is an element of the first target conversion matrix in the i-th row and the j-th column, is an element of the second target conversion matrix in the i-th row and the j-th column. is a first adjustment coefficient, is an element of the first target conversion matrix in the i-th row and the j-th column, is a second adjustment coefficient, is an element of the second target conversion matrix in the i-th row and the j-th column.

[0098] ​​​​​​For example, this invention uses hyperspectral data for feature matching to identify foreign objects. First, it obtains a main dimension transformation matrix based on the known spectral characteristics of the object. This matrix is ​​then used to transform each spectral vector, and spectral vectors with foreign object risk are selected from the transformation results. These risky spectral vectors are then transformed using each first-dimensional transformation matrix (each first-dimensional transformation matrix corresponds to a spectral characteristic of an object). Spectral characteristics are matched according to the transformation results. After matching, further foreign object analysis is performed based on the contour of the image formed by the risky spectral vectors, thus completing the foreign object identification.

[0099] From the above process, we can see that the dimension transformation matrix is ​​key to analyzing the spectral characteristics of the first spectral vector. In fact, each dimension transformation matrix corresponds to a spectral label; in other words, it's a label for the object's spectrum. When the first spectral vector matches this spectral label, the transformation result of the transformation matrix has a high degree of consistency with the original first spectral vector; otherwise, there will be a significant deviation.

[0100] Furthermore, in the embodiments of this invention, the terms "first-dimensional transformation matrix" and "second-dimensional transformation matrix" will be mentioned. These matrix names are used for ease of distinction and have no order or other special meaning.

[0101] like Figure 2 As shown, the dimensional transformation matrix (including the main dimensional transformation matrix and each first dimensional transformation matrix) is constructed by multiple second dimensional transformation matrices 201 and multiple second spectral vectors 202. Each second spectral vector 202 corresponds to a spectral label 203, which generally represents an object.

[0102] In constructing the dimensional transformation matrix using the second spectral vector 202, this invention constructs each dimensional transformation matrix individually. Specifically, for each matrix of each principal dimensional transformation matrix and each matrix of each first dimensional transformation matrix, the following steps are performed:

[0103] First, multiple second-dimensional transformation matrices 201 are initialized. For each second-dimensional transformation matrix 201, a transformation is performed on each second spectral vector 202. In one scenario, the first formula is used:

[0104]

[0105] In the formula, The third spectral vector is 204. For the second spectral vector 202, The second-dimensional transformation matrix is ​​201. For the second dimension transformation matrix 201 Line number Column elements, is the total number of elements in the second spectral vector 202.

[0106] By the above formula, each second spectral vector 202 is converted to obtain a third spectral vector 204. We determine the fitness index 205 according to the second formula, the plurality of third spectral vectors 204 obtained, the plurality of second spectral vectors 202, and the spectral label 203 of each vector.

[0107]

[0108] wherein, is the fitness index 205, is the total number of second spectral vectors 202, is the label judgment value, is the label extraction function of the vector, is the spectral label corresponding to the second dimension conversion matrix.

[0109] The second formula in the present application is a formula for calculating the fitness index of each second dimension conversion matrix, and the final output value is positively correlated with the conversion accuracy of the second dimension conversion matrix.

[0110] The second dimension conversion matrix is a process matrix, and the ultimate goal of its construction is to convert the spectral vector adapted to it to obtain a vector that has a higher similarity and a smaller deviation compared to the vector before conversion; on the contrary, for the spectral vector that is not adapted, the conversion of the vector obtained after conversion has a lower similarity and a larger deviation compared to the vector before conversion.

[0111] Example: The second dimension conversion matrix is ultimately used to match the spectral vector of rice (spectral label: rice), and the second spectral vector is used to test the second dimension conversion matrix, and there are multiple second spectral vectors, which may be rice or soybeans.

[0112] For a second dimension conversion matrix that can achieve the goal (a matrix with a higher fitness index), for the second spectral vector with a spectral label of rice, the left half of the second formula is applied (because , that is, the spectral label of the second dimension conversion matrix is the same as the label of the second spectral vector):

[0113]

[0114] It can be seen that the more similar the second spectral vector A and the third spectral vector B are, the greater the fitness index SF is.

[0115] On the contrary, for the second spectral vector with a spectral label of soybeans, the right half of the second formula is applied (because , that is, the spectral label of the second dimension conversion matrix is different from the label of the second spectral vector:

[0116]

[0117] It can be seen that the more similar the second spectral vector A and the third spectral vector B are, the smaller the fitness index SF is.

[0118] The more dissimilar the second spectral vector A and the third spectral vector B are, the larger the fitness index SF is. This is because a second dimension conversion matrix that matches the spectral label of rice well should match the spectral label of soybean poorly in order to successfully distinguish the difference between the two (the third spectral vector B output by the second dimension conversion matrix is greatly different from the second spectral vector).

[0119] From the above analysis, it can be seen that the second spectral vector with a spectral label is a vector used to test the conversion effect of the second dimension conversion matrix.

[0120] And the third spectral vector is a vector obtained by the second spectral vector through the second dimension conversion matrix (a result vector for testing the second dimension conversion matrix).

[0121] And the second spectral vector is different from the first spectral vector, which is the real vector to be distinguished and the real operation vector, which is a spectral vector obtained based on the picture pixels.

[0122] If the number of iterations is reached (the number of iterations refers to the number of times that all second dimension conversion matrices 201 complete the conversion of multiple second spectral vectors 202 and calculate the fitness index 205 of all second dimension conversion matrices 201, which can be recorded as one iteration number after all second dimension conversion matrices 201 calculate the fitness index 205), the second dimension conversion matrix 201 with the largest fitness index is taken as the main dimension conversion matrix or the first dimension conversion matrix, and the deviation threshold is determined according to the maximum fitness index, for example, the deviation threshold is determined in proportion to the maximum fitness index, for example, in one scenario, the deviation threshold , is the maximum fitness index.

[0123] If the number of iterations is not reached, adjust each second dimension conversion matrix 201 according to multiple fitness indexes 205, and repeat the above steps of converting multiple second spectral vectors 202 by using the second dimension conversion matrix 201 after the adjustment.

[0124] In terms of adjustment, this invention sets up a fitness queue for each second-dimensional transformation matrix 201. We add the obtained fitness index 205 to the fitness queue of the corresponding second-dimensional transformation matrix 201. Then, we extract the fitness index with the largest value from each fitness queue as the first target fitness, and use the historical second-dimensional transformation matrix 201 corresponding to the first target fitness as the first target transformation matrix.

[0125] Meanwhile, the maximum value among multiple fitness indices 205 is taken as the second target fitness, and the second dimension transformation matrix 201 corresponding to the second target fitness is taken as the second target transformation matrix.

[0126] Finally, for each second-dimensional transformation matrix 201, adjustments are made according to the third formula, the second target transformation matrix, and the corresponding first target transformation matrix. The third formula is as follows:

[0127]

[0128] In the formula, The adjusted second-dimensional transformation matrix 201 Line number Column elements, The second-dimensional transformation matrix before adjustment, 201. Line number Column elements, The first adjustment factor is... For the first target transformation matrix, the first... Line number Column elements, This is the second adjustment factor. For the second objective transformation matrix, the first Line number The elements of the column.

[0129] Through the above process, we obtain the dimension transformation matrix corresponding to different spectral characteristics. We will discuss in detail how to perform risk spectral vector screening and spectral feature matching in the following steps.

[0130] In step 102, for each first spectral vector in the first spectral vector set, it is transformed according to the main dimension transformation matrix, and multiple first risk spectral vectors are selected from the first spectral vector set according to the transformation result. The deviation between the transformation result of the first risk spectral vector and the vector before transformation exceeds the deviation threshold, and each first spectral vector corresponds to a pixel of the target image.

[0131] In some embodiments, the converting, for each first spectral vector in the first set of spectral vectors, according to the main dimension conversion matrix respectively, and screening a plurality of first risk spectral vectors from the first set of spectral vectors according to the conversion result, comprises:

[0132] The following steps are performed for each first spectral vector respectively:

[0133] The first spectral vector is converted according to a fourth formula, and a deviation degree is obtained according to the conversion result, wherein the fourth formula is:

[0134]

[0135] wherein, is the converted vector, is the first spectral vector, is the main dimension conversion matrix, is the deviation degree;

[0136] If the deviation degree is greater than the deviation threshold, the first spectral vector is taken as a first risk spectral vector.

[0137] In step 103, for each first risk spectral vector, conversion is performed through the plurality of first dimension conversion matrices, and spectral characteristic matching is performed according to the conversion result.

[0138] In some embodiments, each first risk spectral vector corresponds to a spectral label representing the spectral characteristics of the object, and the converting, for each first risk spectral vector, through the plurality of first dimension conversion matrices, and the spectral characteristic matching according to the conversion result, comprises:

[0139] The following steps are performed for each first risk spectral vector respectively:

[0140] The first risk spectral vector is converted through the plurality of first dimension conversion matrices respectively, and a plurality of fourth spectral vectors are obtained;

[0141] A deviation degree is calculated for each fourth spectral vector with the first risk spectral vector respectively;

[0142] The fourth spectral vector with a deviation degree less than a deviation degree threshold is taken as a target spectral vector;

[0143] The spectral label corresponding to the first dimension conversion matrix of the target spectral vector is taken as the spectral label of the pixel corresponding to the first risk spectral vector.

[0144] Exemplarily, it is to be noted that the spectral vector data of the present application: the first spectral vectors are aggregated into a first spectral vector set, and in fact, each first spectral vector corresponds to a pixel of the target image, and the first spectral vector is composed of spectral amplitudes of multiple wave bands. In other words, the first spectral vector set corresponds to the target image, and the first spectral vector corresponds to the pixel of the target image.

[0145] In the aspect of screening the spectral vectors by using the principal dimension conversion matrix, for each first spectral vector, the first spectral vector is converted by using a fourth formula, and a deviation degree is obtained according to the conversion result, wherein the fourth formula is:

[0146]

[0147] In the formula, is the converted vector, is the first spectral vector, is the principal dimension conversion matrix, is the deviation degree;

[0148] If the deviation degree is greater than a deviation threshold, the first spectral vector is taken as a first risk spectral vector.

[0149] The above-mentioned step only performs screening of the risk spectral vectors, and spectral feature matching still needs to be performed afterwards. In the matching, the present application is converted by using each first dimension conversion matrix, and the matching is performed according to the obtained conversion result. Specifically, for each first risk spectral vector, the first risk spectral vector is converted by using a plurality of first dimension conversion matrices respectively, a plurality of fourth spectral vectors (each fourth spectral vector is converted based on one first dimension conversion matrix) are obtained, and then, for each fourth spectral vector, a deviation degree is calculated with the first risk spectral vector respectively; then, the fourth spectral vector with a deviation degree less than a deviation threshold is taken as a target spectral vector, at this time, the spectral characteristic matching is completed, and finally, the spectral label of the target spectral vector corresponding to the first dimension conversion matrix is taken as the spectral label of the pixel corresponding to the first risk spectral vector.

[0150] After the above-mentioned step is completed, the foreign matter recognition can be performed.

[0151] In step 104, a first image contour is extracted from the target image according to the spectral characteristics, and the first image contour is sent to the recognition model for foreign matter recognition.

[0152] In some embodiments, the risk pixels in the target image are identified with spectral labels, and the first image contour is extracted from the target image according to the spectral characteristics, and the first image contour is sent to the recognition model for foreign matter recognition, which includes:

[0153] For each spectral label, the following steps are performed:

[0154] Pixels marked with the spectral label are extracted from the target image;

[0155] The extracted pixels are constructed into a first image block, and an outline of the first image block is extracted as a first image outline;

[0156] The first image outline is input into the recognition model constructed according to the artificial neural network model for recognition;

[0157] The foreign matter category is determined according to the output of the recognition model.

[0158] Exemplarily, in the aspect of foreign matter recognition, the present application extracts the image outline through the spectral label extraction of the foregoing steps, and performs recognition based on the outline.

[0159] Specifically, for each spectral label, first, pixels marked with the spectral label are extracted from the target image, then the extracted pixels are constructed into a first image block, and an outline of the first image block is extracted as a first image outline, finally, the first image outline is input into the recognition model constructed according to the artificial neural network model for recognition, and the foreign matter category is determined according to the output of the recognition model.

[0160] In the foreign matter recognition method embodiment based on spectral feature selection, a main dimension conversion matrix and a plurality of first dimension conversion matrices are first obtained, wherein the main dimension conversion matrix and the first dimension conversion matrices are respectively constructed according to spectral characteristics of an object; then for each first spectral vector in a first spectral vector set, the main dimension conversion matrix is used for conversion, and a plurality of first risk spectral vectors are selected from the first spectral vector set according to the conversion results, wherein the conversion result of the first risk spectral vector deviates from the vector before conversion by more than a deviation threshold, and each first spectral vector corresponds to a pixel of a target image; then for each first risk spectral vector, the plurality of first dimension conversion matrices are used for conversion, and spectral characteristic matching is performed according to the conversion results; finally, a first image outline is extracted from the target image according to the spectral characteristics, and the first image outline is input into a recognition model for foreign matter recognition. Since the spectral vector is analyzed by using the dimension conversion matrix with spectral characteristics, the risk vector can be selected from the plurality of spectral vectors, and the spectral characteristics of the risk vector are matched, that is, during data processing, the characteristic matching is completed, the image outline is extracted based on the matching result, and finally the recognition is performed according to the outline. In this way, since the feature is distinguished, the pretreatment effect is good, and the recognition efficiency and recognition accuracy are improved.

[0161] It should be understood that the size of the serial number of each step in the above embodiments does not mean the order of execution, and the execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0162] The following is the device embodiment of the present application. For details not described in detail, please refer to the corresponding method embodiments described above.

[0163] Figure 3 is the function block diagram of the foreign matter recognition device based on spectrum feature selection provided by the embodiments of the present application. Referring to Figure 3 , the foreign matter recognition device based on spectrum feature selection comprises a conversion matrix acquisition module 301, a risk vector screening module 302, a spectrum characteristic matching module 303 and a foreign matter recognition module 304, wherein:

[0164] The conversion matrix acquisition module 301 is configured to acquire a main dimension conversion matrix and a plurality of first dimension conversion matrices, wherein the main dimension conversion matrix and the first dimension conversion matrix are constructed according to the spectrum characteristics of the object respectively;

[0165] The risk vector screening module 302 is configured to, for each first spectrum vector in the first spectrum vector set, respectively convert according to the main dimension conversion matrix, and screen a plurality of first risk spectrum vectors from the first spectrum vector set according to the conversion result, wherein the conversion result of the first risk spectrum vector deviates from the vector before conversion by more than a deviation threshold, and each first spectrum vector corresponds to a pixel of the target image;

[0166] The spectrum characteristic matching module 303 is configured to, for each first risk spectrum vector, convert through the plurality of first dimension conversion matrices, and perform spectrum characteristic matching according to the conversion result;

[0167] The foreign matter recognition module 304 is configured to extract a first image contour from the target image according to the spectrum characteristics, and input the first image contour into a recognition model for foreign matter recognition.

[0168] Figure 4 is the function block diagram of the electronic device provided by the embodiments of the present application. As Figure 4 shown, the electronic device 4 of the embodiment comprises a processor 400 and a memory 401, and the memory 401 stores a computer program 402 which can run on the processor 400. The processor 400 implements the steps in the above-mentioned various foreign matter recognition methods and embodiments based on spectrum feature selection when executing the computer program 402, such as Figure 1 steps 101 to 104 shown in the figure.

[0169] For example, the computer program 402 can be divided into one or more modules / units, which are stored in the memory 401 and executed by the processor 400 to complete the present application.

[0170] The electronic device 4 can be a desktop computer, a notebook computer, a palm computer, a cloud server and the like. The electronic device 4 can include, but is not limited to, the processor 400 and the memory 401. Those skilled in the art can understand that the electronic device 4 can include more or less components, or combine some components, or different components, for example, the electronic device 4 can also include an input / output device, a network access device, a bus and the like. Figure 4 The electronic device 4 is only an example and does not constitute a limitation on the electronic device 4, and can include more or less components than the diagram, or combine some components, or different components, for example, the electronic device 4 can also include an input / output device, a network access device, a bus and the like.

[0171] The processor 400 can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.

[0172] The memory 401 can be an internal storage unit of the electronic device 4, such as a hard disk or a memory of the electronic device 4. The memory 401 can also be an external storage device of the electronic device 4, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card and the like equipped on the electronic device 4. Further, the memory 401 can include both the internal storage unit and the external storage device of the electronic device 4. The memory 401 is used to store the computer program 402 and other programs and data required by the electronic device 4. The memory 401 can also be used to temporarily store data that has been output or will be output.

[0173] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of each functional unit and module is exemplified, and in actual application, the above-mentioned functions can be completed by different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be realized in the form of hardware or software function unit. In addition, the specific name of each functional unit and module is only for the convenience of mutual distinction, and does not limit the protection scope of the present application. The specific working process of the unit and module in the above system can refer to the corresponding process in the foregoing method embodiment, which will not be repeated here.

[0174] In the above embodiments, the description of each embodiment has its own emphasis, and the parts not described or recorded in detail in a certain embodiment can be referred to the related description of other embodiments.

[0175] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized in electronic hardware or a combination of computer software and electronic hardware. Whether the functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. A person skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0176] In the embodiments provided by the present application, it should be understood that the disclosed apparatus / electronic device and method can be implemented in other ways. For example, the above-described apparatus / electronic device embodiments are merely schematic, for example, the division of the modules or units is only a logical function division, and there can be another division manner in actual implementation, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interface, device or unit, and can be electrical, mechanical or other forms.

[0177] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on a plurality of network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the present embodiment scheme.

[0178] In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.

[0179] The integrated module / unit, if realized in the form of a software functional unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, all or part of the processes in the above-mentioned embodiment methods can also be completed by a computer program instructing related hardware, and the computer program can be stored in a computer readable storage medium. When the computer program is executed by a processor, the steps of each method and device embodiment described above can be implemented. The computer program includes computer program code, which can be in the form of source code, object code, executable files or some intermediate forms. The computer readable medium can include any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal and software distribution medium, etc.

[0180] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement to part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.

Claims

1. A foreign matter recognition method based on spectral feature selection, characterized by, include: Obtain the principal dimension transformation matrix and multiple first dimension transformation matrices, wherein the principal dimension transformation matrix and the first dimension transformation matrices are constructed based on the spectral characteristics of the object, including: For each matrix in the main dimension transformation matrix and the first dimension transformation matrix, the following steps are performed: Obtain multiple second-dimensional transformation matrices and multiple second-spectral vectors, where each second-spectral vector corresponds to a spectral label that identifies the spectral characteristics of an object; For each second-dimensional transformation matrix, the multiple second-spectral vectors are transformed using the second-dimensional transformation matrix respectively, and the fitness index is determined based on the multiple third-spectral vectors obtained, the multiple second-spectral vectors, and the spectral label of each vector; If the number of iterations is reached, the second-dimensional transformation matrix with the largest fitness index is used as the main-dimensional transformation matrix or the first-dimensional transformation matrix, and the deviation threshold is determined based on the largest fitness index. Otherwise, the fitness index is adjusted for each second-dimensional transformation matrix according to multiple fitness indices, and the process jumps to the step of transforming the multiple second-dimensional spectral vectors using the second-dimensional transformation matrix for each second-dimensional transformation matrix, and determining the fitness index based on the obtained multiple third-dimensional spectral vectors, the multiple second-dimensional spectral vectors, and the spectral label of each vector. For each first spectral vector in the first spectral vector set, it is transformed according to the main dimension transformation matrix, and multiple first risk spectral vectors are selected from the first spectral vector set according to the transformation result. The deviation between the transformation result of the first risk spectral vector and the vector before transformation exceeds the deviation threshold. Each first spectral vector corresponds to a pixel of the target image. For each first risk spectral vector, it is transformed using the multiple first-dimensional transformation matrices, and spectral characteristics are matched based on the transformation results; The first image contour is extracted from the target image based on the spectral characteristics, and the first image contour is sent to the recognition model for foreign object recognition. The adjustment of each second-dimensional transformation matrix based on multiple fitness indices includes: Obtain multiple fitness queues, where each fitness queue corresponds to a second-dimensional transformation matrix; Add each fitness index to the fitness queue of the corresponding second-dimensional transformation matrix; Extract the fitness index with the largest value from each fitness queue as the first target fitness, and use the historical second-dimensional transformation matrix corresponding to the first target fitness as the first target transformation matrix; The maximum value among the plurality of fitness indices is taken as the second target fitness, and the second dimension transformation matrix corresponding to the second target fitness is taken as the second target transformation matrix; For each second-dimensional transformation matrix, adjustments are made according to the third formula, the second target transformation matrix, and the corresponding first target transformation matrix, wherein the third formula is: In the formula, The adjusted second-dimensional transformation matrix Line number Column elements, The second dimension transformation matrix before adjustment Line number Column elements, The first adjustment factor is... For the first target transformation matrix, the first... Line number Column elements, This is the second adjustment factor. For the second objective transformation matrix, the first Line number The elements of the column.

2. The foreign object identification method based on spectral feature selection according to claim 1, characterized in that, The process of transforming the plurality of second spectral vectors using a second-dimensional transformation matrix, and determining the fitness index based on the obtained plurality of third spectral vectors, the plurality of second spectral vectors, and the spectral label of each vector, includes: According to the first formula, each second spectral vector is transformed using the second-dimensional transformation matrix to obtain the third spectral vector, where the first formula is: In the formula, The third spectral vector, The second spectral vector, This is the second-dimensional transformation matrix. For the second dimension transformation matrix Line number Column elements, This represents the total number of elements in the second spectral vector; The fitness index is determined based on the second formula, the obtained multiple third spectral vectors, the multiple second spectral vectors, and the spectral label of each vector, wherein the second formula is: In the formula, For fitness index, The total number of second spectral vectors. For label judgment value, This is the label extraction function for vectors. The spectral labels are for the second-dimensional transformation matrix.

3. The foreign object identification method based on spectral feature selection according to claim 1, characterized in that, For each first spectral vector in the first spectral vector set, a transformation is performed according to the principal dimension transformation matrix, and multiple first risk spectral vectors are selected from the first spectral vector set based on the transformation results, including: For each first spectral vector, perform the following steps: The first spectral vector is transformed according to the fourth formula, and the deviation is obtained based on the transformation result. The fourth formula is: In the formula, The vector obtained by the transformation, The first spectral vector, Main dimension transformation matrix, For deviation; If the deviation is greater than the deviation threshold, then the first spectral vector is used as the first risk spectral vector.

4. The foreign object identification method based on spectral feature selection according to claim 1, characterized in that, Each first risk spectral vector corresponds to a spectral label characterizing the spectral properties of an object. For each first risk spectral vector, transformation is performed using the multiple first-dimensional transformation matrices, and spectral property matching is performed based on the transformation results, including: For each first-risk spectral vector, perform the following steps: The first risk spectral vector is transformed using the multiple first-dimensional transformation matrices to obtain multiple fourth spectral vectors; For each fourth spectral vector, calculate the deviation from the first risk spectral vector; The fourth spectral vector with a deviation less than the deviation threshold is taken as the target spectral vector; The spectral label of the first dimension transformation matrix corresponding to the target spectral vector is used as the spectral label of the pixel corresponding to the first risk spectral vector.

5. The foreign object identification method based on spectral feature selection according to any one of claims 1-4, characterized in that, The risk pixels in the target image are identified by spectral tags. The step of extracting a first image contour from the target image based on spectral characteristics and then feeding the first image contour into a recognition model for foreign object identification includes: For each spectral label, perform the following steps: Extract pixels labeled with spectral tags from the target image; The extracted pixels are used to construct a first image block, and the contour of the first image block is extracted as the first image contour. The first image contour is input into the recognition model constructed based on the artificial neural network model for recognition; The type of foreign object is determined based on the output of the recognition model.

6. A foreign object identification device based on spectral feature selection, characterized in that, For implementing the foreign object identification method based on spectral feature selection as described in any one of claims 1-5, the foreign object identification device based on spectral feature selection comprises: The transformation matrix acquisition module is used to acquire the main dimension transformation matrix and multiple first dimension transformation matrices, wherein the main dimension transformation matrix and the first dimension transformation matrices are constructed based on the spectral characteristics of the object. The risk vector filtering module is used to transform each first spectral vector in the first spectral vector set according to the main dimension transformation matrix, and to filter out multiple first risk spectral vectors from the first spectral vector set according to the transformation result. The deviation between the transformation result of the first risk spectral vector and the vector before transformation exceeds the deviation threshold, and each first spectral vector corresponds to a pixel of the target image. The spectral characteristic matching module is used to transform each first risk spectral vector through the multiple first-dimensional transformation matrices and perform spectral characteristic matching based on the transformation results. as well as, The foreign object recognition module is used to extract a first image contour from the target image based on spectral characteristics, and to send the first image contour into the recognition model for foreign object recognition.

7. An electronic device comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1 to 5 above.

8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 5 above.

Citation Information

Patent Citations

  • Drug production quality identification method and platform based on big data

    CN118962042A

  • Distributed task scheduling method and apparatus, storage medium, and electronic device

    WO2025035834A1