Environmental quality testing methods and devices

By combining principal component analysis and random forest classification model, the accuracy and adaptability issues of environmental detection in hyperspectral remote sensing images were solved, achieving efficient and accurate environmental quality detection.

CN116778337BActive Publication Date: 2026-03-10AEROSPACE INFORMATION RES INST CAS
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310862919.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-13
Publication Date
2026-03-10
Estimated Expiration
2043-07-13

AI Technical Summary

Technical Problem

Existing environmental detection methods based on hyperspectral remote sensing images suffer from low detection accuracy, limitations, and low adaptability.

Method used

Principal component analysis was used to preprocess and reduce the dimensionality of hyperspectral remote sensing images. Attention scores were calculated for feature extraction. Environmental quality detection was performed by combining multi-scale convolution operations and weighted summation with a random forest classification model, especially by assigning greater weight to minority class samples.

Benefits of technology

It improves the accuracy and efficiency of environmental detection, overcomes the limitations of traditional methods in handling features at different scales, enhances the ability to identify minority class samples, and adapts to the needs of different categories of features.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116778337B_ABST
    Figure CN116778337B_ABST
Patent Text Reader

Abstract

This invention provides an environmental quality detection method and apparatus, relating to the fields of image data processing and environmental quality detection, to address problems such as low detection accuracy and limitations. The method includes: preprocessing a hyperspectral remote sensing image to obtain an enhanced image; performing dimensionality reduction on the enhanced image using principal component analysis to obtain a first feature map; calculating the attention score of the first feature map, which is used to highlight target features in the dimensionality-reduced feature map; extracting features from the dimensionality-reduced feature image based on the attention score to obtain an attention feature map; performing multi-scale convolution on the first feature map to obtain second feature maps at different scales, and then performing a weighted summation to obtain a third feature map; fusing the attention feature map and the third feature map, and inputting the resulting fourth feature map into a random forest classification model to predict the quality detection result, wherein the weight of the decision tree that can accurately classify minority class samples in the random forest classification model is greater than the weight of other decision trees.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image data processing technology, specifically to the field of environmental quality detection technology, and particularly to an environmental quality detection method and apparatus. Background Technology

[0002] With social development and population growth, public concern for environmental quality is increasing. Environmental quality monitoring is a crucial means of assessing and monitoring the degree of environmental pollution. Traditional environmental quality monitoring methods suffer from problems such as difficulty in sample acquisition and high time costs. Because hyperspectral remote sensing images possess characteristics such as multi-band coverage, high spectral resolution, and rich spectral information, they can provide important data support for environmental quality monitoring. Therefore, environmental monitoring based on hyperspectral remote sensing images has become an important technical approach.

[0003] However, existing environmental detection methods based on hyperspectral remote sensing images still suffer from technical problems such as low detection accuracy, limited detection capabilities, and low adaptability. Summary of the Invention

[0004] To address the aforementioned technical problems, the present invention provides an environmental quality testing method and apparatus, which at least partially solves the above-mentioned technical problems.

[0005] Based on this, the first aspect of the present invention provides an environmental quality detection method, comprising: preprocessing a hyperspectral remote sensing image to obtain an enhanced image; performing dimensionality reduction on the enhanced image using principal component analysis to obtain a first feature map; calculating an attention score of the first feature map, wherein the attention score is used to highlight target features in the dimensionality-reduced feature map; extracting features from the dimensionality-reduced feature image based on the attention score to obtain an attention feature map; performing multi-scale convolution operations on the first feature map to obtain second feature maps at different scales; performing weighted summation on the second feature maps at different scales to obtain a third feature map; fusing the attention feature map and the third feature map to obtain a fourth feature map; and inputting the fourth feature map into a random forest classification model to predict the quality detection result, wherein the weight of the decision tree in the random forest classification model that can accurately classify minority class samples is greater than the weight of other decision trees.

