Foreign matter early warning method and device, electronic equipment and storage medium

By using visual segmentation lines and dimensionality reduction transformation matrices to process spectral data in customs supervision scenarios, a method for identifying foreign objects has been developed. This method solves the problem of false alarms when combining visual and spectral analysis, and achieves more efficient foreign object identification.

CN121330622BActive Publication Date: 2026-04-14INSPECTION & 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
2025-12-17
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

In existing technologies, the combination of vision and spectral analysis is prone to false alarms when identifying foreign objects, especially when it is difficult to accurately identify foreign objects disguised as normal goods.

Method used

By acquiring the first region, the region is divided using visual segmentation lines. The spectral data is then reduced in dimensionality and classified using a dimensionality reduction transformation matrix. The probability of foreign objects is calculated using spectral class identifiers and conditional probability equations, and an early warning is output.

Benefits of technology

It improves the accuracy of foreign object detection, reduces the probability of false alarms, and increases detection efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121330622B_ABST
    Figure CN121330622B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of foreign matter identification, and particularly relates to a foreign matter early warning method and device, electronic equipment and storage medium, the method of the present application first acquires a first region; then a plurality of first spectral vectors are reduced in dimension through a dimension reduction conversion matrix to obtain a plurality of second spectral vectors; then each second spectral vector is classified according to the relationship between the second spectral vector and a plurality of spectral classes to obtain a plurality of spectral class identifiers; finally, a plurality of target identifiers are selected from the plurality of spectral class identifiers, a first foreign matter probability is determined according to the plurality of target identifiers, a perimeter area ratio of the first region and a conditional probability equation, and early warning is performed according to the first foreign matter probability. Based on the region of visual identification, spectral data is extracted, the spectral data is reduced in dimension and classified, the foreign matter risk is determined based on data dimension reduction, classification and statistics, the accuracy of foreign matter early warning is improved, and the probability of false alarm when discovering foreign matter is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of foreign object identification technology, and in particular to a foreign object early warning method, device, electronic device, and storage medium. Background Technology

[0002] In customs supervision scenarios, "foreign objects" typically refer to items that do not comply with regulations, are undeclared, or pose safety risks, and may include contraband, dangerous goods, infringing products, quarantine pests, etc. Customs' investigation and handling of foreign objects is a crucial step in ensuring public safety, public health, and social order.

[0003] Customs inspection of foreign objects mainly uses the following methods:

[0004] Manual inspection: Opening and inspecting luggage and goods, using visual and olfactory senses to determine if there are any abnormal items, applicable to obvious violations.

[0005] Technical equipment inspection: X-ray security inspection machine: Through penetrating imaging, it identifies structural differences inside luggage or cargo to determine whether there are hidden foreign objects (such as knives, liquids, high-density items).

[0006] CT scan: a three-dimensional imaging technology that can more clearly show the shape of items inside complex packages and is often used to screen high-risk goods.

[0007] Quarantine equipment, such as trace drug detectors and biosensors, can quickly detect the presence of drug residues or harmful biological DNA.

[0008] Spectral analysis: Identifying the composition of unknown liquids and powders by analyzing their spectral characteristics, and determining whether they are hazardous or prohibited substances.

[0009] In reality, most of the above-mentioned inspection methods still require manual verification, which has disadvantages such as low efficiency, high requirements for professional experience, and harm to human health.

[0010] Other technologies attempt to identify foreign objects using visual methods. However, some foreign objects are disguised and their shape is very similar to normal goods, making it easy for visual methods to miss detections. Combining visual recognition methods with other devices, such as spectral analysis, can also lead to frequent false alarms.

[0011] Therefore, it is necessary to develop and design a foreign object early warning method. Summary of the Invention

[0012] The present invention provides a foreign object early warning method, device, electronic device and storage medium to solve the problem that false alarms are easily triggered when foreign objects are detected by combining visual and spectral analysis in the prior art.

[0013] In a first aspect, embodiments of the present invention provide a foreign object warning method, comprising:

[0014] Obtain a first region, wherein a visual dividing line exists between the first region and other regions;

[0015] Multiple first spectral vectors are reduced in dimension by a dimension reduction transformation matrix to obtain multiple second spectral vectors. Each second spectral vector corresponds to a first spectral vector. The first spectral vector is obtained based on the first region and is constructed from multiple spectral values, each of which corresponds to a spectral wavelength.

[0016] Each second spectral vector is classified according to its relationship with multiple spectral classes to obtain multiple spectral class identifiers, where each spectral class identifier corresponds to a second spectral vector;

[0017] Multiple target identifiers are selected from the multiple spectral identifiers. A first foreign object probability is determined based on the multiple target identifiers, the perimeter-to-area ratio of the first region, and the conditional probability equation. An early warning is issued based on the first foreign object probability. The proportion of the multiple target identifiers in the multiple spectral identifiers is greater than a first threshold. The perimeter-to-area ratio of the first region is determined based on the perimeter of the first region and the area of ​​the first region. The first foreign object probability represents the probability that a foreign object exists in the first region.

[0018] In one possible implementation, the dimensionality reduction transformation matrix is ​​obtained based on a plurality of first sample spectral vectors, including:

[0019] Multiple first sample spectral vectors are obtained, wherein the first sample spectral vectors are constructed based on multiple spectral values, and each spectral value corresponds to a spectral wavelength;

[0020] Each of the plurality of first sample spectral vectors is standardized to obtain a plurality of second sample spectral vectors;

[0021] The second spectral vectors of the multiple samples are used to construct a sample vector matrix;

[0022] The covariance of the matrix elements is calculated based on the sample vector matrix to obtain the first matrix;

[0023] Based on the first matrix, multiple eigenvalues ​​and multiple eigenvectors are determined, wherein each eigenvalue corresponds to one eigenvector;

[0024] The plurality of feature values ​​are sorted in order of value size, and a plurality of target feature values ​​are found from the sorting, wherein the ratio of the sum of the plurality of target feature values ​​to the sum of the plurality of feature values ​​is greater than a first ratio threshold.

[0025] Use the eigenvectors corresponding to the target eigenvalues ​​as the target eigenvectors;

[0026] Multiple target feature vectors are constructed into a dimension reduction transformation matrix.

