A fast medical hyperspectral image classification method
By optimizing the neighborhood window scale using cosine similarity tangent mapping and joint data gravity method, the problem of decreased discrimination performance of heterogeneous regions in medical hyperspectral image classification is solved, and efficient and stable classification results are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANDONG UNIV
- Filing Date
- 2023-06-08
- Publication Date
- 2026-06-02
AI Technical Summary
Existing medical hyperspectral image classification methods based on spatial spectral information fusion exhibit reduced discrimination performance in heterogeneous regions, and traditional data gravity classification methods struggle to complete multi-class classification tasks under imbalanced data conditions.
We employ a method based on cosine similarity tangent mapping and joint data gravity. By extracting training samples, setting an initial neighborhood window scale, performing iterative cross-validation, optimizing the neighborhood window scale, and classifying the results by weighted similarity calculation.
It effectively reduces the interference of heterogeneous pixels, adaptively balances the contributions of minority and majority classes, improves the stability and accuracy of classification, and achieves fast and stable medical hyperspectral image classification.
Smart Images

Figure CN116681944B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of hyperspectral image processing technology, specifically to a rapid medical hyperspectral image classification method. Background Technology
[0002] Hyperspectral imaging (HSI) offers significantly higher spectral resolution compared to traditional color digital imagery, typically containing dozens or even hundreds of bands. This rich spectral information provides a basis for accurate target identification, making it widely used in remote sensing. With technological advancements, the advantages of spectral imaging have been applied across various fields, such as archaeological mural preservation, evidence identification, and non-destructive testing of food. Among these, healthcare has become the fastest-growing application area for HSI, driven by the continuous development of medical spectral imaging technology. For medical applications, medical hyperspectral imaging (MHSI) not only provides two-dimensional spatial distribution information of various tissue structures but also obtains the complete spectrum of a point on a biological tissue sample within the wavelength range of interest, enabling analysis of the chemical composition and physical characteristics of different pathological tissues. Therefore, the rapid and accurate classification capabilities of MHSI make non-invasive disease diagnosis and clinical treatment possible.
[0003] When dealing with ultra-complex surfaces, especially when the pixels to be classified are in heterogeneous regions, the discriminative performance of current methods based on spatial spectral information fusion deteriorates due to interference from heterogeneous pixels. The pervasive HSI imbalance problem renders traditional data gravitation-based classification (DGC) methods unsuitable for multidimensional data, as they treat all samples equally, ignoring their individual distributions. In imbalanced data situations, it becomes difficult to complete multi-class classification tasks.
[0004] Therefore, in the case of imbalanced data, how to improve medical hyperspectral image classification methods to enhance the classification speed and stability of pixels in heterogeneous regions has become an urgent problem to be solved. Summary of the Invention
[0005] In view of this, embodiments of the present invention provide a rapid medical hyperspectral image classification method to solve the problem that the distinguishing performance of existing methods based on spatial spectral information fusion is reduced by interference from heterogeneous pixels.
[0006] This invention provides a rapid medical hyperspectral image classification method, including:
[0007] Extract a number of pixels from the medical hyperspectral image to be classified as training samples;
[0008] Set the initial neighborhood window size;
[0009] Based on the initial neighborhood window scale, joint training regions are randomly selected from the medical hyperspectral images to be classified;
[0010] The similarity between each pixel in the joint training region and the training samples is calculated using a joint classification algorithm.
[0011] The optimal neighborhood window scale is obtained by optimizing the initial neighborhood window scale through k iterations of cross-validation algorithm.
[0012] The optimal neighborhood window scale and joint classification algorithm are used to classify all pixels of the medical hyperspectral image to be classified.
[0013] The joint classification algorithms include:
[0014] The first similarity result between the pixel to be classified and the training sample is obtained by using a tangent mapping based on cosine similarity.
[0015] The second similarity result between the pixel to be classified and the training sample is obtained by joint data gravity classification;
[0016] The first similarity result and the second similarity result are weighted and calculated to obtain the classification result of the pixel to be classified.
[0017] Optionally, before extracting several pixels from the medical hyperspectral image to be classified as training samples, the method further includes:
[0018] The spectral values corresponding to each pixel in the medical hyperspectral image to be classified are normalized band by band.
[0019] Optionally, a number of pixels are extracted from the medical hyperspectral image to be classified as training samples, including:
[0020] Based on the actual tissue types in the medical hyperspectral images to be classified, a sample set is extracted.
[0021] Where m is the number of samples; l i ={1, 2, ..., c} represents the label of the i-th sample; c is the number of land cover categories in the medical hyperspectral image to be classified; is a real number; d is the spectral dimension.
[0022] Optionally, the first similarity result between the pixel to be classified and the training samples is obtained through a tangent mapping based on cosine similarity, including:
[0023] Calculate the cosine similarity between the pixel to be classified and each training sample pixel in the feature space;
[0024] Apply tangent mapping to cosine similarity;
[0025] By combining spatial neighborhood calculations, the similarity between each pixel to be classified and training sample pixels of different categories is obtained, thus yielding the first similarity result.
[0026] Optionally, the similarity between each pixel to be classified and training sample pixels of different categories is calculated by combining spatial neighborhood to obtain the first similarity result, including:
[0027] Calculate the third similarity result between the first pixel to be classified and the training sample pixels of different categories;
[0028] Obtain the fourth similarity result between the second pixel to be classified and the training sample pixels of different categories within the spatial neighborhood of the first pixel to be classified.
[0029] Calculate the first average of the third and fourth similarity results;
[0030] The first average value is used as the similarity between the first pixel to be classified and the training sample pixels of different categories.
[0031] Optionally, a second similarity result between the pixel to be classified and the training samples is obtained through joint data gravity classification, including:
[0032] Obtain the Euclidean distance between each pixel to be classified and all training sample pixels within the window scale;
[0033] Based on the similarity between each pixel to be classified and the center pixel of the window scale range, the quality of each pixel to be classified and the quality of the pixels to be classified in the corresponding spatial neighborhood of each pixel to be classified are obtained.
[0034] By combining spatial neighborhood calculations to determine the data attraction of each pixel to be classified to different categories of training sample pixels, a second similarity result is obtained.
[0035] Optionally, by combining spatial neighborhood calculations to determine the data attraction of each pixel to be classified to training sample pixels of different categories, a second similarity result is obtained, including:
[0036] Calculate the first data attraction between the third pixel to be classified and the training sample pixels of different categories;
[0037] Obtain the second data attraction between the fourth pixel to be classified and the training sample pixels of different categories within the spatial neighborhood of the third pixel to be classified.
[0038] Calculate the second average value of the first and second data gravity;
[0039] The second average value is used as the data attraction between the third pixel to be classified and the training sample pixels of different categories.
[0040] Optionally, the initial neighborhood window scale is optimized, including:
[0041] During the k iterations of cross-validation, the center pixel of the joint training region remains unchanged;
[0042] At the end of each iteration of cross-validation, the neighborhood window scale of the joint training region is updated.
[0043] Optionally, after classifying all pixels of the medical hyperspectral image to be classified using the optimal neighborhood window scale and joint classification algorithm, the following steps are also included:
[0044] The confusion matrix is calculated based on the classification results of all pixels of the medical hyperspectral image to be classified using the training samples, and the overall classification accuracy and Kappa coefficient are obtained.
[0045] Optionally, a weighted calculation is performed on the first similarity result and the second similarity result to obtain the classification result of the pixel to be classified, including:
[0046] The first weight corresponding to the first similarity result ranges from 0.3 to 0.7;
[0047] The second weight corresponding to the second similarity result ranges from 0.3 to 0.7;
[0048] The sum of the first weight and the second weight is 1.
[0049] Beneficial effects of the embodiments of the present invention:
[0050] This embodiment proposes a rapid medical hyperspectral image classification method based on similarity tangent mapping and joint data gravity. Based on cosine similarity and joint data gravity, the similarity between samples is measured by weighting the tangent mapping of cosine similarity and the logarithmic value of data gravity. Then, the similarity between the pixel to be classified and different categories is calculated by jointly using local regions, ensuring full utilization of the spatial-spectral information of the hyperspectral image and a balanced use of the majority and minority classes. The pixel to be classified is assigned to the category with the highest contribution similarity, quickly obtaining stable classification results. The similarity between the pixel to be classified and training samples of different categories is calculated by weighted allocation. The cosine similarity after tangent mapping effectively reduces the interference of heterogeneous pixels, and the local similarity data gravity adaptively balances the contributions of the minority and majority classes, thus ensuring full utilization of MHSI spatial-spectral information. By combining pixel-level tangent mapping and the logarithmic representation of data gravity, the clustering of homogeneous pixels and the separability of heterogeneous pixels are effectively increased, resulting in better classification results than traditional classification methods. Attached Figure Description
[0051] The features and advantages of the invention will be more clearly understood by referring to the accompanying drawings, which are schematic and should not be construed as limiting the invention in any way. In the drawings:
[0052] Figure 1 A flowchart of the first rapid medical hyperspectral image classification method in an embodiment of the present invention is shown;
[0053] Figure 2 A flowchart of the second rapid medical hyperspectral image classification method in an embodiment of the present invention is shown;
[0054] Figure 3 A flowchart of the third rapid medical hyperspectral image classification method in an embodiment of the present invention is shown;
[0055] Figure 4 This invention illustrates a real-image marker map of a human brain hyperspectral image according to an embodiment of the invention.
[0056] Figure 5 The image shows the classification results of human brain hyperspectral images obtained using the rapid medical hyperspectral image classification method in this embodiment of the invention. Detailed Implementation
[0057] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0058] This invention provides a rapid medical hyperspectral image classification method, such as... Figure 1 As shown, it includes:
[0059] Step S10: Extract several pixels from the medical hyperspectral image to be classified as training samples.
[0060] In this embodiment, a sample set is extracted from the image based on the actual tissue types in the image. In a specific embodiment, the sample set is extracted based on the actual tissue types in the medical hyperspectral image to be classified.
[0061] Where m is the number of samples; l i ={1, 2, ..., c} represents the label of the i-th sample; c is the number of land cover categories in the medical hyperspectral image to be classified; is a real number; d is the spectral dimension.
[0062] Step S20: Set the initial neighborhood window scale.
[0063] Step S30: Based on the initial neighborhood window scale, randomly select joint training regions from the medical hyperspectral images to be classified.
[0064] In this embodiment, all pixels within the joint training region are test samples.
[0065] Step S40: The similarity between each pixel in the joint training region and the training sample is calculated using a joint classification algorithm.
[0066] Step S50: The initial neighborhood window scale is optimized through k iterations of cross-validation algorithm to obtain the optimal neighborhood window scale.
[0067] In this embodiment, the test sample is randomly divided into k equal parts. K-1 parts of the data are used for training in turn, and 1 part is used for testing. The average of the k results is taken as the accuracy of the estimation to evaluate the window scale R value, thus obtaining the optimal R value. In a specific embodiment, k is 10 times. The window scale R value optimization process is as follows: Figure 2 As shown.
[0068] Step S60: Using the optimal neighborhood window scale and joint classification algorithm, classify all pixels of the medical hyperspectral image to be classified.
[0069] The joint classification algorithms include:
[0070] The first similarity result between the pixel to be classified and the training sample is obtained by using a tangent mapping based on cosine similarity.
[0071] The second similarity result between the pixel to be classified and the training sample is obtained by joint data gravity classification;
[0072] The first similarity result and the second similarity result are weighted and calculated to obtain the classification result of the pixel to be classified.
[0073] In this embodiment, the first weight corresponding to the first similarity result is in the range of 0.3 to 0.7; the second weight corresponding to the second similarity result is in the range of 0.3 to 0.7; and the sum of the first weight and the second weight is 1.
[0074] In a specific embodiment, the first weight and the second weight are preferably 0.5 and 0.5, respectively. This is based on logarithmic data gravity classification and pixel y... i The label is determined in the following way:
[0075]
[0076] In a specific embodiment, through Figure 3 The steps shown enable rapid medical hyperspectral image classification. Addressing the shortcomings of existing spatial spectral classification methods, this embodiment proposes a rapid medical hyperspectral image classification method based on similarity tangent mapping and joint data gravity. By leveraging joint local regions, the similarity between pixels is assessed through tangent mapping of cosine similarity and calculation of average joint gravity. Then, weighted calculations are performed to determine the similarity between the pixel to be classified and training samples of different categories. The cosine similarity after tangent mapping effectively reduces interference from heterogeneous pixels, and the local similarity data gravity adaptively balances the contributions of the minority and majority classes, thus ensuring full utilization of MHSI spatial spectral information. Finally, the category labels of the pixels to be classified are assigned based on the weighted similarity, quickly obtaining stable classification results.
[0077] As an optional implementation, before step S10, the following steps are also included:
[0078] The spectral values corresponding to each pixel in the medical hyperspectral image to be classified are normalized band by band.
[0079] In this embodiment, for the medical hyperspectral images to be classified Where n is the number of pixels in the image, and d is the spectral dimension. Normalization preprocessing is performed, where the normalization process for the spectral value corresponding to the p-th pixel in the j-th band of the image is as follows:
[0080]
[0081] Among them, y p,j The values are normalized spectral values, where min represents the minimum spectral value in the j-th band and max represents the maximum spectral value in the j-th band.
[0082] As an optional implementation, the first similarity result between the pixel to be classified and the training samples is obtained through a tangent mapping based on cosine similarity, including:
[0083] Calculate the cosine similarity between the pixel to be classified and each training sample pixel in the feature space;
[0084] Apply tangent mapping to cosine similarity;
[0085] By combining spatial neighborhood calculations, the similarity between each pixel to be classified and training sample pixels of different categories is obtained, thus yielding the first similarity result.
[0086] In this embodiment, the cosine similarity between the pixel to be classified and each training sample in the feature space is calculated to form a similarity matrix s∈ n×m , pixel y i and training sample x r (xr The cosine similarity of (∈X) is calculated as follows:
[0087]
[0088] The obtained cosine similarity matrix s is mapped to tangent as follows:
[0089]
[0090] Here, ε is a small constant to prevent elements in the cosine similarity matrix s from having infinite values. In a specific embodiment, ε is set to 10. -6 .
[0091] For pixel y i The similarity to class l can be represented by the average similarity of all pixels in its neighborhood. In a specific implementation, the similarity between each pixel to be classified and training sample pixels of different classes is calculated by combining spatial neighborhood, as follows:
[0092] Calculate the third similarity result between the first pixel to be classified and the training sample pixels of different categories;
[0093] Obtain the fourth similarity result between the second pixel to be classified and the training sample pixels of different categories within the spatial neighborhood of the first pixel to be classified.
[0094] Calculate the first average of the third and fourth similarity results;
[0095] The first average value is used as the similarity between the first pixel to be classified and the training sample pixels of different categories.
[0096] In this embodiment, pixel y is first determined. i Pixels {y} within the spatial neighborhood i,1 ,y i,2 ,…,y i,T}, where T = (2R + 1) 2 R is the neighborhood scale, and T is the number of pixels in the neighborhood.
[0097] Neighboring pixels y are selected based on the similarity matrix s. i,u (u∈T) is the highest similarity with all samples of class l. Finally, the mean similarity of all neighboring pixels is used to represent pixel y. i Similarity to class l:
[0098]
[0099] As an optional implementation, a second similarity result between the pixel to be classified and the training samples is obtained through joint data gravity classification, including:
[0100] Obtain the Euclidean distance between each pixel to be classified and all training sample pixels within the window scale;
[0101] Based on the similarity between each pixel to be classified and the center pixel of the window scale range, the quality of each pixel to be classified and the quality of the pixels to be classified in the corresponding spatial neighborhood of each pixel to be classified are obtained.
[0102] By combining spatial neighborhood calculations to determine the data attraction of each pixel to be classified to different categories of training sample pixels, a second similarity result is obtained.
[0103] In this embodiment, the y-value of each pixel in the joint region is calculated. i The Euclidean distance between the sample and all training samples is expressed as:
[0104]
[0105] First determine pixel y i Pixels {y} within the spatial neighborhood i,1 ,y i,2 ,…,y i,T}, where T = (2R + 1) 2 R is the neighborhood scale, and T is the number of pixels in the neighborhood. Setting the local quality of each pixel in the neighborhood to 1, the quality of the u-th pixel within the window can be defined as: M yi,u =1.
[0106] In a specific implementation, the second similarity result is obtained by combining the spatial neighborhood calculation to determine the data attraction of each pixel to be classified to training sample pixels of different categories, including:
[0107] Calculate the first data attraction between the third pixel to be classified and the training sample pixels of different categories;
[0108] Obtain the second data attraction between the fourth pixel to be classified and the training sample pixels of different categories within the spatial neighborhood of the third pixel to be classified.
[0109] Calculate the second average value of the first and second data gravity;
[0110] The second average value is used as the data attraction between the third pixel to be classified and the training sample pixels of different categories.
[0111] In this embodiment, for pixel y i The gravitational force acting on class l∈{1,2,…,c} can be represented by the mean gravitational force of all pixels in the neighborhood. First, in the training set labeled l, based on the distance matrix d... ir Filter the nearest neighbors Then calculate the pixel y in the neighborhood. i,u The gravitational force acting on type l is:
[0112]
[0113] Among them, M x Set to 1, ε is set to 10 -6 .
[0114] y is represented by the gravitational mean of all neighboring pixels. i Gravitational forces acting on type l:
[0115]
[0116] As an optional implementation, optimizing the initial neighborhood window scale includes:
[0117] During the k iterations of cross-validation, the center pixel of the joint training region remains unchanged;
[0118] At the end of each iteration of cross-validation, the neighborhood window scale of the joint training region is updated.
[0119] As an optional implementation, after classifying all pixels of the medical hyperspectral image to be classified using the optimal neighborhood window scale and joint classification algorithm, the method further includes:
[0120] The confusion matrix is calculated based on the classification results of all pixels of the medical hyperspectral image to be classified using the training samples, and the overall classification accuracy and Kappa coefficient are obtained.
[0121] In this embodiment, test samples from the remaining joint training region used for training are used for testing, and the confusion matrix is calculated to obtain the overall accuracy (OA) and Kappa coefficient of the classification. This embodiment records the classification accuracy and standard deviation of 10 randomly selected training sets.
[0122] In a specific embodiment, taking the In-Vivo human brain hyperspectral image dataset as an example, the image contains 826 bands, 127 noisy bands are removed, and 699 bands are retained. The image size is 443×479, and the spatial resolution is 128.7μm.
[0123] Table 1 Classification accuracy and computation time
[0124]
[0125] like Figure 4 , Figure 5 As shown in Table 1, compared with Support Vector Machine (SVM), Joint Nearest Neighbor (JNN), Joint Sparse Representation (JSRC), Joint Data Gravity (JDGC), and Cosine Similarity Tangent Mapping (CSTM) algorithm, the fast hyperspectral image classification method provided in this embodiment can achieve higher classification accuracy and stability.
[0126] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A rapid medical hyperspectral image classification method, characterized in that, include: Extract a number of pixels from the medical hyperspectral image to be classified as training samples; Set the initial neighborhood window size; Based on the initial neighborhood window scale, a joint training region is randomly selected from the medical hyperspectral image to be classified; The similarity between each pixel in the joint training region and the training sample is calculated using a joint classification algorithm. pass k The iterative cross-validation algorithm optimizes the initial neighborhood window scale to obtain the optimal neighborhood window scale. The optimal neighborhood window scale and the joint classification algorithm are used to classify all pixels of the medical hyperspectral image to be classified. The joint classification algorithm includes: The first similarity result between the pixel to be classified and the training sample is obtained by tangent mapping based on cosine similarity; A second similarity result between the pixel to be classified and the training samples is obtained by joint data gravity classification; The first similarity result and the second similarity result are weighted and calculated to obtain the classification result of the pixel to be classified; The first similarity result between the pixel to be classified and the training samples is obtained by using a tangent mapping based on cosine similarity, including: Calculate the cosine similarity between the pixel to be classified and each of the training sample pixels in the feature space; perform tangent mapping on the cosine similarity; combine spatial neighborhood to calculate the similarity between each pixel to be classified and the training sample pixels of different categories, and obtain the first similarity result; The first similarity result is obtained by combining spatial neighborhood calculations to determine the similarity between each pixel to be classified and training sample pixels of different categories, including: Calculate the third similarity result between the first pixel to be classified and the training sample pixels of different categories; obtain the fourth similarity result between the second pixel to be classified and the training sample pixels of different categories within the spatial neighborhood corresponding to the first pixel to be classified; calculate the first average value of the third similarity result and the fourth similarity result; and use the first average value as the similarity between the first pixel to be classified and the training sample pixels of different categories.
2. The rapid medical hyperspectral image classification method according to claim 1, characterized in that, Before extracting several pixels from the medical hyperspectral image to be classified as training samples, the following steps are also included: The spectral values corresponding to each pixel in the medical hyperspectral image to be classified are normalized band by band.
3. The rapid medical hyperspectral image classification method according to claim 1, characterized in that, Several pixels are extracted from the medical hyperspectral image to be classified as training samples, including: Based on the actual tissue types in the medical hyperspectral images to be classified, a sample set is extracted. ; in, m The number of samples; l i ={1, 2, ..., c } indicates the first i The labels of each sample; c The number of land cover categories in the medical hyperspectral image to be classified; It is a real number; d For spectral dimensions.
4. The rapid medical hyperspectral image classification method according to claim 1, characterized in that, Obtaining a second similarity result between the pixel to be classified and the training samples through joint data gravity classification includes: Obtain the Euclidean distance between each pixel to be classified and all the training sample pixels within the window scale range; Based on the similarity between each pixel to be classified and the center pixel of the window scale range, the quality of each pixel to be classified and the quality of the pixels to be classified in the corresponding spatial neighborhood of each pixel to be classified are obtained. The second similarity result is obtained by combining the spatial neighborhood calculation to determine the data attraction of each pixel to be classified to different categories of training sample pixels.
5. The rapid medical hyperspectral image classification method according to claim 4, characterized in that, The second similarity result is obtained by combining spatial neighborhood calculations to determine the data attraction between each pixel to be classified and training sample pixels of different categories. Calculate the first data attraction between the third pixel to be classified and the training sample pixels of different categories; Obtain the second data attraction between the fourth pixel to be classified in the spatial neighborhood of the third pixel to be classified and the training sample pixels of different categories; Calculate a second average value for the first data gravity and the second data gravity; The second average value is used as the data attraction between the third pixel to be classified and the training sample pixels of different categories.
6. The rapid medical hyperspectral image classification method according to claim 1, characterized in that, Optimizing the initial neighborhood window scale includes: exist k During each iteration of cross-validation, the center pixel of the joint training region remains unchanged; At the end of each iteration of cross-validation, the neighborhood window scale of the joint training region is updated.
7. The rapid medical hyperspectral image classification method according to claim 1, characterized in that, After classifying all pixels of the medical hyperspectral image to be classified using the optimal neighborhood window scale and the joint classification algorithm, the method further includes: The confusion matrix is calculated based on the classification results of all pixels of the medical hyperspectral image to be classified using the training samples, and the overall classification accuracy and Kappa coefficient are obtained.
8. The rapid medical hyperspectral image classification method according to claim 1, characterized in that, The first similarity result and the second similarity result are weighted and calculated to obtain the classification result of the pixel to be classified, including: The first weight corresponding to the first similarity result is in the range of 0.3 to 0.7; The second weight corresponding to the second similarity result ranges from 0.3 to 0.7; The sum of the first weight and the second weight is 1.