[0006] According to an embodiment of the present invention, dimensionality reduction of an enhanced image using principal component analysis to obtain a first feature map includes: acquiring the number of pixels in the enhanced image, the pixel value of each pixel, and the number of spectral channels; determining a first feature value for each pixel based on its pixel value; calculating an average feature value corresponding to each spectral channel based on the number of pixels and the pixel value of each pixel; centering the enhanced image based on the first feature value of each pixel and the average feature value corresponding to each spectral channel to obtain feature data corresponding to each spectral channel; calculating the covariance between any two spectral channels based on the feature data to form a covariance matrix; solving for the second eigenvalue of the covariance matrix and the unit eigenvector corresponding to the second eigenvalue; and determining the first feature map based on the unit eigenvector corresponding to the second eigenvalue greater than a preset threshold.

[0007] According to an embodiment of the present invention, calculating the attention score of the first feature map includes: sequentially inputting the first feature map into a first average pooling layer and a first fully connected layer, calculating the spectral attention score of the first feature map, wherein the spectral attention score is used to weight the first feature map to highlight the target spectral channel; sequentially inputting the first feature map into a second average pooling layer and a convolutional layer, calculating the spatial attention score of the first feature map, wherein the spectral attention score is used to weight the first feature map to highlight the target spatial channel.

[0008] According to an embodiment of the present invention, feature extraction is performed on the dimensionality-reduced feature image based on the attention score to obtain an attention feature map; the first feature map is weighted based on the spectral attention score to obtain a spectral attention feature map; the first feature map is weighted based on the spatial attention score to obtain a spatial attention feature map; and the spectral attention feature map and the spatial attention feature map are fused to obtain an attention feature map.

[0009] According to an embodiment of the present invention, fusing the spectral attention feature map and the spatial attention feature map includes: assigning a first weight to the spectral attention feature map and the spatial attention feature map based on the degree of dependence of the hyperspectral remote sensing image on spectral characteristics and the degree of dependence on spatial characteristics; and performing weighted fusion of the spectral attention feature map and the spatial attention feature map based on the first weight.

[0010] According to an embodiment of the present invention, weighted summation of second feature maps at different scales to obtain a third feature map includes: inputting the second feature map at each scale into a third average pooling layer and outputting feature vectors corresponding to the second feature map at each scale; inputting the feature vector at each scale into a second fully connected layer and calculating the second weight of the feature vector at each scale; and weighted summation of feature vectors at all scales based on the second weight of the feature vector at each scale to obtain a third feature map.

[0011] According to an embodiment of the present invention, inputting the fourth feature map into a random forest classification model and predicting the quality detection result includes: inputting the fourth feature map into each decision tree and outputting multiple prediction results; weighting the multiple prediction results based on the weights pre-assigned to each decision tree to obtain the quality detection result.

[0012] According to an embodiment of the present invention, the harmonic mean of the precision and recall of each decision tree for classifying unstable samples is determined as the weight of the corresponding decision tree.

[0013] According to an embodiment of the present invention, preprocessing a hyperspectral remote sensing image to obtain an enhanced image includes: filtering the hyperspectral remote sensing image using a nonlinear low-pass filtering method, wherein the mean filtering during the filtering process keeps the pixel value unchanged, and when the difference between a pixel and the pixel mean falls outside the standard deviation, the new value of the pixel is set as the pixel mean.

[0014] A second aspect of this invention provides an environmental quality detection device, comprising: a preprocessing module for preprocessing a hyperspectral remote sensing image to obtain an enhanced image; a dimensionality reduction module for performing dimensionality reduction on the enhanced image using principal component analysis to obtain a first feature map; a calculation module for calculating an attention score of the first feature map, wherein the attention score is used to highlight target features in the dimensionality-reduced feature map; a feature extraction module for extracting features from the dimensionality-reduced feature map based on the attention score to obtain an attention feature map; a convolution module for performing multi-scale convolution operations on the first feature map to obtain second feature maps at different scales; a weighting module for performing weighted summation on the second feature maps at different scales to obtain a third feature map; a fusion module for fusing the attention feature map and the third feature map to obtain a fourth feature map; and a prediction module for inputting the fourth feature map into a random forest classification model to predict the quality detection result, wherein the weight of the decision tree in the random forest classification model that can accurately classify minority class samples is greater than the weight of other decision trees.