[0027] In one possible implementation, the standardization of each of the plurality of first sample spectral vectors to obtain a plurality of second sample spectral vectors includes:

[0028] Spectral wavelengths are sequentially selected from multiple spectral wavelengths as the wavelengths to be converted;

[0029] Multiple spectral values ​​are extracted from the multiple first sample spectral vectors according to the wavelength to be converted, and used as multiple first intermediate spectral values;

[0030] Calculate the mean and standard deviation of the plurality of first intermediate spectral values, and use them as the first mean and the first standard deviation;

[0031] Based on the plurality of first intermediate spectral values, the first mean, the first standard deviation, and the first formula, a plurality of second intermediate spectral values ​​are determined, wherein the first formula is:

[0032]

[0033] In the formula, This is the second intermediate spectral value. This is the first intermediate spectral value. The first mean, The first standard deviation;

[0034] The plurality of second intermediate spectral values ​​are respectively added as vector elements to the plurality of second sample spectral vectors;

[0035] If the traversal of multiple spectral wavelengths is not completed, the process jumps to the step of sequentially extracting spectral wavelengths from multiple spectral wavelengths as the wavelengths to be converted.

[0036] The step of reducing the dimensionality of multiple first spectral vectors using a dimensionality reduction transformation matrix to obtain multiple second spectral vectors includes:

[0037] Multiple first spectral vectors are reduced in dimension using the second formula and the dimension reduction transformation matrix to obtain multiple second spectral vectors, wherein the second formula is:

[0038]

[0039] In the formula, The second spectral vector, The first spectral vector, This is the dimension reduction transformation matrix. For the first Target feature vectors.

[0040] In one possible implementation, the plurality of spectral classes are constructed based on a plurality of third sample spectral vectors, including:

[0041] Obtain the first preset distance, the number of reference samples, and multiple third sample spectral vectors. Each third sample spectral vector corresponds to an initial sample spectral vector. The third sample spectral vector is obtained by dimensionality reduction of the initial sample spectral vector through a dimensionality reduction transformation matrix. The initial sample spectral vector is constructed based on multiple spectral values, each of which corresponds to a spectral wavelength.

[0042] For each third sample spectral vector, calculate the first distance value to each other third sample spectral vector, and construct a distance dataset from the multiple first distance values ​​obtained.

[0043] The distance dataset with the number of target elements exceeding the number of reference samples is taken as the starting point dataset, and the third sample spectral vector corresponding to the starting point dataset is taken as the starting point spectral vector. The target element is the element in the dataset whose value is less than the first preset distance.

[0044] The vector taken from the multiple starting point spectral vectors that have not been clustered is used as the clustering vector;

[0045] In the unclustered third sample spectral vector, find the target vector, where the target vector is the vector whose distance from the current cluster vector is less than the first preset distance;

[0046] If a target vector exists, the target vector is added to the class where the clustering vector is located, the target vector is used as the clustering vector, and the process jumps to the third sample spectral vector that has not been clustered to find the target vector.

[0047] Otherwise, if there are unclustered starting point spectral vectors, then jump to the step of extracting the vector from the multiple unclustered starting point spectral vectors as the clustering vector;

[0048] Delete the spectral vectors of the third sample that have not completed clustering, as well as the classes whose number of vectors is less than the threshold for the number of classes;

[0049] The remaining classes are designated as the plurality of spectral classes.

[0050] In one possible implementation, classifying each second spectral vector based on its relationship with multiple spectral classes to obtain multiple spectral class identifiers includes:

[0051] The vectors are iteratively selected from the plurality of second spectral vectors as vectors to be classified, and the following steps are performed after each selection:

[0052] Calculate the distance between the vector to be classified and each of the multiple class vectors to obtain multiple second distance values, where the class vectors are vectors in the multiple spectral classes;

[0053] Use the minimum value among multiple second distance values ​​as the classification distance value;

[0054] If the classification distance value is less than the first preset distance, then the class vector corresponding to the classification distance value is taken as the nearest vector, and the identifier of the class in which the nearest vector is located is taken as the spectral class identifier of the vector to be classified.

[0055] Otherwise, an empty identifier is used as the spectral class identifier for the vector to be classified.

[0056] In one possible implementation, selecting multiple target identifiers from the plurality of spectral class identifiers and determining the first foreign object probability based on the plurality of target identifiers, the perimeter-to-area ratio of the first region, and a conditional probability equation includes:

[0057] Obtain the second proportional threshold;

[0058] Group the identical identifiers among the multiple spectral class identifiers into a group to obtain multiple identifier groups;

[0059] The number of icons in the icon group is taken as the number of icons;

[0060] Multiple values ​​are selected from the number of identifiers in descending order to serve as multiple target values, wherein the ratio of the sum of the multiple target values ​​to the sum of the number of identifiers is greater than the second ratio threshold.

[0061] Use the spectral class identifier of the identifier group corresponding to the target value as the target identifier;

[0062] Use the ratio of the perimeter area of ​​the first region to the identifier of the interval as the interval identifier;

[0063] Based on the multiple target identifiers, the interval identifiers, and the conditional probability equation, the probability of the first foreign object is determined, wherein the conditional probability equation is:

[0064]

[0065] In the formula, The probability of the first foreign object is... This represents the probability of a region being marked after a foreign object is detected. The first occurrence after the appearance of a foreign object The probability of a target identifier. The probability of a foreign object appearing. The probability of the interval identifier appearing. For the appearance of the first The probability of a target identifier.

[0066] In one possible implementation, the first region is obtained based on a visual image, including:

[0067] Obtain visual images;

[0068] The visual image is converted to grayscale to obtain a first grayscale image;

[0069] The first grayscale image is blurred using Gaussian blurring to obtain the second grayscale image;

[0070] The second grayscale image is convolved using horizontal edge extraction operators and vertical edge extraction operators to obtain horizontal edge feature maps and vertical edge feature maps, respectively.

[0071] A gradient magnitude synthesis operation is performed on the horizontal edge feature map and the vertical edge feature map to obtain a magnitude map;

[0072] Non-maximum suppression is applied to the amplitude map to obtain a first edge map;

[0073] A second edge map is obtained by performing dual threshold detection and edge connection on the first edge map;

