Hyperspectral image small sample classification method and system in combination with contrast learning
Through the comparative learning method, combined with PCA dimensionality reduction and pixel domain block division, combined with 2-D CNN and 3-D CNN network structures, the SimCLR loss function is used to solve the problem of high-dimensionality and high sample labeling cost in the small sample classification of hyperspectral images. Achieve efficient classification effect.
Patent Information
- Application Number
- CN202411589088.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-08
- Publication Date
- 2025-01-10
AI Technical Summary
The classification of small samples of hyperspectral images faces the problems of high dimensions, large data volume and high cost of artificially adding sample marks.
Using a contrast learning method, through PCA dimensionality reduction, pixel domain block division and data augmentation, combined with 2-D CNN and 3-D CNN network structures, the SimCLR loss function is used to train to realize the classification of hyperspectral images.
Effectively alleviates dimensional disasters, reduces computing costs, improves data processing speed, and achieves accurate classification with fewer samples.
Smart Images

Figure CN119295835A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image classification, and in particular relates to a method and system for classifying small samples of hyperspectral images combined with contrast learning. Background Art
[0002] Hyperspectral remote sensing technology is based on imaging spectroscopy, which usually uses imaging spectra to obtain remote sensing data, and then processes, analyzes and applies them. It is widely used in many fields including biodiversity research, resource exploration, environmental monitoring, disaster warning, etc. At present, the classification of small samples of hyperspectral images still faces important problems such as high dimensionality, large data volume and high cost of adding sample labels manually. Summary of the invention
[0003] The present invention provides a method and system for classifying small samples of hyperspectral images combined with contrastive learning, which are used to solve the technical problems of high dimension, large data volume and high cost of artificially adding sample labels in small sample classification of hyperspectral images.
[0004] In a first aspect, the present invention provides a method for classifying small samples of hyperspectral images combined with contrastive learning, comprising:
[0005] Acquire hyperspectral image data, and perform dimensionality reduction processing on the hyperspectral image data to obtain target hyperspectral image data;
[0006] Dividing the target hyperspectral image data into pixel domain blocks to obtain image data to be input, wherein the image data to be input includes each neighborhood pixel block of the target hyperspectral image;
[0007] The image data to be input is input into a pre-constructed CL-HSI network model, and the CL-HSI network model outputs a classification result corresponding to the target hyperspectral image data.
[0008] In a second aspect, the present invention provides a hyperspectral image small sample classification system combined with contrastive learning, comprising:
[0009] An acquisition module is configured to acquire hyperspectral image data, perform dimensionality reduction processing on the hyperspectral image data, and obtain target hyperspectral image data;
[0010] A division module is configured to divide the target hyperspectral image data into pixel domain blocks to obtain image data to be input, wherein the image data to be input includes each neighborhood pixel block of the target hyperspectral image;
[0011] The output module is configured to input the image data to be input into a pre-built CL-HSI network model, and the CL-HSI network model outputs a classification result corresponding to the target hyperspectral image data.
[0012] In a third aspect, an electronic device is provided, comprising: at least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the steps of the method for small sample classification of hyperspectral images combined with contrast learning of any embodiment of the present invention.
[0013] In a fourth aspect, the present invention further provides a computer-readable storage medium having a computer program stored thereon, wherein when the program instructions are executed by a processor, the processor executes the steps of the method for small sample classification of hyperspectral images combined with contrast learning according to any embodiment of the present invention.
[0014] The hyperspectral image small sample classification method and system combined with contrast learning in this application have the following beneficial effects:
[0015] Using the PCA algorithm to reduce the dimensionality of the original high-dimensional data can alleviate the dimensionality disaster problem, minimize information loss while compressing the data, reduce the amount of calculation, speed up program operation, and facilitate the execution of subsequent tasks;
[0016] The pixel neighborhood division and data enhancement methods are used to enrich the spatial information stored in a single pixel unit and speed up data processing;
[0017] The network structure combining 2-D CNN and 3-D CNN is used as the Encoder part of the contrastive learning framework, which is more lightweight.
[0018] The projection head uses the FC-BN-ReLU-FC structure to map the feature representation obtained by the encoder to the feature space where the contrast loss is applied, helping to identify the unique features of each input;
[0019] The loss function of the contrastive learning model SimCLR is used to train the data set, and finally fine-tuning and classification are completed. This can achieve training on a smaller sample space, thereby reducing computing costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0021] Figure 1 A flowchart of a method for classifying small samples of hyperspectral images combined with contrast learning provided by one embodiment of the present invention;
[0022] Figure 2 A structural block diagram of a small sample classification system for hyperspectral images combined with contrast learning provided by an embodiment of the present invention;
[0023] Figure 3 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0025] See also Figure 1 , which shows a flowchart of a small sample classification method of hyperspectral images combined with contrast learning in the present application.
[0026] like Figure 1 As shown in FIG. 1 , the small sample classification method of hyperspectral images combined with contrastive learning specifically includes the following steps:
[0027] Step S101, acquiring hyperspectral image data, and performing dimensionality reduction processing on the hyperspectral image data to obtain target hyperspectral image data.
[0028] In this step, the cube of spectral-spatial hyperspectral image data is represented as I∈R M×N×D , I is the original input, M is the width, N is the height, and D is the number of optical bands / depths; PCA dimensionality reduction method is used to reduce I∈R M×N×D Perform dimensionality reduction to obtain the data cube X∈R M×N×B , X is the data after dimensionality reduction, and B is the number of spectral bands after dimensionality reduction.
[0029] Step S102 , dividing the target hyperspectral image data into pixel area blocks to obtain image data to be input, wherein the image data to be input includes each neighborhood pixel block of the target hyperspectral image.
[0030] In this step, the data cube is divided into overlapping neighborhood pixel units, and the true value label of the neighborhood pixel unit is determined by the label of the central pixel;
[0031] Using P∈R S×S×B Represents the creation of a data cube X∈R M×N×BP represents the 3D neighborhood of the data cube X∈R centered at the spatial position (α, β), covering a window of size S×S and all B spectral bands. M×N×B The total number of generated 3-D blocks n is expressed as:
[0032] n=(M-S+1)(N-S+1),
[0033] Where M, N represent the width and height of the data cube X, respectively, and S represents the window width and height.
[0034] Step S103: input the image data to be input into a pre-built CL-HSI network model, and the CL-HSI network model outputs a classification result corresponding to the target hyperspectral image data.
[0035] In this step, data enhancement is performed on the image data to be input, and the data enhancement includes flipping, rotation, scaling, cropping, shifting and Gaussian noise, wherein the expression of Gaussian distribution is:
[0036]
[0037] Where f(x) represents the Gaussian distribution function, μ is the mean, σ is the standard deviation, and x is randomly generated data.
[0038] It should be noted that a network structure combining lightweight 2-DCNN and 3-DCNN is used as the Encoder part of the contrastive learning framework, including 3 three-dimensional convolutional layers and 2 two-dimensional convolutional layers;
[0039] After the encoder, the FC-BN-ReLU-FC structure is used as the projection head to map the output f(X) obtained by the encoder to g(f(x)), where the calculation formula of the projection head is:
[0040] g(f(x))=W (2) (σW (1) (f(X))),
[0041] Where W (1) and W (2) Represent the weight parameters of the two FCs respectively, and σ is the ReLU activation function;
[0042] The contrast loss adopts the form of NCE loss function, and the similarity metric adopts cosine distance, which is expressed as:
[0043]
[0044] In the formula, z i and z j is the input xi and x j The corresponding output, τ is the adjustable temperature parameter, Π [k≠i] is an indicator function whose value is 0 if and only if k=i, otherwise it is 1.
[0045] In summary, the method of the present application pre-processes the data through PCA, pixel neighborhood division and data enhancement, and then uses self-supervised learning and contrastive learning to build a classification network, thereby realizing small sample classification of hyperspectral images.
[0046] See also Figure 2 , which shows a structural block diagram of a small sample classification system of hyperspectral images combined with contrast learning in the present application.
[0047] like Figure 2 As shown, the hyperspectral image small sample classification system 200 includes an acquisition module 210 , a division module 220 and an output module 230 .
[0048] Among them, the acquisition module 210 is configured to acquire hyperspectral image data, perform dimensionality reduction processing on the hyperspectral image data, and obtain target hyperspectral image data; the division module 220 is configured to perform pixel domain block division on the target hyperspectral image data to obtain image data to be input, and the image data to be input includes each neighborhood pixel block of the target hyperspectral image; the output module 230 is configured to input the image data to be input into a pre-constructed CL-HSI network model, and the CL-HSI network model outputs a classification result corresponding to the target hyperspectral image data.
[0049] It should be understood that Figure 2 Modules and references documented in Figure 1 Therefore, the operations and features described above for the method and the corresponding technical effects are also applicable to Figure 2 The modules in it will not be described in detail here.
[0050] In some other embodiments, the embodiments of the present invention further provide a computer-readable storage medium having a computer program stored thereon, wherein when the program instructions are executed by a processor, the processor is caused to execute the hyperspectral image small sample classification method combined with contrast learning in any of the above method embodiments;
[0051] As an implementation mode, the computer-readable storage medium of the present invention stores computer-executable instructions, and the computer-executable instructions are configured as follows:
[0052] Acquire hyperspectral image data, and perform dimensionality reduction processing on the hyperspectral image data to obtain target hyperspectral image data;
[0053] Dividing the target hyperspectral image data into pixel domain blocks to obtain image data to be input, wherein the image data to be input includes each neighborhood pixel block of the target hyperspectral image;
[0054] The image data to be input is input into a pre-constructed CL-HSI network model, and the CL-HSI network model outputs a classification result corresponding to the target hyperspectral image data.
[0055] The computer-readable storage medium may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required by at least one function; the data storage area may store data created according to the use of the small sample classification system for hyperspectral images combined with contrast learning, etc. In addition, the computer-readable storage medium may include a high-speed random access memory, and may also include a memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the computer-readable storage medium may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the small sample classification system for hyperspectral images combined with contrast learning via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0056] Figure 3 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, such as Figure 3 As shown, the device includes: a processor 310 and a memory 320. The electronic device may also include: an input device 330 and an output device 340. The processor 310, the memory 320, the input device 330 and the output device 340 may be connected via a bus or other means. Figure 3 In the example, the bus connection is used. The memory 320 is the above-mentioned computer-readable storage medium. The processor 310 executes various functional applications and data processing of the server by running the non-volatile software programs, instructions and modules stored in the memory 320, that is, the high-spectral image small sample classification method combined with contrast learning in the above-mentioned method embodiment is realized. The input device 330 can receive input digital or character information, and generate key signal input related to user settings and function control of the high-spectral image small sample classification system combined with contrast learning. The output device 340 may include a display device such as a display screen.
[0057] The electronic device can execute the method provided by the embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not described in detail in this embodiment, please refer to the method provided by the embodiment of the present invention.
[0058] As an implementation mode, the electronic device is applied to a small sample classification system of a hyperspectral image combined with contrast learning, and is used for a client, and includes: at least one processor; and a memory connected to the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can:
[0059] Acquire hyperspectral image data, and perform dimensionality reduction processing on the hyperspectral image data to obtain target hyperspectral image data;
[0060] Dividing the target hyperspectral image data into pixel domain blocks to obtain image data to be input, wherein the image data to be input includes each neighborhood pixel block of the target hyperspectral image;
[0061] The image data to be input is input into a pre-constructed CL-HSI network model, and the CL-HSI network model outputs a classification result corresponding to the target hyperspectral image data.
[0062] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.
[0063] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A small sample classification method for hyperspectral images combined with contrastive learning, characterized in that: include: Acquire hyperspectral image data, and perform dimensionality reduction processing on the hyperspectral image data to obtain target hyperspectral image data; Dividing the target hyperspectral image data into pixel domain blocks to obtain image data to be input, wherein the image data to be input includes each neighborhood pixel block of the target hyperspectral image; The image data to be input is input into a pre-constructed CL-HSI network model, and the CL-HSI network model outputs a classification result corresponding to the target hyperspectral image data.
2. The method for small sample classification of hyperspectral images combined with contrastive learning according to claim 1, characterized in that: The acquiring of the hyperspectral image data and performing dimensionality reduction processing on the hyperspectral image data to obtain target hyperspectral image data comprises: Denote the cube of spectral-spatial hyperspectral image data as I∈R M×N×D , I is the original input, M is the width, N is the height, and D is the number of optical bands / depths; PCA dimensionality reduction method is used to reduce I∈R M×N×D Perform dimensionality reduction to obtain the data cube X∈R M×N×B , X is the data after dimensionality reduction, and B is the number of spectral bands after dimensionality reduction.
3. The method for small sample classification of hyperspectral images combined with contrastive learning according to claim 1, characterized in that: The pixel domain block division of the target hyperspectral image data to obtain the image data to be input includes: Divide the data cube into overlapping neighborhood pixel units, where the true value label of the neighborhood pixel unit is determined by the label of the central pixel; Using P∈R S×S×B Represents the creation of a data cube X∈R M×N×B P represents the 3D neighborhood of the data cube X∈R centered at the spatial position (α, β), covering a window of size S×S and all B spectral bands. M×N×B The total number of generated 3-D blocks n is expressed as: n=(M-S+1)(N-S+1) Where M, N represent the width and height of the data cube X, respectively, and S represents the window width and height.
4. The method for small sample classification of hyperspectral images combined with contrastive learning according to claim 1, characterized in that: Before the image data to be input is input into a pre-built CL-HSI network model and the CL-HSI network model outputs a classification result corresponding to the target hyperspectral image data, the method further includes: Data enhancement is performed on the image data to be input, and the data enhancement includes flipping, rotation, scaling, cropping, shifting and Gaussian noise, wherein the expression of Gaussian distribution is: Where f(x) represents the Gaussian distribution function, μ is the mean, σ is the standard deviation, and x is randomly generated data.
5. The method for small sample classification of hyperspectral images combined with contrastive learning according to claim 4, characterized in that: Before the image data to be input is input into a pre-built CL-HSI network model and the CL-HSI network model outputs a classification result corresponding to the target hyperspectral image data, the method further includes: A lightweight 2-DCNN and 3-DCNN combined network structure is used as the Encoder part of the contrastive learning framework, including 3 3D convolutional layers and 2 2D convolutional layers. After the encoder, the FC-BN-ReLU-FC structure is used as the projection head to map the output f(X) obtained by the encoder to g(f(x)), where the calculation formula of the projection head is: g(f(x))=W (2) (σW (1) (f(X))) Where W (1) and W (2) Represent the weight parameters of the two FCs respectively, and σ is the ReLU activation function; The contrast loss adopts the form of NCE loss function, and the similarity metric adopts cosine distance, which is expressed as: In the formula, z i and z j is the input x i and x j The corresponding output, τ is the adjustable temperature parameter, Π [k≠i] is an indicator function whose value is 0 if and only if k=i, otherwise it is 1.
6. A hyperspectral image small sample classification system combined with contrastive learning, characterized in that: include: An acquisition module is configured to acquire hyperspectral image data, perform dimensionality reduction processing on the hyperspectral image data, and obtain target hyperspectral image data; A division module is configured to divide the target hyperspectral image data into pixel domain blocks to obtain image data to be input, wherein the image data to be input includes each neighborhood pixel block of the target hyperspectral image; The output module is configured to input the image data to be input into a pre-built CL-HSI network model, and the CL-HSI network model outputs a classification result corresponding to the target hyperspectral image data.
7. An electronic device, characterized in that: include: At least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method described in any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.