[0015] The environmental quality testing method and apparatus provided according to embodiments of the present invention have at least the following beneficial effects:

[0016] The attention score of the input feature map is calculated. During feature extraction, this attention score highlights important features and suppresses unimportant ones, enabling the extraction of features crucial for environmental detection while removing those unimportant, thus improving both accuracy and efficiency. By capturing and fusing multi-scale feature information from different scales, it addresses the limitations of traditional methods in handling features at different scales, as different features in real remote sensing images may exhibit the greatest differences at different scales, improving the accuracy of environmental detection. Furthermore, an improved random forest classification model is used to predict environmental detection results, enhancing the ability to identify minority class samples and thus improving the accuracy of environmental quality detection.

[0017] By calculating the attention score from both spectral and spatial characteristics, the final attention score is determined, thus linking the spectral and spatial information of hyperspectral remote sensing images. This solves the problem that traditional convolutional neural networks may ignore the correlation between spectral and spatial information in feature extraction of hyperspectral remote sensing images, thereby improving the accuracy of environmental detection.

[0018] During the attention feature map fusion process, weights are assigned to the spectral attention feature map and the spatial attention feature map based on the degree of dependence of the hyperspectral remote sensing image on spectral characteristics and spatial characteristics. This fully considers that different categories of features in actual remote sensing images may require different emphases, enabling the environmental detection method and device to adapt to the needs of different categories of features. Attached Figure Description

[0019] The above and other objects, features, and advantages of the present invention will become more apparent from the following description of embodiments of the invention with reference to the accompanying drawings, in which:

[0020] Figure 1 The flowchart illustrating the environmental quality testing method provided in an embodiment of the present invention is shown.

[0021] Figure 2 A block diagram of an environmental quality detection device provided in an embodiment of the present invention is shown schematically. Detailed Implementation

[0022] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to specific embodiments and the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0023] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the invention. The terms “comprising,” “including,” etc., as used herein indicate the presence of the described feature images, steps, operations, and / or components, but do not exclude the presence or addition of one or more other feature images, steps, operations, or components.

[0024] In this invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," "linking," and "fixing," etc., should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection, an electrical connection, or a connection that allows communication between them; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.

[0025] In the description of this invention, it should be understood that the terms "longitudinal", "length", "circumferential", "front", "rear", "left", "right", "top", "bottom", "inner", "outer", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the subsystem or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention.

[0026] Throughout the accompanying drawings, identical elements are represented by the same or similar reference numerals. Conventional structures or configurations may be omitted where they might cause confusion in understanding the invention. Furthermore, the shapes, dimensions, and positional relationships of the components in the drawings do not reflect actual size, scale, or actual positional relationships. Additionally, any reference symbols placed within parentheses in this invention should not be construed as limiting the scope of the invention.

[0027] Similarly, to simplify the invention and aid in understanding one or more of the various disclosed aspects, in the above description of exemplary embodiments of the invention, various feature images of the invention are sometimes grouped together in a single embodiment, figure, or description thereof. The descriptions using the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific feature images, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of the invention. In this specification, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific feature images, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0028] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical feature images. Therefore, feature images defined as "first" or "second" may explicitly or implicitly include one or more of that feature images. In the description of this invention, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0029] Figure 1 The flowchart illustrating the environmental quality testing method provided in an embodiment of the present invention is shown.

[0030] like Figure 1 As shown, the environmental quality detection method includes operations S110 to S160.

[0031] In operation S110, the hyperspectral remote sensing image is preprocessed to obtain an enhanced image.

[0032] Before conducting environmental quality monitoring, it is necessary to acquire hyperspectral remote sensing images. These images, with high spectral resolution, can be obtained via satellite, drones, or other remote sensing platforms. The acquired hyperspectral remote sensing images should include the environmental scene of the region of interest for subsequent processing and analysis.