[0074] Find closed edge lines from the second edge map, and use the area enclosed by the closed edge lines as the first area.

[0075] In a second aspect, embodiments of the present invention provide a foreign object warning device for implementing the foreign object warning method as described in the first aspect or any possible implementation thereof, the foreign object warning device comprising:

[0076] The target region acquisition module is used to acquire a first region, wherein a visual dividing line exists between the first region and other regions.

[0077] The spectral data dimensionality reduction module is used to reduce the dimensionality of multiple first spectral vectors through a dimensionality reduction transformation matrix to obtain multiple second spectral vectors. Each second spectral vector corresponds to a first spectral vector. The first spectral vector is obtained based on the first region and is constructed from multiple spectral values, each of which corresponds to a spectral wavelength.

[0078] The spectral data identification module is used to classify each second spectral vector according to the relationship between the second spectral vector and multiple spectral classes, and obtain multiple spectral class identifiers, wherein each spectral class identifier corresponds to a second spectral vector;

[0079] as well as,

[0080] The foreign object warning module is used to select multiple target identifiers from the multiple spectral identifiers, determine a first foreign object probability based on the multiple target identifiers, the perimeter-to-area ratio of the first region, and a conditional probability equation, and issue a warning based on the first foreign object probability. The proportion of the multiple target identifiers in the multiple spectral identifiers is greater than a first threshold, the perimeter-to-area ratio of the first region is determined based on the perimeter of the first region and the area of ​​the first region, and the first foreign object probability represents the probability that a foreign object exists in the first region.

[0081] Thirdly, embodiments of the present invention provide an electronic device, including a memory and a processor, wherein the memory stores a computer program executable on the processor, and the processor executes the computer program to implement the steps of the method as described in the first aspect or any possible implementation of the first aspect.

[0082] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method as described in the first aspect or any possible implementation thereof.

[0083] The beneficial effects of the embodiments of the present invention compared with the prior art are as follows:

[0084] This invention discloses a foreign object warning method. First, a first region is acquired, wherein a visual dividing line exists between the first region and other regions. Then, a dimensionality reduction matrix is ​​used to reduce the dimensionality of multiple first spectral vectors to obtain multiple second spectral vectors, where each second spectral vector corresponds to a first spectral vector. The first spectral vectors are obtained based on the first region and constructed from multiple spectral values, each corresponding to a spectral wavelength. Next, each second spectral vector is classified according to its relationship with multiple spectral classes to obtain multiple spectral class identifiers, where each spectral class identifier corresponds to a second spectral vector. Finally, multiple target identifiers are selected from the multiple spectral class identifiers. A first foreign object probability is determined based on the multiple target identifiers, the perimeter-to-area ratio of the first region, and a conditional probability equation. A warning is issued based on the first foreign object probability, wherein the proportion of the multiple target identifiers among the multiple spectral class identifiers is greater than a first threshold, the perimeter-to-area ratio of the first region is determined based on the perimeter and area of ​​the first region, and the first foreign object probability characterizes the probability of a foreign object existing in the first region. This invention extracts spectral data based on visually recognized regions, performs dimensionality reduction and classification on the spectral data, identifies the spectral state of a first region, and calculates the probability of the presence of a foreign object based on the spectral state and shape characteristics of the first region using conditional probability. This invention's method determines the risk of foreign objects based on data dimensionality reduction, classification, and statistics, improves the accuracy of foreign object warnings, and reduces the probability of false alarms when foreign objects are detected. Attached Figure Description

[0085] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0086] Figure 1 This is a flowchart of the foreign object early warning method provided in the embodiments of the present invention;

[0087] Figure 2 This is a schematic diagram illustrating the principle of spectral vector dimensionality reduction and classification process provided in the embodiments of the present invention;

[0088] Figure 3 This is a functional block diagram of the foreign object warning device provided in the embodiments of the present invention;

[0089] Figure 4 This is a functional block diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0090] In the following description, specific details such as particular system structures and techniques are set forth for illustrative purposes and not for limitation, so as to provide a thorough understanding of embodiments of the invention. However, those skilled in the art will understand that the invention can be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, and methods are omitted so as not to obscure the description of the invention with unnecessary detail.

[0091] To make the objectives, technical solutions, and advantages of the present invention clearer, specific embodiments will be described below in conjunction with the accompanying drawings.

[0092] The embodiments of the present invention will be described in detail below. This example is implemented based on the technical solution of the present invention, and provides detailed implementation methods and specific operation processes. However, the protection scope of the present invention is not limited to the following embodiments.

[0093] Figure 1 A flowchart of a foreign object early warning method provided for an embodiment of the present invention.

[0094] like Figure 1 As shown, a flowchart illustrating the implementation of the foreign object early warning method provided by an embodiment of the present invention is presented, and is described in detail below:

[0095] In step 101, a first region is obtained, wherein a visual dividing line exists between the first region and other regions.

[0096] In some implementations, the first region is obtained based on a visual image, including:

[0097] Obtain visual images;

[0098] The visual image is converted to grayscale to obtain a first grayscale image;

[0099] The first grayscale image is blurred using Gaussian blurring to obtain the second grayscale image;

[0100] The second grayscale image is convolved using horizontal edge extraction operators and vertical edge extraction operators to obtain horizontal edge feature maps and vertical edge feature maps, respectively.

[0101] A gradient magnitude synthesis operation is performed on the horizontal edge feature map and the vertical edge feature map to obtain a magnitude map;

[0102] Non-maximum suppression is applied to the amplitude map to obtain a first edge map;

[0103] A second edge map is obtained by performing dual threshold detection and edge connection on the first edge map;

[0104] Find closed edge lines from the second edge map, and use the area enclosed by the closed edge lines as the first area.

[0105] For example, the embodiments of the present invention are based on visual and spectral analysis of foreign objects. As mentioned above, the purpose is to overcome the disadvantages of low efficiency and high professional experience requirements of manual inspection. At the same time, compared with the traditional method of combining visual and spectral analysis of foreign objects, it reduces the possibility of false alarms.

[0106] In terms of technical implementation, this invention is based on visual analysis, which divides the acquired image into multiple regions. For each region, multiple spectral data of that region are extracted, and the overall state is labeled according to the spectral data. Based on the state label and the shape characteristics of the region itself, the probability of foreign object risk is output.

