A hyperspectral image classification method, device, electronic device and storage medium
By introducing probabilistic distribution and contrast loss function in hyperspectral image classification, the uncertainty of pixels is modeled, the label uncertainty problem is solved, the classification accuracy and robustness are improved, and efficient hyperspectral image classification is achieved. .
Patent Information
- Application Number
- CN202111602641.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-24
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2041-12-24
AI Technical Summary
Existing hyperspectral image classification methods easily introduce label uncertainty problems when using spatial neighbor information to reduce spectral dimension uncertainty, especially in the case of low spatial resolution and mixed pixels, leading to uncertainty in the classification results.
The structure of probabilistic distribution is used to model the uncertainty of neighboring pixels and central pixels in the embedding space, and the distribution parameters are constrained by the probabilistic contrast loss function to reduce the impact of label uncertainty on image classification. Specific methods include using convolutional neural networks to extract image features, constructing mean and variance networks, and optimizing classification results through Monte Carlo sampling and cross-entropy loss functions.
It effectively reduces the impact of label uncertainty in image classification, improves classification accuracy and model robustness, and can reach or exceed the performance of existing methods on existing data sets.
Smart Images

Figure CN114417976B
Abstract
Description
Technical Field
[0001] The present disclosure relates to computer vision and aerial remote sensing technology, and in particular to a hyperspectral image classification method, device, electronic device and storage medium. Background Art
[0002] Hyperspectral remote sensing can capture rich ground information with hundreds of fine and continuous spectral bands. Among them, hyperspectral image classification classifies each pixel in the image, which is an important task in hyperspectral remote sensing. Hyperspectral image classification methods include traditional machine learning methods and deep learning methods. Among them, machine learning methods use artificially extracted image features for modeling. For example, Blanzier et al. used the k-nearest neighbor method to measure the similarity between hyperspectral samples. Melgani et al. introduced support vector machines into the study of hyperspectral classification, which attracted widespread attention at the time. Sun et al. used active learning methods to further improve the performance of hyperspectral classification. Hyperspectral classification methods based on deep learning use the structure of deep neural networks to automatically extract features from images for modeling, and they occupy a dominant position in the field of hyperspectral classification today. For example, one-dimensional convolutional neural networks, recurrent neural networks, and generative discriminant networks are all used to capture rich information in hyperspectral images, and improve classification effects by strengthening the model's modeling and representation capabilities for images.
[0003] Due to factors such as natural spectral differences, hyperspectral instrument noise, and atmospheric influences, there is uncertainty in the spectral dimension in hyperspectral images, namely the phenomenon of "same object, different spectrum" and "different objects, same spectrum". Therefore, existing methods focus on simultaneously considering the spatial dimension information and spectral dimension information in the image to reduce the impact of spectral uncertainty. For example, Sun et al. used weighted Markov random fields to supervise the spectral and spatial hyperspectral classification training. Li et al. further integrated the Markov random field into the support vector machine structure to improve the model representation ability. Fang et al. used multi-scale sparse representation to simultaneously consider the spectral and spatial dimension information. In order to extract and represent image features more efficiently, Yang et al. proposed a three-dimensional convolutional neural network structure that simultaneously processes the spatial and spectral information in the image by inputting image blocks. Paoletti et al. constructed a pyramid-shaped deep residual network structure to represent the spectral and spatial dimension information. He et al. specifically designed a multi-scale covariance projection method to extract spatial information. In addition, researchers have used the model structure based on the attention mechanism that has been popular in the field of computer vision in recent years to the hyperspectral image classification task. For example, Sun et al. considered the attention weights of both spatial and spectral dimensions to perform classification tasks. Yu et al. proposed a feedback-based dense convolutional neural network structure based on the attention mechanism to enhance the model's ability to process hyperspectral images.
[0004] The above methods enhance the confidence of the hyperspectral classification model by considering spatial information, which is similar to the idea of ensemble learning. However, since hyperspectral images often have low spatial resolution, neighboring pixels may contain different ground object information from the central pixel, and the central pixel may also have multiple different ground object features, forming mixed pixels. Therefore, directly incorporating spatial information into the model may bring uncertainty to the label information (the input image block has different ground object information, but the label is a single category). Summary of the invention
[0005] The purpose of the present disclosure is to overcome the shortcomings of the existing technology and propose a hyperspectral image classification method, device, electronic device and storage medium. The present disclosure solves the problem that in the existing hyperspectral image classification method that considers both spatial and spectral dimensions, while using spatial neighbor information to reduce the influence of spectral dimension uncertainty, the label uncertainty of neighbor pixels is introduced. A probabilistic distribution structure is proposed to introduce modeling of the uncertainty of neighbor pixels and center pixels in the embedding space, and a probabilistic contrast loss function is used to constrain the distribution parameters in the embedding space, thereby reducing the adverse effects of label uncertainty in the space on image classification.
[0006] The first embodiment of the present disclosure provides a hyperspectral image classification method, comprising:
[0007] Inputting the hyperspectral image to be classified into a preset convolutional neural network to obtain image features of the hyperspectral image;
[0008] Using the image features, according to a preset mean network, a mean matrix corresponding to the image features is obtained;
[0009] The probability values of the hyperspectral image corresponding to each category are calculated according to the mean matrix, and the category corresponding to the maximum value of the probability value is used as the classification result of the hyperspectral image.
[0010] In a specific embodiment of the present disclosure, the probability value of each category corresponding to the hyperspectral image is calculated according to the mean matrix, and the expression is as follows:
[0011]
[0012] Wherein, the hyperspectral image is denoted as x i , k represents the kth category label, M i Represents x i The mean matrix corresponding to the image features, f l (M i ) represents the mean matrix M i A linear mapping such that M i The dimension of f is equal to the total number of categories, l(M i ) k Represents f l (M i ) in the kth component value, y i Represents x i The classification result, N represents the total number of categories.
[0013] In a specific embodiment of the present disclosure, before inputting the hyperspectral image to be classified into a preset convolutional neural network to obtain the image features of the hyperspectral image, the method further includes:
[0014] Training the convolutional neural network and the mean network;
[0015] The training of the convolutional neural network and the mean network comprises:
[0016] Get the training dataset;
[0017] Construct a convolutional neural network and initialize it randomly;
[0018] Constructing a mean network and a variance network, and connecting the mean network and the variance network after the convolutional neural network respectively;
[0019] The convolutional neural network, the mean network and the variance network are trained using the training data set to obtain the trained convolutional neural network, the mean network and the variance network.
[0020] In a specific embodiment of the present disclosure, the convolutional neural network includes a spectral feature extraction unit and a spatial feature extraction unit connected in sequence; wherein the spectral feature extraction unit and the spatial extraction unit are each formed by connecting two residual modules, and each residual module is composed of two convolutional layers.
[0021] In a specific embodiment of the present disclosure, the mean network and the variance network are composed of a fully connected layer with the same structure.
[0022] In a specific embodiment of the present disclosure, the using the training data set to train the convolutional neural network, the mean network and the variance network to obtain the trained convolutional neural network, the mean network and the variance network includes:
[0023] 1) Image feature extraction;
[0024] Each image x in the training dataset i Input the current convolutional neural network and use the current convolutional neural network to extract the corresponding image features f i ;
[0025] 2) Use the current mean network and variance network to construct the mean mean matrix and variance matrix corresponding to the image features, as shown below:
[0026]
[0027]
[0028] Among them, f i For x i image features, g1 and g2 represent the mapping of the mean network and variance network to the input image features, respectively. i For the corresponding f i The mean matrix, m i j is the mean matrix M i The mean vector corresponding to the jth pixel in V i For the corresponding f i The variance matrix, v i j is the variance matrix V i The variance vector corresponding to the j-th pixel in , T represents the number of pixels in the input image;
[0029] 3) Increase the variance of peripheral pixels in image features by constraining the loss function;
[0030] Among them, for the image feature f i The constraint loss function constructed for the pixels of the jth circle is as follows:
[0031]
[0032]
[0033] Among them, α is the set increase ratio value, n j Represents the number of pixels in the jth circle when the center pixel of the image feature is the first circle;
[0034] 4) Using the Monte Carlo strategy to sample each pixel of the image feature, the category label of each sample obtained is the same as the category label of the central pixel of the image feature;
[0035] 5) Using the samples obtained by sampling, the matching probability between samples is calculated, the matching probability between pixels to which the samples belong is obtained, and the probabilistic contrast loss function between pixels is calculated;
[0036] For any two samples z i and z j , the matching probability calculation expression is as follows:
[0037] p(z i , z j)=σ(-aD ij +b)
[0038]
[0039] Among them, D ij is the sample z i and z j The Euclidean distance between them, a>0 and b are the parameters representing the Euclidean distance threshold;
[0040] Calculate the matching probability between the pixels to which the samples belong. The expression is as follows:
[0041]
[0042] Among them, p1 and p2 are any two pixels in the image features. is the k1th sampling sample of pixel p1, is the k2th sampling sample of pixel p2, where K is the number of sampling times;
[0043] Calculate the probabilistic contrast loss function between pixels:
[0044]
[0045] In the formula, match means that the two pixels belong to the same category;
[0046] 6) Use softmax function for classification;
[0047] Calculate image x i The probability value corresponding to each category:
[0048]
[0049] Among them, k represents the k-th category label, f l (M i ) represents the mean matrix M i A linear mapping that makes M i The dimension of f is equal to the total number of categories, l (M i ) k Represents f l (M i ) in the kth component value, y i Represents x i The classification result, N represents the total number of categories;
[0050] 7) Calculate the cross entropy loss function of the current training:
[0051]
[0052] The hyperspectral classification optimization objective is as follows:
[0053] J PDML =J dist +λ3J ce
[0054] in,
[0055]
[0056] Among them, λ1, λ2 and λ3 are coefficients used to balance the impact of each loss function on the overall optimization goal, B is the amount of batch data passing through the neural network each time, and s is the side length of the input image;
[0057] 8) Using the hyperspectral classification optimization target result obtained in step 7), the current convolutional neural network, mean network and variance network are iteratively updated. After all images in the training set are input for one round, a training is completed. When the set maximum number of training times is reached, the training ends and the trained convolutional neural network, mean network and variance network are obtained.
[0058] In a specific embodiment of the present disclosure, the and stated The expressions are as follows:
[0059]
[0060]
[0061]
[0062] Among them, m1 and m2 represent the mean vectors of pixel point p1 and pixel point p2 respectively, v1 and v2 represent the variance vectors of pixel point p1 and pixel point p2 respectively, is a random variable that follows a standard Gaussian distribution corresponding to the k1th sampling of pixel point p1. It is a random variable that obeys the standard Gaussian distribution corresponding to the k2th sampling of pixel point p2.
[0063] A second aspect of the present disclosure provides a hyperspectral image classification device, comprising:
[0064] An image feature extraction module is used to input the hyperspectral image to be classified into a preset convolutional neural network to obtain the image features of the hyperspectral image;
[0065] A mean matrix extraction module, used to obtain a mean matrix corresponding to the image feature by using the image feature according to a preset mean network;
[0066] The image classification module is used to calculate the probability value of each category of the hyperspectral image according to the mean matrix, and take the category corresponding to the maximum value of the probability value as the classification result of the hyperspectral image.
[0067] A third aspect of the present disclosure provides an electronic device, including:
[0068] at least one processor; and a memory communicatively coupled to the at least one processor;
[0069] The memory stores instructions executable by the at least one processor, and the instructions are configured to execute the above-mentioned hyperspectral image classification method.
[0070] A fourth aspect of the present disclosure provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the above-mentioned hyperspectral image classification method.
[0071] The characteristics and beneficial effects of the present disclosure are:
[0072] The present invention adopts a convolutional neural network to extract rich feature information from the input hyperspectral image block; then each pixel is modeled as a high-dimensional Gaussian distribution in the embedding space and the corresponding mean embedding matrix and variance embedding matrix are obtained; in order to facilitate constraints and training, we use a Monte Carlo sampling strategy to generate multiple samples from the above Gaussian distribution and calculate the matching probability between pairs of samples; next, we use a probabilistic contrast loss function to increase the matching probability between heterogeneous samples and reduce the matching probability between homogeneous samples; we also constrain the variance in the Gaussian distribution so that the variance of the peripheral pixels far from the center pixel is greater than the variance of the neighboring pixels close to the center pixel at a certain ratio; finally, we use a softmax mapping on the mean embedding matrix and use the cross entropy loss function to train the classifier to obtain the final classification result of the input image block; the overall framework of the present invention can be trained in an end-to-end mode, and the influence of uncertainty on the classification result is reduced by directly modeling the uncertainty of each pixel. Its advantages are as follows:
[0073] This paper first considers the spectral dimension uncertainty and label uncertainty in hyperspectral images and uses probabilistic embedding to represent each pixel in the image, introducing uncertainty modeling in the model;
[0074] The present disclosure proposes a probabilistic deep metric learning method, which uses a Monte Carlo sampling strategy to obtain a series of samples from the distribution obtained by uncertainty modeling, and then uses a contrast loss function in the embedding space to reduce the distance between samples of the same type and increase the distance between samples of different types;
[0075] The hyperspectral classification architecture based on probabilistic deep metric learning proposed in this disclosure can be applied to existing models to improve classification performance, and can also achieve the best existing classification effect on the corresponding data set. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] Figure 1 It is a principle diagram of a hyperspectral image classification method in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0077] The embodiments of the present disclosure provide a hyperspectral image classification method, device, electronic device, and storage medium, which are further described in detail below in conjunction with the accompanying drawings and specific embodiments.
[0078] The first aspect of the present disclosure proposes a hyperspectral image classification method. Most of the current hyperspectral image classification methods use image blocks as input to simultaneously consider the spatial information and spectral information in the image. Although this can reduce the impact of spectral dimension uncertainty on the model, it introduces label uncertainty because different pixels in the image block may contain different categories of ground object information. In order to solve this problem, the present disclosure models the high-dimensional Gaussian distribution of each pixel in the input image block in the embedding space to introduce a representation of uncertainty and increase the distribution variance of peripheral pixels to increase the corresponding uncertainty. Monte Carlo sampling is used to generate a series of samples from the Gaussian distribution, and a probabilistic contrast loss function is used to constrain the distance between samples in the embedding space. Finally, the softmax function is used to obtain the classification result and the cross entropy loss function is used for overall constraint; the method principle of the embodiment of the present disclosure is as follows: Figure 1 As shown, it is divided into training phase and testing phase. The specific steps are as follows:
[0079] 1) Training phase;
[0080] 1-1) Obtain training data set;
[0081] A hyperspectral image is obtained to establish a training data set. The hyperspectral image of the training data set in the embodiment of the present disclosure comes from a public data set. In a specific embodiment of the present disclosure, the hyperspectral image comes from an Indian pine data set (IndianPines), which contains 16 different types of ground objects, and each image has 220 spectral channels. Since 20 of the spectral channels are affected by water absorption, the embodiment of the present disclosure discards these 20 channels and uses the remaining 200 channels for subsequent classification.
[0082] 1-2) Build a convolutional neural network and initialize it randomly;
[0083] The disclosed embodiment uses a convolutional neural network to extract features of the input image, and the convolutional neural network includes a spectral feature extraction unit and a spatial feature extraction unit. The spectral feature extraction unit is formed by connecting two residual modules, and each residual module is composed of two general convolutional layers. The spatial extraction unit is located after the spectral feature extraction part, and is also composed of two residual modules, and each residual module is also composed of two general convolutional layers.
[0084] 1-3) Construct mean network and variance network;
[0085] The mean network and the variance network use a fully connected layer with the same structure. The two fully connected layers are respectively located after the convolutional neural network constructed in step 1-2) for the subsequent Gaussian distribution modeling process.
[0086] 1-4) Using the training data set established in step 1-1), train the convolutional neural network established in step 1-2) and the two-layer fully connected neural network established in step 1-3); the specific steps are as follows:
[0087] 1-4-1) Image feature extraction;
[0088] Each image x in the training dataset i Input the current convolutional neural network and use the convolutional neural network to extract the corresponding image features f i In a specific embodiment of the present disclosure, the size of each input image and image feature is 5×5×24.
[0089] 1-4-2) Modeling high-dimensional Gaussian distribution in embedding space;
[0090] In the embedding space, the image features obtained from the convolutional neural network are probabilistically modeled, and the Gaussian distribution mean vector and variance vector of each pixel are obtained through the mean network and variance network in 1-3), thereby directly modeling the uncertainty of the hyperspectral image, as shown below:
[0091]
[0092]
[0093] Among them, f i For x i The image features of M are represented by g1 and g2, respectively, representing the mapping of the mean network and the variance network to the input image features. i For the corresponding f i The mean matrix, m i j is the mean matrix M i The mean vector corresponding to the jth pixel in V i For the corresponding fi The variance matrix, v i j is the variance matrix V i The variance vector corresponding to the j-th pixel in , T represents the number of pixels in the input image.
[0094] 1-4-3) Increase the variance of peripheral pixels in image features by constraining the loss function;
[0095] Since the peripheral pixels in the input hyperspectral image are more likely to contain different types of ground object information from the central pixels, the embodiment of the present disclosure directly increases the variance parameter of the peripheral pixels in the image block according to a certain ratio α (a specific embodiment of the present disclosure takes a value of 0.2) in the embedding space, and the constraint loss function is as follows:
[0096]
[0097]
[0098] Among them, n j represents the number of pixels in the jth circle when the center pixel of the image feature is the first circle. This formula represents the number of pixels in the jth circle when the center pixel of the image feature is the first circle. i The loss function of the jth circle, where j>1.
[0099] 1-4-4) Sampling using Monte Carlo strategy;
[0100] In order to facilitate the constraints of the subsequent loss function, the embodiment of the present disclosure directly samples each pixel of the image feature from the high-dimensional Gaussian distribution through the Monte Carlo strategy to obtain multiple sampling samples (the value in this embodiment is 3), and assigns each sample the same category label as the central pixel of the image feature. The sampling process complies with the heavy parameter rule, as shown below (taking two pixels as an example):
[0101]
[0102]
[0103]
[0104] in, is the k1th sampling sample of the first pixel p1, is the k2th sampling sample of the second pixel point p2. In a specific embodiment of the present disclosure, k1=1, 2, 3, k2=1, 2, 3; m1 and m2 represent the mean vectors of the first pixel point p1 and the second pixel point p2, respectively; v1 and v2 represent the variance vectors of the first pixel point p1 and the second pixel point p2, respectively. is a random variable that follows a standard Gaussian distribution corresponding to the k1th sampling of pixel point p1. It is a random variable that obeys the standard Gaussian distribution corresponding to the k2th sampling of pixel point p2.
[0105] 1-4-5) Probabilistically compare the sample loss function constraints;
[0106] In order to more comprehensively describe the relationship between samples, the embodiment of the present disclosure uses matching probability to characterize the matching degree of paired samples and adopts a probabilistic contrast loss function for corresponding constraints. The matching probability is between 0 and 1, indicating the matching degree of a pair of samples:
[0107] p(z i , z j )=σ(-aD ij +b)
[0108]
[0109] Among them, z i and z j Represent any two samples, D ij is the sample z i and z j The Euclidean distance between them, a>0 and b are two learnable parameters representing the threshold of the Euclidean distance.
[0110] The matching probability between the pixels of the samples obtained by the Monte Carlo strategy is the mean of the matching probabilities between each pair of corresponding generated samples:
[0111]
[0112] Wherein, p1 and p2 are any two pixel points in the image feature, and K is the number of sampling times (3 in this embodiment).
[0113] The probabilistic contrast loss function is used to constrain the above matching probabilities:
[0114]
[0115] In the formula, match means that the two pixels belong to the same category.
[0116] When two pixels belong to the same category, the matching probability between them will increase, otherwise it will decrease.
[0117] 1-4-6) Use softmax function for classification;
[0118] In the implementation of the present disclosure, in the mean matrix M iThe softmax function is used to map the input image x i Hyperspectral classification results.
[0119] Calculate image x i The probability value corresponding to each category:
[0120]
[0121] Among them, k represents the k-th category label, f l (M i ) represents the mean matrix M i A linear mapping that makes M i The dimension of f is equal to the total number of categories, l (M i ) k Represents f l (M i ) in the kth component value, y i Represents x i The classification result, N represents the total number of categories;
[0122] 1-4-7) Calculate the cross entropy loss function of the current training:
[0123]
[0124] The overall hyperspectral classification optimization objective of probabilistic metric learning is as follows:
[0125] J PDML =J dist +λ3J ce
[0126] in,
[0127]
[0128] Wherein, λ1, λ2 and λ3 are coefficients used to balance the influence of each loss function on the overall optimization target (in one embodiment of the present disclosure, the values are all 1), B is the amount of batch data passing through the neural network each time, T is the number of pixels of the image block, and the image block is the input image; s is the side length of the input image;
[0129] 1-4-8) Using the result of step 1-4-7) (the above J PDML Update the parameters of the overall network through back propagation) Iteratively update the current convolutional neural network, mean network and variance network (the above J PDMLThe parameters of the three networks are updated through back propagation. When the set maximum number of training times is reached (in the embodiment of the present disclosure, one training is completed after all images in the training set are input for one round, and the maximum number of training times in a specific embodiment of the present disclosure is 300), the training ends and the trained convolutional neural network, mean network and variance network are obtained.
[0130] 2) Testing phase;
[0131] 2-1) Get any hyperspectral image;
[0132] 2-2) inputting the hyperspectral image of step 2-1) into the convolutional neural network trained in step 1) to obtain image features corresponding to the image;
[0133] 2-3) Inputting the image features obtained in step 2-2) into the mean network trained in step 1) to obtain the mean matrix corresponding to the image features;
[0134] 2-4) Using the results of step 2-3), the probability value of each category of the hyperspectral image is calculated through the softmax function:
[0135]
[0136] Among them, the category label corresponding to the maximum probability value is the classification result of the hyperspectral image.
[0137] The method of the disclosed embodiment retains the current popular image block input format to simultaneously consider the spatial information and spectral information in the hyperspectral image, and uses a probabilistic embedding method to directly model the label uncertainty of different pixels in the image block, which improves the corresponding classification accuracy while also improving the robustness of the model to a certain extent.
[0138] To implement the above embodiment, a second aspect of the present disclosure provides a hyperspectral image classification device, including:
[0139] An image feature extraction module is used to input the hyperspectral image to be classified into a preset convolutional neural network to obtain the image features of the hyperspectral image;
[0140] A mean matrix extraction module, used to obtain a mean matrix corresponding to the image feature by using the image feature according to a preset mean network;
[0141] The image classification module is used to calculate the probability value of each category of the hyperspectral image according to the mean matrix, and take the category corresponding to the maximum value of the probability value as the classification result of the hyperspectral image.
[0142] To implement the above embodiment, a third aspect of the present disclosure provides an electronic device, including:
[0143] at least one processor; and a memory communicatively coupled to the at least one processor;
[0144] The memory stores instructions executable by the at least one processor, and the instructions are configured to execute the above-mentioned hyperspectral image classification method.
[0145] To implement the above embodiment, a fourth aspect of the present disclosure provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the above hyperspectral image classification method.
[0146] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0147] The computer readable medium may be included in the electronic device, or may exist independently without being installed in the electronic device. The computer readable medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device executes a hyperspectral image classification method of the above embodiment.
[0148] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0149] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0150] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0151] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0152] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute the instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or otherwise processing in a suitable manner if necessary, and then stored in a computer memory.
[0153] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0154] A person skilled in the art may understand that all or part of the steps in the above-mentioned embodiment method may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0155] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0156] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A hyperspectral image classification method, characterized in that: include: Inputting the hyperspectral image to be classified into a preset convolutional neural network to obtain image features of the hyperspectral image; Using the image features, according to a preset mean network, a mean matrix corresponding to the image features is obtained; According to the mean matrix, the probability values of the hyperspectral image corresponding to each category are calculated, and the category corresponding to the maximum value of the probability value is used as the classification result of the hyperspectral image; Wherein, before inputting the hyperspectral image to be classified into a preset convolutional neural network to obtain the image features of the hyperspectral image, the method further includes: Training the convolutional neural network and the mean network; The training of the convolutional neural network and the mean network comprises: Get the training dataset; Construct a convolutional neural network and initialize it randomly; Constructing a mean network and a variance network, and connecting the mean network and the variance network after the convolutional neural network respectively; Using the training data set to train the convolutional neural network, the mean network, and the variance network to obtain the trained convolutional neural network, the mean network, and the variance network, comprising: 1) Image feature extraction; Each image x in the training dataset i Input the current convolutional neural network and use the current convolutional neural network to extract the corresponding image features f i ; 2) Use the current mean network and variance network to construct the mean matrix and variance matrix corresponding to the image features, as shown below: Among them, f i For x i image features, g1 and g2 represent the mapping of the mean network and variance network to the input image features, respectively. i For the corresponding f i The mean matrix, m i j is the mean matrix M i The mean vector corresponding to the jth pixel in V i For the corresponding f i The variance matrix, v i j is the variance matrix V i The variance vector corresponding to the j-th pixel in , T represents the number of pixels in the input image; 3) Increase the variance of peripheral pixels in image features by constraining the loss function; Among them, for the image feature f i The constraint loss function constructed for the pixels of the jth circle is as follows: Among them, α is the set increase ratio value, n j Represents the number of pixels in the jth circle when the center pixel of the image feature is the first circle; 4) Using the Monte Carlo strategy to sample each pixel of the image feature, the category label of each sample obtained is the same as the category label of the central pixel of the image feature; 5) Using the samples obtained by sampling, the matching probability between samples is calculated, the matching probability between pixels to which the samples belong is obtained, and the probabilistic contrast loss function between pixels is calculated; For any two samples z i and z j , the matching probability calculation expression is as follows: p(z i ,With j )=σ(-aD ij +b) Among them, D ij is the sample z i and z j The Euclidean distance between them, a>0 and b are the parameters representing the Euclidean distance threshold; Calculate the matching probability between the pixels to which the samples belong. The expression is as follows: Among them, p1 and p2 are any two pixels in the image features. is the k1th sampling sample of pixel p1, is the k2th sampling sample of pixel p2, where K is the number of sampling times; Calculate the probabilistic contrast loss function between pixels: In the formula, match means that the two pixels belong to the same category; 6) Use softmax function for classification; Calculate image x i The probability value corresponding to each category: Among them, k represents the k-th category label, fl(M i ) represents the mean matrix M i A linear mapping that makes M i The dimension of f is equal to the total number of categories, l (M i ) k Represents f l (M i ) in the kth component value, y i Represents x i The classification result, N represents the total number of categories; 7) Calculate the cross entropy loss function of the current training: The hyperspectral classification optimization objective is as follows: I PDML =J dist +λ3J ce in, Among them, λ1, λ2 and λ3 are coefficients used to balance the impact of each loss function on the overall optimization goal, B is the amount of batch data passing through the neural network each time, and s is the side length of the input image; 8) Using the hyperspectral classification optimization target result obtained in step 7), the current convolutional neural network, mean network and variance network are iteratively updated. After all images in the training set are input for one round, a training is completed. When the set maximum number of training times is reached, the training ends and the trained convolutional neural network, mean network and variance network are obtained.
2. The method according to claim 1, characterized in that According to the mean matrix, the probability value of each category corresponding to the hyperspectral image is calculated, and the expression is as follows: Wherein, the hyperspectral image is denoted as x i , k represents the kth category label, M i Represents x i The mean matrix corresponding to the image features, f l (M i ) represents the mean matrix M i A linear mapping such that M i The dimension of f is equal to the total number of categories, l (M i ) k Represents f l (M i ) in the kth component value, y i Represents x i The classification result, N represents the total number of categories.
3. The method according to claim 1, characterized in that The convolutional neural network includes a spectral feature extraction unit and a spatial feature extraction unit connected in sequence; wherein the spectral feature extraction unit and the spatial extraction unit are both formed by connecting two residual modules, and each residual module is composed of two convolutional layers.
4. The method according to claim 1, characterized in that: The mean network and the variance network are composed of a fully connected layer with the same structure.
5. The method according to claim 1, characterized in that Said and stated The expressions are as follows: Among them, m1 and m2 represent the mean vectors of pixel point p1 and pixel point p2 respectively, v1 and v2 represent the variance vectors of pixel point p1 and pixel point p2 respectively, is a random variable that follows a standard Gaussian distribution corresponding to the k1th sampling of pixel point p1. It is a random variable that obeys the standard Gaussian distribution corresponding to the k2th sampling of pixel point p2.
6. A hyperspectral image classification device for executing the method according to claim 1, characterized in that: include: An image feature extraction module is used to input the hyperspectral image to be classified into a preset convolutional neural network to obtain the image features of the hyperspectral image; A mean matrix extraction module, used to obtain a mean matrix corresponding to the image feature by using the image feature according to a preset mean network; The image classification module is used to calculate the probability value of each category of the hyperspectral image according to the mean matrix, and take the category corresponding to the maximum value of the probability value as the classification result of the hyperspectral image.
7. An electronic device, characterized in that: include: at least one processor; and, a memory communicatively coupled to the at least one processor; The memory stores instructions executable by the at least one processor, and the instructions are configured to execute the method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the method according to any one of claims 1 to 5.