[0033] Hyperspectral remote sensing images are often affected by various noises during acquisition or transmission, making it difficult to extract important information. Therefore, image enhancement is necessary before analysis. Improving image quality is a prerequisite for extracting useful information from images, and the quality of the image significantly affects the accuracy of the final information extraction, making it more suitable for further analysis. Therefore, preprocessing is performed on the original images, including noise reduction and redundancy removal. To ensure a certain level of image clarity, the original images need to be processed.

[0034] In an embodiment of the present invention, a nonlinear low-pass filtering method is used to filter the image. When the nonlinear low-pass filter performs filtering, the mean filtering keeps the pixel value unchanged. When the difference between pixel P and the pixel mean falls outside one standard deviation, the new value of the pixel is set as the pixel mean, as shown in the following formula:

[0035]

[0036]

[0037]

[0038] Among them, P i,j Let be the pixel value of pixel (i, j), μ be the average pixel value within a certain neighborhood of pixel (i, j), and σ be the standard deviation of the pixel values ​​within that neighborhood. H×W is the pixel size. For example, a 3×3 pixel can be used to perform nonlinear low-pass filtering on a hyperspectral remote sensing image.

[0039] In operation S120, principal component analysis is used to reduce the dimensionality of the enhanced image to obtain the first feature map.

[0040] In an embodiment of the present invention, the process of dimensionality reduction of the enhanced image using principal component analysis can be as follows: Obtain the number of pixels, the pixel value of each pixel, and the number of spectral channels in the enhanced image. Determine the first eigenvalue of each pixel based on its pixel value. Calculate the average eigenvalue corresponding to each spectral channel based on the number of pixels and the pixel value of each pixel. Center the enhanced image based on the first eigenvalue of each pixel and the average eigenvalue corresponding to each spectral channel to obtain feature data corresponding to each spectral channel. Calculate the covariance between any two spectral channels based on the feature data to form a covariance matrix. Solve for the second eigenvalue of the covariance matrix and the unit eigenvector corresponding to the second eigenvalue. Determine the first feature map based on the unit eigenvector corresponding to the second eigenvalue greater than a preset threshold.

[0041] For example, the centralization process is as follows: given a dataset of hyperspectral images Where n is the number of samples (the number of pixels in the hyperspectral image), and p is the number of features (the number of spectral channels). First, the average value of each feature is calculated. (Pixel values), then, subtract the corresponding average value from the feature value of each sample to obtain the centered dataset. The specific formula for this step is as follows:

[0042]

[0043]

[0044] The process of calculating the covariance matrix is ​​as follows: Calculate the covariance matrix of the centered dataset. The elements S of the covariance matrix jk Let $\mathbf{j}$ be the covariance of feature $j$ and feature $k$, which can be calculated using the following formula:

[0045]

[0046] Finding eigenvalues ​​and eigenvectors: Finding the eigenvalues ​​of the covariance matrix and the corresponding unit eigenvector Eigenvalues ​​and eigenvectors satisfy the following equation:

[0047] SV = VΛ

[0048] Among them, Λ=diag(λ1,...,λ p V is a diagonal matrix where the elements on the diagonal are eigenvalues, and V = [v1, ..., v2]. p ] is an eigenvector matrix, where each column is an eigenvector.

[0049] Principal component selection: Based on the magnitude of the eigenvalues, select the eigenvectors corresponding to the top d largest eigenvalues ​​to form a dimensionality reduction matrix. Here, d is the dimension of the target after dimensionality reduction, which needs to satisfy d≤p.

[0050] Dimensionality reduction: A linear transformation is performed on a centralized dataset using a dimensionality reduction matrix to obtain a dimensionality-reduced dataset. The formula for this step is as follows:

[0051]

[0052] In operation S130, the attention score of the first feature map is calculated, and features are extracted from the dimensionality-reduced feature image based on the attention score to obtain the attention feature map.

[0053] In embodiments of the present invention, attention scores are used to highlight target features in the dimensionality-reduced feature map. Embodiments of the present invention employ an improved convolutional neural network for feature extraction, which mainly consists of three parts: a basic convolutional layer, an adaptive spectral-spatial attention module, and a classifier.