[0107] In fact, spectral data is a high-dimensional dataset, and, as... Figure 2 As shown, there are multiple spectral acquisition points within the first region 201, resulting in high-dimensionality and large-volume spectral data (each spectral acquisition point acquires a series of spectral values, forming a first spectral vector 202). Based on these characteristics, the curse of dimensionality occurs when labeling the state of the first region 201. In terms of spectral data processing, this invention first reduces the dimensionality of the first spectral vector 202 using a dimensionality reduction transformation matrix 203, forming a second spectral vector 204 with a smaller dimension. These second spectral vectors 204 are then classified using spectral classes 205 to obtain spectral class identifiers 206. In other words, the second spectral vectors 204 are classified using spectral classes 205. At this point, each spectral acquisition point corresponds to one identifier, and the first region 201 corresponds to multiple identifiers. Through these identifiers, we can obtain the state of the first region 201. Finally, based on the region state and the shape characteristics of the first region 201 itself, a probability equation is used to determine the risk probability.

[0108] Through the above process, we can see that the basic premise of this invention is to utilize visual images to analyze a large target area, dividing it into multiple regions, and then analyzing the risk of foreign objects in each of these regions. Regarding obtaining regions through visual images, this invention is based on extracting image edges, forming closed regions through these edges, and thus completing the division of the target area.

[0109] In its specific implementation, this invention first performs grayscale processing on the visual image. Then, it blurs the grayscale image using Gaussian blur (the purpose of which is to suppress noise in the image). Next, it performs convolution processing on the image using operators. This invention employs both horizontal and vertical operators to perform convolution processing on the blurred image. For example, in one scenario, the two operators are as follows:

[0110]

[0111] and

[0112]

[0113] The convolution process essentially extracts data blocks of the same type as the operator from the image, performs a dot product operation with the operator, and reconstructs the image from the dot product result. In other words, it yields horizontal and vertical edge feature maps, which extract the horizontal and vertical edge lines, respectively. These two edge feature maps are then combined into an amplitude map. For example, for a given pixel, the square root of the sum of the squares of the horizontal and vertical edge values ​​at that point is used to obtain the combined amplitude.

[0114]

[0115] In the above formula, For the synthesized amplitude, For horizontal edge values, This represents the vertical edge value.

[0116] After completing the synthesized amplitude map, non-maximum suppression and double threshold detection are performed on the image. Finally, the edges are connected to complete the construction of the edge map. Based on the edge map, closed edge lines are found in the image, and the area enclosed by the closed edge lines is taken as the first region.

[0117] In step 102, the multiple first spectral vectors are reduced in dimension by a dimension reduction transformation matrix to obtain multiple second spectral vectors. Each second spectral vector corresponds to a first spectral vector. The first spectral vector is obtained based on the first region and is constructed based on multiple spectral values, each of which corresponds to a spectral wavelength.

[0118] In some implementations, the dimensionality reduction transformation matrix is ​​obtained based on a plurality of first sample spectral vectors, including:

[0119] Multiple first sample spectral vectors are obtained, wherein the first sample spectral vectors are constructed based on multiple spectral values, and each spectral value corresponds to a spectral wavelength;

[0120] Each of the plurality of first sample spectral vectors is standardized to obtain a plurality of second sample spectral vectors;

[0121] The second spectral vectors of the multiple samples are used to construct a sample vector matrix;

[0122] The covariance of the matrix elements is calculated based on the sample vector matrix to obtain the first matrix;

[0123] Based on the first matrix, multiple eigenvalues ​​and multiple eigenvectors are determined, wherein each eigenvalue corresponds to one eigenvector;

[0124] The plurality of feature values ​​are sorted in order of value size, and a plurality of target feature values ​​are found from the sorting, wherein the ratio of the sum of the plurality of target feature values ​​to the sum of the plurality of feature values ​​is greater than a first ratio threshold.

[0125] Use the eigenvectors corresponding to the target eigenvalues ​​as the target eigenvectors;

[0126] Multiple target feature vectors are constructed into a dimension reduction transformation matrix.

[0127] In some implementations, standardizing each of the plurality of first sample spectral vectors to obtain a plurality of second sample spectral vectors includes:

[0128] Spectral wavelengths are sequentially selected from multiple spectral wavelengths as the wavelengths to be converted;

[0129] Multiple spectral values ​​are extracted from the multiple first sample spectral vectors according to the wavelength to be converted, and used as multiple first intermediate spectral values;

[0130] Calculate the mean and standard deviation of the plurality of first intermediate spectral values, and use them as the first mean and the first standard deviation;

[0131] Based on the plurality of first intermediate spectral values, the first mean, the first standard deviation, and the first formula, a plurality of second intermediate spectral values ​​are determined, wherein the first formula is:

[0132]

[0133] In the formula, This is the second intermediate spectral value. This is the first intermediate spectral value. The first mean, The first standard deviation;

[0134] The plurality of second intermediate spectral values ​​are respectively added as vector elements to the plurality of second sample spectral vectors;

[0135] If the traversal of multiple spectral wavelengths is not completed, the process jumps to the step of sequentially extracting spectral wavelengths from multiple spectral wavelengths as the wavelengths to be converted.

[0136] The step of reducing the dimensionality of multiple first spectral vectors using a dimensionality reduction transformation matrix to obtain multiple second spectral vectors includes:

[0137] Multiple first spectral vectors are reduced in dimension using the second formula and the dimension reduction transformation matrix to obtain multiple second spectral vectors, wherein the second formula is:

[0138]

[0139] In the formula, The second spectral vector, The first spectral vector, This is the dimension reduction transformation matrix. For the first Target feature vectors.

[0140] For example, as mentioned earlier, spectral data has high dimensionality, with significant discrepancies between data points, making operations such as classification difficult. This invention reduces the dimensionality of spectral data—specifically, the first spectral vector—using a dimensionality reduction transformation matrix. More specifically, it uses a second formula to reduce the dimensionality:

[0141]

[0142] In the formula, The second spectral vector, The first spectral vector, This is the dimension reduction transformation matrix. For the first Target feature vectors.