[0054] The basic convolutional layers are used to extract initial features. The attention module calculates attention scores based on the input feature maps to highlight important features and suppress unimportant ones. The classifier part generates the final classification result.

[0055] The adaptive spectral-spatial attention module is a core component of the improved convolutional neural network, consisting of a spectral attention submodule and a spatial attention submodule. Both submodules are adaptive, meaning their attention scores are dynamically calculated based on the input feature maps.

[0056] Therefore, calculating the attention score of the first feature map includes: sequentially inputting the first feature map into a first average pooling layer and a first fully connected layer, and calculating the spectral attention score of the first feature map, wherein the spectral attention score is used to weight the first feature map to highlight the target spectral channels. Then, sequentially inputting the first feature map into a second average pooling layer and a second convolutional layer, and calculating the spatial attention score of the first feature map, wherein the spectral attention score is used to weight the first feature map to highlight the target spatial channels.

[0057] For example, in the spectral attention submodule, for the first feature map after dimensionality reduction... (C is the number of channels, H and W are the height and width of the feature map, respectively). First, the global average pooling is calculated through the first average pooling layer.

[0058]

[0059] Then, the spectral attention score is calculated using the first fully connected layer and the Sigmoid activation function.

[0060]

[0061] in, and Here, σ represents the parameters of the first fully connected layer, and σ is the sigmoid function. Spectral attention scores are used to weight the input feature map to highlight important spectral channels.

[0062] The spatial attention score is calculated similarly to the spectral attention score, except that it is calculated along the spatial dimension (i.e., height and width). For the first feature map after dimensionality reduction... (C is the number of channels, H and W are the height and width of the feature map, respectively). First, the global average pooling is calculated through the second average pooling layer.

[0063]

[0064] Then, the spatial attention score is calculated through convolutional layers and the sigmoid activation function.

[0065]

[0066] in, and Here, represents the parameters of the convolutional layer, K is the kernel size, * represents the convolution operation, and σ is the sigmoid function. Spatial attention scores are used to weight the input feature map to highlight important spatial locations.

[0067] Finally, the outputs of the spectral attention submodule and the spatial attention submodule are combined. Features are extracted from the dimensionality-reduced feature image based on the attention scores to obtain an attention feature map. The first feature map is then weighted according to the spectral attention scores to obtain a spectral attention feature map. Similarly, the first feature map is weighted according to the spatial attention scores to obtain a spatial attention feature map. Finally, the spectral and spatial attention feature maps are weighted and fused to obtain the final attention feature map.

[0068] Y1=(X⊙A s )⊙A sp

[0069] Here, ⊙ represents element-level multiplication.

[0070] Furthermore, in real-world remote sensing images, different categories may require different feature emphases. For example, some categories may rely more on spectral characteristics, while others may rely more on spatial characteristics. Therefore, to enable the model to better adapt to the feature requirements of different categories, a dynamic weight adjustment module is introduced into the improved convolutional neural network model. This module automatically adjusts the weights of the spectral attention module and the spatial attention module based on the characteristics of each category.

[0071] Therefore, fusing the spectral attention feature map and the spatial attention feature map can also include: assigning a first weight to the spectral attention feature map and the spatial attention feature map based on the degree of dependence of the hyperspectral remote sensing image on spectral characteristics and on spatial characteristics; and performing weighted fusion of the spectral attention feature map and the spatial attention feature map according to the first weight.

[0072] For example, in the dynamic weight adjustment module, the average attention score for each category in the spectral attention module and the spatial attention module is first calculated to obtain two attention vectors. and

[0073] Then, the first weights w of the spectral attention module and the spatial attention module are calculated through a fully connected layer and a softmax activation function. s and w sp The formula for a fully connected layer is as follows:

[0074]

[0075]

[0076] in, and These are the parameters of the fully connected layer.

[0077] Finally, the outputs of the spectral attention module and the spatial attention module are weighted and summed according to their respective weights to obtain the final attention feature map.

[0078] Y2=X⊙(w s A s +w sp A sp )

[0079] It should be understood that the design of the dynamic weight adjustment module enables the improved convolutional neural network model to automatically adjust the weights of the spectral attention module and the spatial attention module according to the characteristics of each category, thereby better adapting to the feature requirements of different categories.

[0080] In operation S140, a multi-scale convolution operation is performed on the first feature map to obtain second feature maps of different scales. The second feature maps of different scales are then weighted and summed to obtain the third feature map.

[0081] In real-world remote sensing images, different features may exhibit the greatest differences at different scales. Therefore, an effective remote sensing image feature extraction method should be able to capture multi-scale feature information. In the improved convolutional neural network model, an adaptive multi-scale feature fusion module is further introduced, which can automatically learn and fuse feature information from different scales.

[0082] For example, in the adaptive multi-scale feature fusion module, the first input feature map is first processed... Perform multi-scale convolution operations to obtain a set of feature maps at different scales. in, H m and W m These are the height and width at the m-th scale. The formula for this multi-scale convolution operation is as follows:

[0083]

[0084] in, It is the convolution kernel at the m-th scale, and * represents the convolution operation.

[0085] In an embodiment of the present invention, the weighted summation of second feature maps at different scales to obtain a third feature map includes: inputting the second feature map at each scale into a third average pooling layer, outputting feature vectors corresponding to the second feature map at each scale; inputting the feature vectors at each scale into a second fully connected layer, calculating the second weights of the feature vectors at each scale; and weighted summing the feature vectors at all scales based on the second weights of the feature vectors at each scale to obtain the third feature map.

[0086] First, perform global average pooling on this set of feature maps to obtain a set of feature vectors. in The formula for global average pooling is as follows:

[0087]

[0088] Then, the weights for each scale are calculated using a second fully connected layer and a Softmax activation function. The formula for the second fully connected layer is as follows:

[0089]

[0090] in, and These are the parameters of the second fully connected layer.

[0091] Finally, this set of feature maps is weighted and summed according to their respective weights to obtain the final feature map.

[0092]

[0093] In operation S150, the attention feature map and the third feature map are fused to obtain the fourth feature map. In an embodiment of the present invention, the fourth feature map can be represented as:

[0094] Y = Y1 + Y2 + Y3

[0095] In operation S160, the fourth feature map is input into the random forest classification model to predict the quality detection result.

[0096] In an embodiment of the present invention, the weight of the decision tree that can accurately classify minority class samples in the random forest classification model is greater than the weight of other decision trees.

[0097] For example, traditional random forests treat all decision trees indiscriminately, resulting in decision trees with different classification performance having the same voting weight. To improve the ability of random forests to identify minority class samples, embodiments of the present invention propose an improved random forest algorithm.

[0098] During the decision tree training phase, the classification performance of each decision tree is evaluated, and decision trees that accurately classify minority class samples are assigned higher weights. The final prediction result is obtained through weighted voting. The prediction result of a random forest is defined as:

[0099]

[0100] Where N is the test set, T is the number of decision trees, I(·) is the indicator function, and f t(N) represents the prediction result of the t-th decision tree, y represents the category, and ω t Let I be the voting weight of the t-th decision tree. The indicator function I(·) is 1 when the prediction result of the decision tree is true, and 0 otherwise.

[0101] Next, a confusion matrix is ​​constructed, in which TP represents a stable sample being classified as a stable sample, FN represents a stable sample being classified as an unstable sample, FP represents an unstable sample being classified as a stable sample, and TN represents an unstable sample being classified as an unstable sample.

[0102] The accuracy P of classifying unstable samples using each decision tree re (precision) and recall R ec The harmonic mean F1 of (recall) is used as the weight of the tree, and the voting weight ω of each tree is used. t Defined as:

[0103]

[0104]

[0105]

[0106] A higher F1 score indicates better classification performance of the decision tree for minority class samples. This study uses an improved random forest machine learning classification model to identify the degree of heavy metal pollution.

[0107] Finally, the model is trained using training samples, and the trained model is used for environmental quality detection and classification.