[0143] The dimensionality reduction transformation matrix is ​​essentially a matrix constructed from eigenvectors. Its purpose is to remove redundant dimensions in the data dimension and ensure the orthogonality of the data dimension. For this application, the spectral vectors after dimensionality reduction through the dimensionality reduction transformation matrix are intuitively perceived as having reduced distance between vectors.

[0144] The eigenvectors and dimensionality transformation matrix are constructed from multiple first-sample spectral vectors. In fact, redundant terms in the data dimensions can be found from these multiple first-sample spectral vectors, thus forming a dimensionality reduction transformation matrix.

[0145] In terms of specific implementation, firstly, each dimension of the first spectral vector is standardized. Specifically, for each dimension, the data from multiple first spectral vectors are extracted, the mean and standard deviation of the extracted spectral values ​​are calculated, and the data for that dimension is standardized using the first formula:

[0146]

[0147] In the formula, This is the second intermediate spectral value. This is the first intermediate spectral value. The first mean, This is the first standard deviation.

[0148] After standardizing the above dimensions, data is extracted from the next dimension, the mean and standard deviation are calculated, and the data of the next dimension is standardized using the above formula. This process is repeated until all dimensions are standardized. The standardized dimensional data are then recombined to form the second spectral vector.

[0149] The second spectral vector is used as rows or columns to construct a sample vector matrix. Then, the covariance is calculated using the covariance calculation equation to obtain the covariance matrix (the first matrix).

[0150]

[0151] In the above formula, This is the covariance matrix (the first matrix). Let be the dimension of the first spectral vector. This is the sample vector matrix.

[0152] Then, calculate multiple eigenvalues ​​and multiple feature vectors of the first matrix. From the multiple eigenvalues, select multiple target eigenvalues ​​from the largest to the smallest. If the ratio of the sum of these multiple target eigenvalues ​​to the sum of the multiple eigenvalues ​​is greater than the ratio threshold, the remaining eigenvalues ​​are deleted. Since there is a one-to-one relationship between eigenvalues ​​and eigenvectors, multiple target feature vectors can be found based on the multiple target eigenvalues. These multiple feature vectors are then used to construct a dimension reduction transformation matrix.

[0153] In step 103, each second spectral vector is classified according to the relationship between the second spectral vector and multiple spectral classes to obtain multiple spectral class identifiers, wherein each spectral class identifier corresponds to a second spectral vector.

[0154] In some implementations, the plurality of spectral classes are constructed based on a plurality of third-sample spectral vectors, including:

[0155] Obtain the first preset distance, the number of reference samples, and multiple third sample spectral vectors. Each third sample spectral vector corresponds to an initial sample spectral vector. The third sample spectral vector is obtained by dimensionality reduction of the initial sample spectral vector through a dimensionality reduction transformation matrix. The initial sample spectral vector is constructed based on multiple spectral values, each of which corresponds to a spectral wavelength.

[0156] For each third sample spectral vector, calculate the first distance value to each other third sample spectral vector, and construct a distance dataset from the multiple first distance values ​​obtained.

[0157] The distance dataset with the number of target elements exceeding the number of reference samples is taken as the starting point dataset, and the third sample spectral vector corresponding to the starting point dataset is taken as the starting point spectral vector. The target element is the element in the dataset whose value is less than the first preset distance.

[0158] The vector taken from the multiple starting point spectral vectors that have not been clustered is used as the clustering vector;

[0159] In the unclustered third sample spectral vector, find the target vector, where the target vector is the vector whose distance from the current cluster vector is less than the first preset distance;

[0160] If a target vector exists, the target vector is added to the class where the clustering vector is located, the target vector is used as the clustering vector, and the process jumps to the third sample spectral vector that has not been clustered to find the target vector.

[0161] Otherwise, if there are unclustered starting point spectral vectors, then jump to the step of extracting the vector from the multiple unclustered starting point spectral vectors as the clustering vector;

[0162] Delete the spectral vectors of the third sample that have not completed clustering, as well as the classes whose number of vectors is less than the threshold for the number of classes;

[0163] The remaining classes are designated as the plurality of spectral classes.

[0164] In some implementations, classifying each second spectral vector based on its relationship with multiple spectral classes to obtain multiple spectral class identifiers includes:

[0165] The vectors are iteratively selected from the plurality of second spectral vectors as vectors to be classified, and the following steps are performed after each selection:

[0166] Calculate the distance between the vector to be classified and each of the multiple class vectors to obtain multiple second distance values, where the class vectors are vectors in the multiple spectral classes;

[0167] Use the minimum value among multiple second distance values ​​as the classification distance value;

[0168] If the classification distance value is less than the first preset distance, then the class vector corresponding to the classification distance value is taken as the nearest vector, and the identifier of the class in which the nearest vector is located is taken as the spectral class identifier of the vector to be classified.

[0169] Otherwise, an empty identifier is used as the spectral class identifier for the vector to be classified.

[0170] For example, as mentioned earlier, the dimensionality-reduced spectral vectors appear to be closer together. In fact, the effect of bringing them closer together is even more pronounced for vectors with similar characteristics.

[0171] For the second spectral vector obtained in the aforementioned steps, the second spectral vector is classified according to its relationship with the spectral class, and a spectral class identifier is assigned to the second spectral vector according to the classification result (each spectral class has a unique identifier in order to distinguish spectral classes).

[0172] The spectral class is obtained by clustering the third sample spectral vector. The third sample spectral vector is obtained in the same way as the second spectral vector, which is obtained by reducing the dimensionality of the initial sample spectral vector with multiple dimensions through a dimensionality reduction transformation matrix.

[0173] Regarding the construction of spectral clusters, this invention first analyzes each third sample spectral vector to find a spectral vector that can be used as a starting point. Specifically, in one approach, it finds third sample spectral vectors that are close to each other as starting points.

[0174] Then, a vector is randomly selected from the unclustered starting point spectral vectors as the clustering vector. Vectors in the unclustered vectors that are less than the distance threshold from this clustering vector are assigned to the class to which the clustering vector belongs. The newly added vectors are then used as the clustering vectors, and the above vector assignment steps are repeated until there are no vectors in the unclustered vectors that meet the distance threshold condition.

[0175] If there are still some unclustered starting point spectral vectors, then randomly select a vector from the unclustered starting point spectral vectors as the clustering vector, and repeat the above steps.