[0108] It should be noted that the improved convolutional neural network model is trained using the standard backpropagation algorithm. In each training iteration, the model's predictions are first calculated through forward propagation, then the error between the predictions and the true labels is calculated using the loss function, and finally the model's parameters are updated through backpropagation.

[0109] The loss function of the improved convolutional neural network model is cross-entropy loss, which is applied to a batch of training samples. Its loss function L is defined as follows:

[0110]

[0111] Among them, y i p is the true label of the i-th sample. i It is the model's prediction result for the i-th sample.

[0112] Figure 2 A block diagram of an environmental quality detection device provided in an embodiment of the present invention is shown schematically.

[0113] like Figure 2 As shown, the environmental quality detection device 200 includes: a preprocessing module 210, a dimensionality reduction module 220, a calculation module 230, a feature extraction module 240, a convolution module 250, a weighting module 260, a fusion module 270, and a prediction module 280.

[0114] The preprocessing module 210 is used to preprocess the hyperspectral remote sensing image to obtain an enhanced image.

[0115] The dimensionality reduction module 220 is used to reduce the dimensionality of the enhanced image using principal component analysis to obtain the first feature map.

[0116] The calculation module 230 is used to calculate the attention score of the first feature map, wherein the attention score is used to highlight the target features in the dimensionality-reduced feature map.

[0117] The feature extraction module 240 is used to extract features from the dimensionality-reduced feature image based on the attention score to obtain the attention feature map.

[0118] The convolution module 250 is used to perform multi-scale convolution operations on the first feature map to obtain second feature maps of different scales.

[0119] The weighting module 260 is used to perform weighted summation on the second feature maps at different scales to obtain the third feature map.

[0120] The fusion module 270 is used to fuse the attention feature map and the third feature map to obtain the fourth feature map.

[0121] The prediction module 280 is used to input the fourth feature map into the random forest classification model to predict the quality detection result. In the random forest classification model, the weight of the decision tree that can accurately classify minority class samples is greater than the weight of other decision trees.

[0122] It should be noted that the specific implementation details and technical effects of the device embodiment are not the same as those of the method embodiment, and will not be repeated here.

[0123] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. An environmental quality detection method, characterized by, The method comprises the following steps: Preprocessing a hyperspectral remote sensing image to obtain an enhanced image; Performing dimensionality reduction on the enhanced image by principal component analysis to obtain a first feature map; Calculating an attention score of the first feature map, wherein the attention score is used to highlight target features in the first feature map; Extracting features from the first feature map according to the attention score to obtain an attention feature map; Performing multi-scale convolution operation on the first feature map to obtain second feature maps of different scales; Performing weighted summation on the second feature maps of different scales to obtain a third feature map; Fusing the attention feature map and the third feature map to obtain a fourth feature map; Inputting the fourth feature map into a random forest classification model to predict a quality detection result, wherein the weight of a decision tree in the random forest classification model that can accurately classify a small number of class samples is greater than the weight of other decision trees. The method further comprises the following steps: Inputting the first feature map into a first average pooling layer and a first fully connected layer in sequence to calculate a spectral attention score of the first feature map, wherein the spectral attention score is used to highlight target spectral channels by weighting the first feature map; Inputting the first feature map into a second average pooling layer and a convolution layer in sequence to calculate a spatial attention score of the first feature map, wherein the spatial attention score is used to highlight target spatial channels by weighting the first feature map; The method further comprises the following steps: Weighting the first feature map according to the spectral attention score to obtain a spectral attention feature map; Weighting the first feature map according to the spatial attention score to obtain a spatial attention feature map; Assigning a first weight to the spectral attention feature map and the spatial attention feature map according to the dependence of the hyperspectral remote sensing image on spectral characteristics and the dependence on spatial characteristics; Weighting and fusing the spectral attention feature map and the spatial attention feature map according to the first weight.