[0176] Once all starting spectral vectors have been clustered, the clustering process is considered complete. At this point, some vectors will not have been clustered at all, and these vectors will be deleted as noise data. Another group will be clustered, but if the number of vectors in this group is small (e.g., the average number of vectors in this group is less than a threshold), this group will also be deleted.

[0177] The remaining classes will be designated as spectral classes, and each spectral class will be assigned a unique spectral class identifier to distinguish it from other spectral classes.

[0178] Regarding the allocation of spectral class identifiers for the second spectral vector using spectral classes, this invention allocates them based on the principle of closest distance. Specifically, the second spectral vector will calculate the distance with the third sample spectral vector obtained after the above clustering. If the minimum calculated distance is less than the distance threshold used during clustering, then the second spectral vector will be assigned to the class where the third sample spectral vector with the minimum distance is located, and the identifier of that class will be used as the identifier of the second spectral vector.

[0179] If the calculated minimum distance is greater than the distance threshold used in clustering, then this second spectral vector will be assigned a null identifier to indicate that the second spectral vector is far away from the vectors in the class.

[0180] In step 104, multiple target identifiers are selected from the multiple spectral identifiers. A first foreign object probability is determined based on the multiple target identifiers, the perimeter-to-area ratio of the first region, and the conditional probability equation. An early warning is issued based on the first foreign object probability. The proportion of the multiple target identifiers in the multiple spectral identifiers is greater than a first threshold. The perimeter-to-area ratio of the first region is determined based on the perimeter of the first region and the area of ​​the first region. The first foreign object probability represents the probability that a foreign object exists in the first region.

[0181] In some implementations, selecting multiple target identifiers from the plurality of spectral identifiers and determining the first foreign object probability based on the plurality of target identifiers, the perimeter-to-area ratio of the first region, and a conditional probability equation includes:

[0182] Obtain the second proportional threshold;

[0183] Group the identical identifiers among the multiple spectral class identifiers into a group to obtain multiple identifier groups;

[0184] The number of icons in the icon group is taken as the number of icons;

[0185] Multiple values ​​are selected from the number of identifiers in descending order to serve as multiple target values, wherein the ratio of the sum of the multiple target values ​​to the sum of the number of identifiers is greater than the second ratio threshold.

[0186] Use the spectral class identifier of the identifier group corresponding to the target value as the target identifier;

[0187] Use the ratio of the perimeter area of ​​the first region to the identifier of the interval as the interval identifier;

[0188] Based on the multiple target identifiers, the interval identifiers, and the conditional probability equation, the probability of the first foreign object is determined, wherein the conditional probability equation is:

[0189]

[0190] In the formula, The probability of the first foreign object is... This represents the probability of a region being marked after a foreign object is detected. The first occurrence after the appearance of a foreign object The probability of a target identifier. The probability of a foreign object appearing. The probability of the interval identifier appearing. For the appearance of the first The probability of a target identifier.

[0191] For example, in practice, through the above steps, we can know that the target identifier indicates the category of the spectrum of the spectral acquisition point. As mentioned above, the present invention is based on multiple target identifiers indicating the status label of the first region, and then based on the status label and the shape characteristics of the first region, the probability of foreign object risk is obtained.

[0192] Regarding the status label for the first region, this invention groups identical spectral identifiers obtained in the aforementioned steps and counts the number of identifiers, thus obtaining the number of multiple identifiers. From these multiple identifier counts, a number of identifiers are selected in descending order of quantity, such that the ratio of the sum of the selected counts to the total sum of the identifier counts is greater than a threshold, for example, greater than 85%. The spectral identifiers corresponding to the selected counts are then used as the status labels representing the first region.

[0193] For example, among the six spectral categories a, b, c, d, e, and f, categories a, c, and e account for 91% of the total number of categories. Therefore, categories a, c, and e represent the spectral state of the first region.

[0194] At the same time, the ratio of the perimeter to the area of ​​the first region is assigned to the corresponding perimeter-area ratio interval, and the corresponding interval is used as the interval identifier.

[0195] At this point, the probability of a foreign object can be calculated using the conditional probability equation:

[0196]

[0197] In the formula, The probability of the first foreign object is... This represents the probability of a region being marked after a foreign object is detected. The first occurrence after the appearance of a foreign object The probability of a target identifier. The probability of a foreign object appearing. The probability of the interval identifier appearing. For the appearance of the first The probability of a target identifier.

[0198] Finally, based on the probability of a foreign object, a foreign object warning message is output.

[0199] The foreign object warning method of the present invention first acquires a first region, wherein a visual dividing line exists between the first region and other regions; then, it reduces the dimensionality of multiple first spectral vectors using a dimensionality reduction transformation matrix to obtain multiple second spectral vectors, wherein each second spectral vector corresponds to a first spectral vector, the first spectral vectors are obtained based on the first region, and the first spectral vectors are constructed based on multiple spectral values, each spectral value corresponding to a spectral wavelength; next, it classifies each second spectral vector according to the relationship between the second spectral vector and multiple spectral classes to obtain multiple spectral class identifiers, wherein each spectral class identifier corresponds to a second spectral vector; finally, it selects multiple target identifiers from the multiple spectral class identifiers, determines a first foreign object probability based on the multiple target identifiers, the perimeter-to-area ratio of the first region, and a conditional probability equation, and issues a warning based on the first foreign object probability, wherein the proportion of the multiple target identifiers in the multiple spectral class identifiers is greater than a first threshold, the perimeter-to-area ratio of the first region is determined based on the perimeter and area of ​​the first region, and the first foreign object probability characterizes the probability of the presence of a foreign object in the first region. This invention extracts spectral data based on visually recognized regions, performs dimensionality reduction and classification on the spectral data, identifies the spectral state of a first region, and calculates the probability of the presence of a foreign object based on the spectral state and shape characteristics of the first region using conditional probability. This invention's method determines the risk of foreign objects based on data dimensionality reduction, classification, and statistics, improves the accuracy of foreign object warnings, and reduces the probability of false alarms when foreign objects are detected.

[0200] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0201] The following are embodiments of the apparatus of the present invention. For details not described in detail, please refer to the corresponding method embodiments described above.