2. The environmental quality detection method according to claim 1, wherein, The method further comprises the following steps: Obtaining the number of pixels of the enhanced image, the pixel value of each pixel, and the number of spectral channels; Determining a first feature value of each pixel according to the pixel value of each pixel; Calculating an average feature value corresponding to each spectral channel according to the number of pixels, the pixel value of each pixel; Centering the enhanced image according to the first feature value of each pixel and the average feature value corresponding to each spectral channel to obtain feature data corresponding to each spectral channel; Calculating the covariance between any two spectral channels according to the feature data to form a covariance matrix; Solving the second eigenvalue and the unit eigenvector corresponding to the second eigenvalue of the covariance matrix; Determining the first feature map according to the unit eigenvector corresponding to the second eigenvalue greater than a preset threshold.

3. The environmental quality detection method according to claim 1, wherein, The method further comprises the following steps: inputting the second feature map of each scale into a third average pooling layer, and outputting a feature vector corresponding to the second feature map of each scale respectively; inputting the feature vector of each scale into a second full connection layer, and calculating a second weight of the feature vector of each scale; performing weighted summation on the feature vectors of all scales based on the second weight of the feature vector of each scale, to obtain the third feature map.

4. The environmental quality detection method according to claim 1, wherein, The inputting the fourth feature map into the random forest classification model to predict the quality detection result comprises: inputting the fourth feature map into each decision tree to output a plurality of prediction results; performing weighting on the plurality of prediction results based on the weight assigned to each decision tree in advance to obtain the quality detection result.

5. The environmental quality detection method according to claim 4, wherein, The harmonic mean of the precision and recall of each decision tree in classifying the unstable sample is determined as the weight of the corresponding decision tree.

6. The environmental quality detection method of claim 1, wherein, The preprocessing of the hyperspectral remote sensing image to obtain an enhanced image comprises: performing filtering on the hyperspectral remote sensing image by using a nonlinear low-pass filtering method, wherein the mean filtering in the filtering process keeps the pixel value unchanged, and the new value of the pixel is set to the pixel mean value when the difference between the pixel and the pixel mean value falls outside the standard deviation.

7. An environmental quality detecting apparatus characterized by comprising: It comprises: a preprocessing module configured to preprocess a hyperspectral remote sensing image to obtain an enhanced image; a dimension reduction module configured to perform dimension reduction on the enhanced image by using a principal component analysis method to obtain a first feature map; a calculation module configured to calculate an attention score of the first feature map, wherein the attention score is used to highlight target features in the first feature map; a feature extraction module configured to extract features from the first feature map according to the attention score to obtain an attention feature map; a convolution module configured to perform multi-scale convolution operation on the first feature map to obtain second feature maps of different scales; a weighting module configured to perform weighted summation on the second feature maps of different scales to obtain a third feature map; a fusion module configured to fuse the attention feature map and the third feature map to obtain a fourth feature map; a prediction module configured to input the fourth feature map into a random forest classification model to predict a quality detection result, wherein the weight of a decision tree in the random forest classification model that can accurately classify a minority class sample is greater than the weight of other decision trees. The calculation of the attention score of the first feature map comprises: inputting the first feature map into a first average pooling layer and a first full connection layer in sequence to calculate a spectral attention score of the first feature map, wherein the spectral attention score is used to highlight a target spectral channel by weighting the first feature map; inputting the first feature map into a second average pooling layer and a convolution layer in sequence to calculate a spatial attention score of the first feature map, wherein the spectral attention score is used to highlight a target spatial channel by weighting the first feature map; The feature extraction from the first feature map according to the attention score to obtain an attention feature map comprises: weighting the first feature map according to the spectral attention score to obtain a spectral attention feature map; The first feature map is weighted according to the spatial attention score to obtain a spatial attention feature map; The spectral attention feature map and the spatial attention feature map are assigned a first weight according to a degree of dependence on spectral characteristics and a degree of dependence on spatial characteristics of the hyperspectral remote sensing image; The spectral attention feature map and the spatial attention feature map are weighted and fused according to the first weight.

Citation Information

Patent Citations

  • Hyperspectral image classification method based on space-spectrum joint attention mechanism

    CN111563520A

  • Pneumonia X-ray film image analysis model and analysis method based on attention superposition and feature fusion

    CN114066844A