[0202] Figure 3 This is a functional block diagram of the foreign object warning device provided in the embodiments of the present invention, with reference to... Figure 3 The foreign object warning device includes: a target area acquisition module 301, a spectral data dimensionality reduction module 302, a spectral data identification module 303, and a foreign object warning module 304, wherein:

[0203] The target region acquisition module 301 is used to acquire a first region, wherein there is a visual dividing line between the first region and other regions.

[0204] The spectral data dimensionality reduction module 302 is used to reduce the dimensionality of multiple first spectral vectors through a dimensionality reduction transformation matrix to obtain multiple second spectral vectors. Each second spectral vector corresponds to a first spectral vector. The first spectral vector is obtained based on the first region and is constructed based on multiple spectral values, each spectral value corresponding to a spectral wavelength.

[0205] The spectral data identification module 303 is used to classify each second spectral vector according to the relationship between the second spectral vector and multiple spectral classes to obtain multiple spectral class identifiers, wherein each spectral class identifier corresponds to a second spectral vector;

[0206] The foreign object warning module 304 is used to select multiple target identifiers from the multiple spectral identifiers, determine a first foreign object probability based on the multiple target identifiers, the perimeter-to-area ratio of the first region, and a conditional probability equation, and issue a warning based on the first foreign object probability. The proportion of the multiple target identifiers in the multiple spectral identifiers is greater than a first threshold, the perimeter-to-area ratio of the first region is determined based on the perimeter of the first region and the area of ​​the first region, and the first foreign object probability represents the probability that a foreign object exists in the first region.

[0207] Figure 4 This is a functional block diagram of the electronic device provided in an embodiment of the present invention. For example... Figure 4 As shown, the electronic device 4 of this embodiment includes a processor 400 and a memory 401, wherein the memory 401 stores a computer program 402 that can run on the processor 400. When the processor 400 executes the computer program 402, it implements the steps of the various foreign object warning methods and embodiments described above, for example... Figure 1 Steps 101 to 104 are shown.

[0208] For example, the computer program 402 may 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 invention.

[0209] The electronic device 4 can be a desktop computer, laptop, handheld computer, cloud server, or other computing device. The electronic device 4 may include, but is not limited to, a processor 400 and a memory 401. Those skilled in the art will understand that... Figure 4 This is merely an example of electronic device 4 and does not constitute a limitation on electronic device 4. It may include more or fewer components than shown, or combine certain components, or different components. For example, electronic device 4 may also include input / output devices, network access devices, buses, etc.

[0210] The processor 400 may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.

[0211] The memory 401 can be an internal storage unit of the electronic device 4, such as a hard disk or memory. The memory 401 can also be an external storage device of the electronic device 4, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card. Furthermore, the memory 401 can include both internal and external storage units 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.

[0212] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the aforementioned method embodiments, and will not be repeated here.

[0213] In the above embodiments, the descriptions of each embodiment have their own emphasis. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0214] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0215] In the embodiments provided by this invention, it should be understood that the disclosed devices / electronic devices and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0216] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.

[0217] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0218] If the integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the above-described embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various methods and apparatus embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.

[0219] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.

Claims

1. A foreign object early warning method, characterized in that, include: Obtain a first region, wherein a visual dividing line exists between the first region and other regions; Multiple first spectral vectors are reduced in dimension by a dimension reduction transformation matrix to obtain multiple second spectral vectors. Each second spectral vector corresponds to a first spectral vector. The first spectral vectors are obtained based on the first region and are constructed from multiple spectral values, each of which corresponds to a spectral wavelength. Each second spectral vector is classified according to its relationship with multiple spectral classes to obtain multiple spectral class identifiers, where each spectral class identifier corresponds to a second spectral vector; Multiple target identifiers are selected from the plurality of spectral identifiers. Based on the plurality of target identifiers, the perimeter-to-area ratio of the first region, and the conditional probability equation, a first foreign object probability is determined, including: Obtain the second proportional threshold; Group the identical identifiers among the multiple spectral class identifiers into a group to obtain multiple identifier groups; The number of icons in the icon group is taken as the number of icons; Multiple values ​​are selected from the number of identifiers in descending order to serve as multiple target values, wherein the ratio of the sum of the multiple target values ​​to the sum of the number of identifiers is greater than the second ratio threshold. The spectral class identifier of the identifier group corresponding to the target value is used as the target identifier, wherein the proportion of the multiple target identifiers in the multiple spectral class identifiers is greater than a first threshold, and the perimeter-area ratio of the first region is determined based on the perimeter of the first region and the area of ​​the first region; Use the ratio of the perimeter area of ​​the first region to the identifier of the interval as the interval identifier; Based on the multiple target identifiers, the interval identifiers, and the conditional probability equation, a first foreign object probability is determined, wherein the first foreign object probability represents the probability that a foreign object exists in the first region, and the conditional probability equation is: In the formula, The probability of the first foreign object is... This represents the probability of a region being marked after a foreign object is detected. The first occurrence after the appearance of a foreign object The probability of a target identifier. The probability of a foreign object appearing. The probability of the interval identifier appearing. For the appearance of the first The probability of a target identifier; Based on the first foreign object probability warning.

2. The foreign object early warning method according to claim 1, characterized in that, The dimensionality reduction transformation matrix is ​​obtained based on multiple first sample spectral vectors, including: Multiple first sample spectral vectors are obtained, wherein the first sample spectral vectors are constructed based on multiple spectral values, and each spectral value corresponds to a spectral wavelength; Each of the plurality of first sample spectral vectors is standardized to obtain a plurality of second sample spectral vectors; The plurality of second sample spectral vectors are constructed into a sample vector matrix; The covariance of the matrix elements is calculated based on the sample vector matrix to obtain the first matrix; Based on the first matrix, multiple eigenvalues ​​and multiple eigenvectors are determined, wherein each eigenvalue corresponds to one eigenvector; The plurality of feature values ​​are sorted in order of value size, and a plurality of target feature values ​​are found from the sorting, wherein the ratio of the sum of the plurality of target feature values ​​to the sum of the plurality of feature values ​​is greater than a first ratio threshold. Use the eigenvectors corresponding to the target eigenvalues ​​as the target eigenvectors; Multiple target feature vectors are constructed into a dimension reduction transformation matrix.

3. The foreign object early warning method according to claim 2, characterized in that, The step of standardizing each of the plurality of first sample spectral vectors to obtain a plurality of second sample spectral vectors includes: Spectral wavelengths are sequentially selected from multiple spectral wavelengths as the wavelengths to be converted; Multiple spectral values ​​are extracted from the multiple first sample spectral vectors according to the wavelength to be converted, and used as multiple first intermediate spectral values; Calculate the mean and standard deviation of the plurality of first intermediate spectral values, and use them as the first mean and the first standard deviation; Based on the plurality of first intermediate spectral values, the first mean, the first standard deviation, and the first formula, a plurality of second intermediate spectral values ​​are determined, wherein the first formula is: In the formula, This is the second intermediate spectral value. This is the first intermediate spectral value. The first mean, The first standard deviation; The plurality of second intermediate spectral values ​​are respectively added as vector elements to the plurality of second sample spectral vectors; If the traversal of multiple spectral wavelengths is not completed, the process jumps to the step of sequentially extracting spectral wavelengths from multiple spectral wavelengths as the wavelengths to be converted. The step of reducing the dimensionality of multiple first spectral vectors using a dimensionality reduction transformation matrix to obtain multiple second spectral vectors includes: Multiple first spectral vectors are reduced in dimension using the second formula and the dimension reduction transformation matrix to obtain multiple second spectral vectors, wherein the second formula is: In the formula, The second spectral vector, The first spectral vector, This is the dimension reduction transformation matrix. For the first Target feature vectors.

4. The foreign object early warning method according to claim 1, characterized in that, The multiple spectral classes are constructed based on multiple third-sample spectral vectors, including: Obtain the first preset distance, the number of reference samples, and multiple third sample spectral vectors. Each third sample spectral vector corresponds to an initial sample spectral vector. The third sample spectral vector is obtained by dimensionality reduction of the initial sample spectral vector through a dimensionality reduction transformation matrix. The initial sample spectral vector is constructed based on multiple spectral values, each of which corresponds to a spectral wavelength. For each third sample spectral vector, calculate the first distance value to each other third sample spectral vector, and construct a distance dataset from the multiple first distance values ​​obtained. The distance dataset with the number of target elements exceeding the number of reference samples is taken as the starting point dataset, and the third sample spectral vector corresponding to the starting point dataset is taken as the starting point spectral vector. The target element is the element in the dataset whose value is less than the first preset distance. The vector taken from the multiple starting point spectral vectors that have not been clustered is used as the clustering vector; In the unclustered third sample spectral vector, find the target vector, where the target vector is the vector whose distance from the current cluster vector is less than the first preset distance; If a target vector exists, the target vector is added to the class where the clustering vector is located, the target vector is used as the clustering vector, and the process jumps to the third sample spectral vector that has not been clustered to find the target vector. Otherwise, if there are unclustered starting point spectral vectors, then jump to the step of extracting the vector from the multiple unclustered starting point spectral vectors as the clustering vector; Delete the spectral vectors of the third sample that have not completed clustering, as well as the classes whose number of vectors is less than the threshold for the number of classes; The remaining classes are designated as the plurality of spectral classes.

5. The foreign object early warning method according to claim 4, characterized in that, The step of classifying each second spectral vector based on its relationship with multiple spectral classes to obtain multiple spectral class identifiers includes: The vectors are iteratively selected from the plurality of second spectral vectors as vectors to be classified, and the following steps are performed after each selection: Calculate the distance between the vector to be classified and each of the multiple class vectors to obtain multiple second distance values, where the class vectors are vectors in the multiple spectral classes; Use the minimum value among multiple second distance values ​​as the classification distance value; If the classification distance value is less than the first preset distance, then the class vector corresponding to the classification distance value is taken as the nearest vector, and the identifier of the class in which the nearest vector is located is taken as the spectral class identifier of the vector to be classified. Otherwise, an empty identifier is used as the spectral class identifier for the vector to be classified.

6. The foreign object early warning method according to any one of claims 1-5, characterized in that, The first region is obtained based on a visual image and includes: Obtain visual images; The visual image is converted to grayscale to obtain a first grayscale image; The first grayscale image is blurred using Gaussian blurring to obtain the second grayscale image; The second grayscale image is convolved using horizontal edge extraction operators and vertical edge extraction operators to obtain horizontal edge feature maps and vertical edge feature maps, respectively. A gradient magnitude synthesis operation is performed on the horizontal edge feature map and the vertical edge feature map to obtain a magnitude map; Non-maximum suppression is applied to the amplitude map to obtain a first edge map; A second edge map is obtained by performing dual threshold detection and edge connection on the first edge map; Find closed edge lines from the second edge map, and use the area enclosed by the closed edge lines as the first area.

7. A foreign object warning device, characterized in that, For implementing the foreign object warning method as described in any one of claims 1-6, the foreign object warning device comprises: The target region acquisition module is used to acquire a first region, wherein a visual dividing line exists between the first region and other regions. The spectral data dimensionality reduction module is used to reduce the dimensionality of multiple first spectral vectors through a dimensionality reduction transformation matrix to obtain multiple second spectral vectors. Each second spectral vector corresponds to a first spectral vector. The first spectral vector is obtained based on the first region and is constructed from multiple spectral values, each of which corresponds to a spectral wavelength. The spectral data identification module is used to classify each second spectral vector according to the relationship between the second spectral vector and multiple spectral classes, and obtain multiple spectral class identifiers, wherein each spectral class identifier corresponds to a second spectral vector; as well as, The foreign object warning module is used to select multiple target identifiers from the multiple spectral identifiers, determine a first foreign object probability based on the multiple target identifiers, the perimeter-to-area ratio of the first region, and a conditional probability equation, and issue a warning based on the first foreign object probability. The proportion of the multiple target identifiers in the multiple spectral identifiers is greater than a first threshold, the perimeter-to-area ratio of the first region is determined based on the perimeter of the first region and the area of ​​the first region, and the first foreign object probability represents the probability that a foreign object exists in the first region.

8. 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 6 above.

9. 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 6 above.

Citation Information

Patent Citations

  • A hyperspectral target detection method based on conditional random projection

    CN109784142A

  • Hyperspectral target detection method, system, device and medium

    CN118229955A