Cataract classification method and system based on color constancy and frequency domain attention
By introducing color equivariance and frequency domain attention into the cataract classification method, a CFC-Mamba network was constructed, which solved the problems of inconsistent device colors and insufficient perception of high-frequency details, achieving high-precision fine-grained cataract classification and improving the robustness and classification accuracy of the model.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG UNIV OF TECH
- Filing Date
- 2026-02-02
- Publication Date
- 2026-06-23
AI Technical Summary
Existing cataract classification methods suffer from decreased classification accuracy and robustness when faced with inconsistencies in device color and insufficient perception of high-frequency details. In particular, they lack the ability to distinguish between different degrees of cataract severity, especially when it comes to discriminating key edge and fine-grained changes in opacity.
A cataract classification method based on color variability and frequency domain attention is adopted. By constructing a CFC-Mamba classification network, integrating a color variability fusion module and a frequency domain channel attention module, the device-invariant features are extracted and lesion boundary information is enhanced, thereby improving the robustness and fine-grained classification ability of the model.
It effectively solves the problems of color difference and insufficient perception of high-frequency details in equipment, significantly improves the accuracy and clinical applicability of cataract classification, and enhances the ability to perceive the boundary of cataract lesions.
Smart Images

Figure CN121640192B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer vision and medical artificial intelligence technology, specifically relating to a cataract classification method and system based on color variability and frequency domain attention. This method aims to improve the model's robustness to cross-device color differences and its ability to perceive the boundaries of cataract lesions, thereby achieving high-precision, fine-grained cataract classification. Background Technology
[0002] Cataracts are the leading cause of blindness worldwide. Clinical diagnosis and classification of cataracts are crucial for developing treatment plans. However, traditional methods that rely on subjective assessment by doctors suffer from inconsistent standards and low efficiency. Therefore, achieving accurate and automated classification has become an urgent need to promote large-scale screening and tiered diagnosis and treatment.
[0003] In recent years, deep learning-based automated cataract classification methods have made significant progress. However, existing methods generally face two major challenges. First, there is device-dependent color inconsistency. Differences in hardware and parameters between different imaging devices can lead to significant color shifts in slit-lamp images. These lesion-irrelevant color variations can mislead the model, severely limiting its generalization ability and robustness in real-world clinical settings. Second, there is insufficient perception of high-frequency details. While current mainstream Transformer and Mamba architectures excel in modeling the global context of images, they exhibit a bias towards low-frequency information, often neglecting high-frequency components that characterize lesion boundaries and subtle textures. This results in insufficient discriminative power for key edges and fine-grained opacity changes when distinguishing cataracts of different severities. Summary of the Invention
[0004] To address the decline in classification accuracy and robustness caused by differences in device color and insufficient high-frequency perception in existing technologies, this invention proposes a cataract classification method and system based on color variability and frequency domain attention. This system effectively extracts device-invariant features and enhances lesion boundary information by integrating color variability learning and frequency domain channel attention.
[0005] The technical solution provided by this invention is as follows:
[0006] A cataract classification method based on color variability and frequency domain channel attention includes the following steps:
[0007] Step 1: Construct the CFC-Mamba classification network; Build a cataract classification network model based on color variability and frequency domain channel attention enhancement, using the VMamba model as the backbone network to extract multi-scale hierarchical features from the input image; The network includes a color variability fusion module and a frequency domain channel attention module, which are used to extract device-invariant features and enhance high-frequency detail information of lesion boundaries, respectively.
[0008] Step 2: Train the multi-granularity cataract classification network model, as follows:
[0009] Step 2.1: Acquire slit lamp images and uniformly scale them to N×N resolution, then input them into the feature extraction network; extract discriminative features sequentially through a color variability fusion unit, a frequency domain channel attention mechanism, and a classification module;
[0010] Step 2.2: Initialize model weights based on pre-trained parameters and perform multiple rounds of iterative optimization; training uses a cosine annealing mechanism to gradually reduce the learning rate to enhance convergence stability;
[0011] Step 2.3: In each iteration, calculate the objective function value based on the difference between the model prediction results and the actual annotations;
[0012] Step 2.4: The AdamW optimization algorithm is used to continuously reduce the loss function, and the model parameters with the best performance on the validation set are retained during the training process;
[0013] Step 3: Dataset preprocessing; Filter high-quality slit lamp images and divide the filtered slit lamp images into a set number of categories based on existing labels;
[0014] Step 4: Evaluate model performance on the test set: Input the preprocessed slit lamp images into the fully trained network model, and use a combination of metrics such as precision, recall, F1 score, classification accuracy, Matthews Correlation Coefficient (MCC), and Cohen's Kappa Coefficient for quantitative evaluation. The superiority of this method in fine-grained cataract classification tasks is verified through comparative experiments with existing state-of-the-art algorithms.
[0015] Furthermore, step one includes the following steps:
[0016] Step 1.1: The cataract classification network model based on color variability and frequency domain channel attention enhancement comprises a VMamba backbone network, a color variability fusion module (CEFM), a frequency domain channel attention module (FCA), and a classifier. The VMamba backbone network consists of four feature extraction stages, responsible for learning pathological features with different receptive fields from slit-lamp images. The color variability fusion module is composed of color variability convolution (CEConv) branches and cross-attention fusion layers, used to extract device-invariant feature representations. The frequency domain channel attention module is composed of Fourier transform layers, high-frequency filters, and channel attention mechanisms, used to enhance high-frequency detail information of lesion boundaries. The classifier is composed of fully connected layers, which map the enhanced features to the corresponding multi-granularity cataract categories.
[0017] Step 1.2: Before inputting the slit lamp image into the VMamba backbone network, data standardization is first performed, and the size of all samples is uniformly adjusted to 224×224 pixels. Then, the image is reconstructed through a patch embedding layer. This process systematically divides the complete image into several regularly arranged image patches, providing structured input for the subsequent two-dimensional selective state space model. At the same time, the original RGB three-channel image is projected into a 96-dimensional latent space through this embedding layer, thereby improving the model's ability to distinguish subtle pathological features of cataracts.
[0018] Furthermore, step one also includes the following steps:
[0019] Step 1.3: Construct the VMamba backbone network of the cataract classification network model based on color equivariance and frequency domain channel attention enhancement. This network contains four feature extraction stages, named the first, second, third and fourth feature extraction stages in order of network depth. Each stage consists of multiple cascaded VSSBlocks, with the first and second stages each containing two VSSBlocks, the third stage containing nine VSSBlocks, and the fourth stage containing two VSSBlocks. All VSSBlocks maintain a consistent structure, including SS2D state space modules and MLP feedforward networks, but their internal feature dimensions gradually increase with network depth to enhance the model's ability to express complex features.
[0020] Step 1.4: Each feature extraction stage of the VMamba backbone network is equipped with a downsampling module. This downsampling module is used to reduce the spatial resolution of the feature map and simultaneously increase the feature channel dimension to achieve multi-scale feature modeling. Specifically, downsampling uses a 3×3 convolution kernel with a stride of 2, which reduces the length and width of the feature map to half of its original size, while expanding the number of channels to twice its original size, gradually increasing from 96 dimensions to 192 dimensions, 384 dimensions, and finally reaching 768 dimensions, thereby realizing the reconstruction and compression of feature dimensions.
[0021] Furthermore, step one also includes the following steps:
[0022] Step 1.5: Construct a color equivariance fusion module, which consists of a color equivariance convolution branch and a cross-attention fusion layer. The color equivariance convolution extracts robust feature representations for device color changes. The input image is first processed by CEConv with a 3×3 kernel size and a stride of 2, outputting 64 channels and 3 rotational equivariance features. Then, a 1×1 convolution projects the number of channels to 192 dimensions, aligning it with the feature dimensions of the first stage of the backbone network. Finally, a cross-attention mechanism is used to deeply fuse these features with the hierarchical features extracted by the backbone network, generating enhanced feature representations.
[0023] Step 1.6: Construct a frequency domain channel attention module. This module first transforms the spatial features to the frequency domain through discrete Fourier transform, applies a circular high-pass filter to retain the high-frequency components representing the lesion boundary, and sets the filter radius to 20% of the feature map size. Then, it reconstructs the spatial features through inverse Fourier transform. Finally, it combines a dual-path channel attention mechanism (using global average pooling and global max pooling simultaneously) to adaptively calibrate the weights of the feature channels, highlighting the feature information that is important for the classification task.
[0024] Step 1.7: The classifier of the multi-granularity cataract classification network model consists of fully connected layers. First, the final features are processed by layer normalization. Then, the spatial dimension is compressed to 1×1 through global average pooling. Finally, the 768-dimensional features are mapped to 10 fine-grained cataract categories through fully connected layers to complete the final multi-granularity classification task.
[0025] Furthermore, in step 1.2, the mathematical relationship of the image segmentation operation is expressed as follows: convolution kernel size = segment size × segment size, where the segment size is 4, and the convolution kernel size is 4×4 accordingly.
[0026] Furthermore, in step 1.3, the input-output dimensional transformation relationship of the four feature extraction stages of the network is defined as follows: the initial spatial size of the input slit lamp image is 224 pixels × 224 pixels, and the four sequentially connected feature extraction stages follow the following dimensional recursive relationship: the output feature dimension of the first stage is 56 × 56 × 96; the output feature dimension of the second stage is 28 × 28 × 192; the output feature dimension of the third stage is 14 × 14 × 384; and the output feature dimension of the fourth stage is 7 × 7 × 768.
[0027] Furthermore, in step 1.3, each VSSBlock uses the SS2D state-space model for sequence modeling, and captures long-distance dependencies through a selective scanning mechanism. Its core calculation process is based on the following state-space equation:
[0028] ;
[0029] ;
[0030] in, Indicates a hidden state. Given the input sequence, For the output sequence, , , , is a learnable parameter matrix.
[0031] Furthermore, in step 1.5, the execution process of color-equivariant convolution is as follows: First, the input image is processed using color-equivariant convolution, which is mathematically expressed as:
[0032] ;
[0033] in, For relative color rotation Learnable weights are used to ensure that the extracted features are equally variable to device-induced tone shifts; subsequently, the equally variable color features are fused with the backbone network features through a cross-attention mechanism. The calculation process is as follows:
[0034] ;
[0035] in, Obtained by projection from backbone network features. It is obtained by projection of color and other variable features, thus achieving an effective fusion of invariant features of the equipment and structural features.
[0036] Furthermore, in step 1.6, the execution process of the frequency domain channel attention module is as follows:
[0037] Given an input feature map First, it is transformed to the frequency domain using a two-dimensional discrete Fourier transform:
[0038] ;
[0039] A high-pass filter was then applied. Preserve high-frequency components:
[0040] ;
[0041] The filtered frequency domain features are mapped back to the spatial domain using an inverse Fourier transform:
[0042] ;
[0043] Finally, the feature channel weights are adaptively calibrated using a channel attention mechanism.
[0044] ;
[0045] Where GAP and MaxP represent global average pooling and global max pooling, respectively. This is the Sigmoid function.
[0046] Furthermore, in step 1.7, the detailed process of cross-attention fusion is as follows: Given color-variable features... and FCA-enhanced skeletal features Calculated through the cross-attention fusion module:
[0047] ;
[0048] in, , Attn represents the standard attention computation process. This fusion mechanism effectively combines the advantages of color-robust features and detail-enhancing features.
[0049] The process of step three is as follows:
[0050] Step 3.1: Screen the original slit lamp images according to image quality criteria, focusing on the integrity of the lens structure, and remove samples with reflective occlusion or blurred key areas;
[0051] Step 3.2: Perform region cropping on qualified images to ensure that the anatomical structure of the lens occupies the dominant area in the image;
[0052] Step 3.3: For categories with a small number of samples, merge them reasonably based on the similarity of pathological characteristics;
[0053] Step 3.4: Finally, construct a standardized dataset containing ten fine-grained categories: nuclear cataract (grades II-V), cortical cataract (grades I-IV), posterior subcapsular cataract, and normal lens. Use a stratified sampling strategy to divide the dataset into training, validation, and test sets.
[0054] Furthermore, the process of step four is as follows:
[0055] Step 4.1: Deploy the optimal model weights obtained from training on the test set for comprehensive performance evaluation. Quantitative analysis is performed by calculating precision, recall, F1 score, accuracy, Matthews correlation coefficient, and Cohen's Kappa coefficient.
[0056] Step 4.2: For ten fine-grained categories, including nuclear cataracts (grades 2-5), cortical cataracts (grades 1-4), posterior subcapsular cataracts, and non-cataracts, calculate the classification performance index for each category, analyze the differences in model performance in different cataract severity classifications, and identify the model's strengths and weaknesses in specific categories.
[0057] Step 4.3: Comparative Experiment Verification; The proposed method is compared with mainstream cataract classification algorithms under the same experimental environment, including CNN-based methods (ResNet series, VGG series), Transformer-based methods (ViT, DeiT) and Mamba-based methods (VMamba, Vim). Rigorous statistical tests are used to demonstrate the effectiveness and superiority of the proposed method in multi-granularity cataract classification scenarios.
[0058] A cataract classification system based on color variability and frequency domain channel attention includes:
[0059] The CFC-Mamba network building module is used to build a color equivariance and frequency domain attention-enhanced classification network framework based on the VMamba backbone, integrating a color equivariance fusion module and a frequency domain channel attention module.
[0060] The multi-granularity cataract classification network training module is used to perform the model training process, including learning rate warm-up and cosine annealing scheduling, AdamW optimizer optimization, loss function calculation and optimal weight saving;
[0061] The slit lamp image preprocessing module is used to perform quality screening, uniform cropping, data augmentation, and category balancing on the input image to generate standardized data that meets the requirements of network input.
[0062] The multi-granularity cataract classification test module is used to load the optimal model weights, perform forward inference calculations, output prediction results for ten fine-grained categories, and generate a detailed performance evaluation report.
[0063] The advantages of this invention are: it solves the problems of poor model generalization ability and low classification accuracy caused by color differences in imaging devices, insufficient perception of high-frequency features of lesion boundaries, and the complexity of fine-grained classification tasks in the prior art; it can effectively extract device-independent color robust features, enhance the perception of lesion boundary details, and significantly improve the accuracy and clinical applicability of fine-grained cataract classification. Attached Figure Description
[0064] Figure 1 This is a schematic diagram of the overall structural design of the CFC-Mamba cataract classification network proposed in this invention.
[0065] Figure 2 This is a schematic diagram of the entire data preprocessing process used in this invention.
[0066] Figure 3 This is a schematic diagram illustrating the complete workflow of the model based on the present invention during the inference phase.
[0067] Figure 4 This is a schematic diagram of the overall training process and final classification process of the model of the present invention.
[0068] Figure 5 This is a schematic diagram of the Color Equivalent Fusion Module (CEFM) of the present invention.
[0069] Figure 6 This is a schematic diagram of the frequency-channel attention module (FCA) structure of the present invention. Detailed Implementation
[0070] The present invention will now be further described with reference to the accompanying drawings.
[0071] Reference Figures 1-6 A cataract classification method based on color equivariance and frequency domain attention is proposed. The method specifically includes four core steps: CFC-Mamba network structure design, model training process, dataset preprocessing method, and classification performance testing.
[0072] Slit-lamp imaging, a crucial tool for clinical cataract diagnosis, clearly reveals details of ocular anatomy, particularly the morphological characteristics of lens opacity. Current methods for acquiring slit-lamp images primarily utilize digital slit-lamp microscope systems. These systems integrate a specialized slit-lamp device with a high-resolution digital camera, significantly enhancing overall image contrast and spatial resolution while strengthening the visual representation of pathological features within the lens area, providing ophthalmologists with more reliable imaging evidence for disease assessment. However, in practical applications, differences in color reproduction between different imaging devices, coupled with often unclear lesion edge features, collectively limit the performance of existing deep learning models in terms of cross-device generalization ability and classification accuracy. To address these issues, this invention constructs the CFC-Mamba classification framework based on the characteristics of slit-lamp images. By introducing a color-variable feature fusion mechanism and a frequency-channel attention module, it effectively achieves fine-grained and accurate classification of cataract lesions.
[0073] The cataract classification method based on color variability and frequency domain attention in this embodiment includes the following steps:
[0074] Step 1: Construct a cataract classification network model based on color variability and frequency domain channel attention enhancement (CFC-Mamba) to enable the model to obtain robust representation and accurate discrimination ability of multi-level cataract features in slit-lamp images. The process is as follows:
[0075] Step 1.1: The cataract classification network model based on color variability and frequency domain channel attention enhancement includes a VMamba backbone network, a color variability fusion module (CEFM), a frequency domain channel attention module (FCA), and a classifier. The VMamba backbone network includes four feature extraction stages for extracting multi-scale pathological feature information from slit-lamp images layer by layer. The color variability fusion module consists of a color variability convolution (CEConv) branch and a cross-attention fusion layer for extracting device-invariant feature representations. The frequency domain channel attention module consists of a Fourier transform layer, a high-pass filter, and a dual-path channel attention mechanism for enhancing high-frequency detail information at lesion boundaries. The classifier consists of fully connected layers that map the enhanced features to the corresponding multi-granularity cataract categories.
[0076] Step 1.2: Before inputting the image into the VMamba backbone network, the original slit lamp image is first normalized and uniformly adjusted to 224×224 pixels. Then, a patch embedding layer is used to perform feature transformation on the image. This operation realizes the image block processing, dividing the image into regions of fixed size evenly, providing a foundation for the subsequent SS2D state space model calculation. At the same time, the original 3-channel image is mapped into a 96-dimensional feature space, thereby enhancing the network's ability to represent fine-grained features of cataracts.
[0077] Step 1.3: Construct the VMamba backbone network of the cataract classification network model based on color equivariance and frequency domain channel attention enhancement. This network contains four feature extraction stages, named the first, second, third, and fourth feature extraction stages in order of network depth. Each stage consists of multiple cascaded VSSBlocks, with the first and second stages each containing two VSSBlocks, the third stage containing nine VSSBlocks, and the fourth stage containing two VSSBlocks. All VSSBlocks maintain a consistent structure, including SS2D state space modules and MLP feedforward networks, but their internal feature dimensions gradually increase with network depth to enhance the model's ability to express complex features.
[0078] Step 1.4: Each feature extraction stage of the VMamba backbone network is equipped with a downsampling module. This downsampling module is used to reduce the spatial resolution of the feature map and simultaneously increase the feature channel dimension to achieve multi-scale feature step-by-step modeling. Specifically, downsampling uses a 3×3 convolution kernel with a stride of 2, which reduces the length and width of the feature map to half of its original size, while expanding the number of channels to twice its original size, gradually increasing from 96 dimensions to 192 dimensions, 384 dimensions, and finally reaching 768 dimensions, thereby achieving feature dimension reconstruction and compression.
[0079] Step 1.5: Construct a color equivariant fusion module, which consists of a color equivariant convolution branch and a cross-attention fusion layer. The color equivariant convolution extracts robust feature representations for device color changes. The input image is first processed by color equivariant convolution with a 3×3 kernel and a stride of 2, outputting 64 channels and 3 rotational equivariant features. Then, a 1×1 convolution projects the number of channels to 192 dimensions, aligning it with the feature dimensions of the first stage of the backbone network. Finally, a cross-attention mechanism is used to perform deep fusion of these features with the hierarchical features extracted by the backbone network. The process of color-equivariant convolution is as follows: First, the input image is processed using color-equivariant convolution. The core idea is to use learnable weights to model relative color rotation, ensuring that the extracted features are equivariant to the hue shift caused by the device. Then, the color-equivariant features are fused with the backbone network features through a cross-attention mechanism. The query vector is obtained by projecting the backbone network features, and the key vector is obtained by projecting the color-equivariant features. The device-invariant features and structural features are effectively fused through layer normalization and residual connections.
[0080] Step 1.6: Construct the frequency domain channel attention module. This module first transforms the spatial features to the frequency domain through discrete Fourier transform, applies a circular high-pass filter to retain the high-frequency components representing the lesion boundary, and sets the filter radius to 20% of the feature map size. Then, it reconstructs the spatial features through inverse Fourier transform. Finally, it adaptively calibrates the feature channel weights using a dual-path channel attention mechanism to highlight the feature information that is important for the classification task. The execution process of the frequency domain channel attention module is as follows: Given an input feature map, it is first transformed to the frequency domain through two-dimensional discrete Fourier transform. Then, a high-pass filter is applied to retain the high-frequency components. The filtered frequency domain features are mapped back to the spatial domain through inverse Fourier transform. Finally, it combines the channel attention mechanism and uses a dual-path structure of global average pooling and global max pooling, with multilayer perceptron and sigmoid function to adaptively calibrate the feature channel weights.
[0081] Step 1.7: The classifier of the multi-granularity cataract classification network model consists of fully connected layers. First, the final features are processed by layer normalization. Then, the spatial dimension is compressed to 1×1 through global average pooling. Finally, the 768-dimensional features are mapped to 10 fine-grained cataract categories through fully connected layers to complete the final multi-granularity classification task. The detailed process of cross-attention fusion is as follows: Given color isovariant features and backbone features enhanced by frequency domain channel attention, the cross-attention fusion module is used for calculation. The query vector is obtained by one-dimensional convolution and flattening operation of the enhanced backbone features, and the key value vector is obtained by the same processing of color isovariant features. The effective fusion of color robust features and detail enhancement features is achieved through multi-head attention mechanism, layer normalization and residual connection.
[0082] Step 2: Train the multi-granularity cataract classification network model, as follows:
[0083] Step 2.1: Acquire clinical slit lamp images and preprocess them to a uniform resolution of 224×224 pixels, then input them into the feature extraction backbone network; the data flows through the color variability fusion module and the frequency domain channel attention enhancement module in sequence, and finally generates prediction results through the classifier;
[0084] Step 2.2: Initialize the weights using model parameters pre-trained on large datasets such as ImageNet, and perform an end-to-end iterative training process; during the training period, the cosine annealing algorithm periodically decays the learning rate until it reaches the preset minimum threshold, thereby promoting the stable convergence of model parameters in the later stages of training;
[0085] Step 2.3: Within each training iteration, the classification error is quantified using the cross-entropy loss function based on the difference between the model's prediction results and the expert-annotated true labels.
[0086] Step 2.4: The AdamW optimization algorithm with weight decay is used to minimize the loss function, and the performance on the validation set is continuously monitored throughout the training process. The model parameters that achieve the highest classification accuracy on the validation set are retained as the final deployment model.
[0087] Step 3: Dataset preprocessing; Filter high-quality slit lamp images and divide the filtered slit lamp images into ten categories according to existing labels, as follows;
[0088] Step 3.1: Perform quality screening on the acquired raw slit-lamp images. Key screening criteria include: ensuring that the anatomical structure of the lens is fully presented in the image and the image is clear; removing invalid samples that are overexposed or optically obstructed in key pathological areas of the lens due to strong light source reflection, thereby ensuring the reliable extraction of cataract-related image features.
[0089] Step 3.2: Perform standardized cropping on qualified images that have passed quality screening. Adjust the image composition so that the target area of the lens occupies the main visual range of the image, thereby increasing the proportion of effective features in the input.
[0090] Step 3.3: To address the issue of insufficient sample size in certain categories, categories with similar lesion characteristics and adjacent severity are reasonably merged based on clinical pathology knowledge to maintain the balance of data distribution;
[0091] Step 3.4: After systematic quality control and category optimization, the final dataset contains ten clinically significant fine-grained categories, specifically including: nuclear cataracts (grades II-V), cortical cataracts (grades I-IV), posterior subcapsular cataracts, and normal lens; the dataset is divided into three independent parts—training set, validation set, and test set—in a stratified random sampling method at a ratio of 6:2:2.
[0092] Step 4: Cataract Test Set Testing; Input the preprocessed slit-lamp images into the trained network model, and evaluate the overall performance of the model. The process is as follows:
[0093] Step 4.1: Load the optimized weight parameters into the model and perform a comprehensive performance evaluation on the independent test set. The quantitative evaluation metrics used include: precision, recall, F1 score, accuracy, Matthews correlation coefficient, and Cohen's Kappa coefficient.
[0094] Step 4.2: For ten fine-grained categories, including nuclear cataracts (grades 2 to 5), cortical cataracts (grades 1 to 4), posterior subcapsular cataracts, and non-cataracts, calculate the classification performance index for each category, analyze the differences in model performance in different cataract severity classifications, and identify the model's strengths and weaknesses in specific categories.
[0095] Step 4.3: Comparative Experiment Verification; The proposed method is compared with mainstream cataract classification algorithms under the same experimental environment, including CNN-based methods (ResNet series, VGG series), Transformer-based methods (ViT, DeiT) and Mamba-based methods (VMamba, Vim). Rigorous statistical tests are used to demonstrate the effectiveness and superiority of the proposed method in multi-granularity cataract classification scenarios.
[0096] This embodiment also provides a cataract classification system based on color variability and frequency domain attention, the system comprising:
[0097] The CFC-Mamba network building module is used to build a color equivariance and frequency domain attention-enhanced classification network framework based on the VMamba backbone, integrating a color equivariance fusion module and a frequency domain channel attention module.
[0098] The multi-granularity cataract classification network training module is used to perform the model training process, including cosine annealing scheduling, AdamW optimizer optimization, loss function calculation, and optimal weight saving.
[0099] The slit lamp image preprocessing module is used to perform quality screening, uniform cropping, data augmentation, and category balancing on the input image to generate standardized data that meets the requirements of network input.
[0100] The multi-granularity cataract classification test module is used to load the optimal model weights, perform forward inference calculations, output prediction results for ten fine-grained categories, and generate a detailed performance evaluation report.
[0101] The above technical solutions correspond to the specific implementation content of steps one to four in Embodiment 1.
[0102] The embodiments described in this specification are merely examples of implementations of the inventive concept and are for illustrative purposes only. The scope of protection of this invention should not be considered limited to the specific forms described in these embodiments; rather, it extends to equivalent technical means conceived by those skilled in the art based on the inventive concept.
Claims
1. A cataract classification method based on color variability and frequency domain attention, characterized in that, The method includes the following steps: Step 1: Construct the CFC-Mamba classification network and build a cataract classification network model based on color variability and frequency domain channel attention enhancement. The cataract classification network model based on color variability and frequency domain channel attention enhancement includes a VMamba backbone network, a color variability fusion module CEFM, a frequency domain channel attention module FCA, and a classifier. The VMamba model is used as the backbone network to extract multi-scale hierarchical features from the input image, namely device-invariant features and high-frequency detail information that enhances the lesion boundary. Step 2: Train the multi-granularity cataract classification network model, as follows: Step 2.1: Acquire slit lamp images and uniformly scale them to N×N resolution, input them into a cataract classification network model based on color equivariance and frequency domain channel attention enhancement, and extract discriminative features; Step 2.2: Initialize model weights based on pre-trained parameters and perform multiple rounds of iterative optimization; training uses a cosine annealing mechanism to gradually reduce the learning rate to enhance convergence stability; Step 2.3: In each iteration, calculate the objective function value based on the difference between the model prediction results and the actual annotations; Step 2.4: The AdamW optimization algorithm is used to continuously reduce the loss function, and the model parameters with the best performance on the validation set are retained during the training process; Step 3: Dataset preprocessing; Filter high-quality slit lamp images and divide the filtered slit lamp images into a set number of categories based on existing labels; Step 4: Evaluate model performance on the test set: Input the preprocessed slit lamp images into the fully trained network model and use the set indicators for quantitative evaluation.
2. The cataract classification method based on color variability and frequency domain attention as described in claim 1, characterized in that, Step one includes the following steps: Step 1.1: The cataract classification network model based on color variability and frequency domain channel attention enhancement comprises a VMamba backbone network, a color variability fusion module CEFM, a frequency domain channel attention module FCA, and a classifier. The VMamba backbone network consists of four feature extraction stages, responsible for learning pathological features with different receptive fields from slit-lamp images. The color variability fusion module is composed of a color variability convolution CEConv branch and a cross-attention fusion layer, used to extract device-invariant feature representations. The frequency domain channel attention module is composed of Fourier transform layers, high-frequency filters, and channel attention mechanisms, used to enhance high-frequency detail information at lesion boundaries. The classifier is composed of fully connected layers, which map the enhanced features to the corresponding multi-granularity cataract categories. Step 1.2: Before inputting the slit lamp image into the VMamba backbone network, data standardization is first performed, and the size of all samples is uniformly adjusted to N×N pixels. Then, the image is reconstructed through a patch embedding layer. This process systematically divides the complete image into several regularly arranged image blocks, providing structured input for the subsequent two-dimensional selective state space model. At the same time, the original RGB three-channel image is projected into the latent space through this embedding layer.
3. The cataract classification method based on color variability and frequency domain attention as described in claim 2, characterized in that, Step one also includes the following steps: Step 1.3: Construct the VMamba backbone network of the cataract classification network model based on color equivariance and frequency domain channel attention enhancement. This network contains four feature extraction stages, named the first, second, third, and fourth feature extraction stages in order of network depth. Each stage consists of multiple cascaded VSSBlocks, with the first and second stages each containing two VSSBlocks, the third stage containing nine VSSBlocks, and the fourth stage containing two VSSBlocks. All VSSBlocks maintain a consistent structure, including SS2D state space modules and MLP feedforward networks, but their internal feature dimensions gradually increase with network depth to enhance the model's ability to express complex features. Step 1.4: Each feature extraction stage of the VMamba backbone network is equipped with a downsampling module. This downsampling module is used to reduce the spatial resolution of the feature map and simultaneously increase the feature channel dimension to achieve step-by-step modeling of multi-scale features.
4. The cataract classification method based on color variability and frequency domain attention as described in claim 3, characterized in that, Step one also includes the following steps: Step 1.5: Construct a color equivariance fusion module, which consists of a color equivariance convolution branch and a cross-attention fusion layer. The color equivariance convolution extracts robust feature representations for device color changes. The input image is first processed by CEConv, and then a 1×1 convolution projects the number of channels to a set dimension, aligning it with the feature dimensions of the first stage of the backbone network. Finally, a cross-attention mechanism is used to deeply fuse these features with the hierarchical features extracted by the backbone network, generating enhanced feature representations. Step 1.6: Construct a frequency domain channel attention module. First, the spatial features are transformed to the frequency domain through discrete Fourier transform. A circular high-pass filter is applied to retain the high-frequency components that characterize the lesion boundary. Then, the spatial features are reconstructed through inverse Fourier transform. Finally, the weights of the feature channels are adaptively calibrated by combining a dual-path channel attention mechanism to highlight the feature information that is important for the classification task. Step 1.7: The classifier of the multi-granularity cataract classification network model consists of fully connected layers. First, the final features are processed by layer normalization. Then, the spatial dimension is compressed to 1×1 through global average pooling. Finally, the features are mapped to a set number of fine-grained cataract categories through fully connected layers to complete the final multi-granularity classification task.
5. The cataract classification method based on color variability and frequency domain attention as described in claim 4, characterized in that, In step 1.5, the execution process of color isovariant convolution is as follows: First, the input image is processed using color isovariant convolution to ensure that the extracted features are isovariant to the hue shift caused by the device; then, the color isovariant features are fused with the backbone network features through a cross-attention mechanism to achieve effective fusion of device-invariant features and structural features.
6. The cataract classification method based on color variability and frequency domain attention as described in claim 4, characterized in that, In step 1.6, the execution process of the frequency domain channel attention module is as follows: Given input feature map First, it is transformed to the frequency domain using a two-dimensional discrete Fourier transform, and then a high-pass filter is applied. High-frequency components are preserved, and the filtered frequency domain features are mapped back to the spatial domain through inverse Fourier transform. Finally, the feature channel weights are adaptively calibrated by combining a channel attention mechanism.
7. The cataract classification method based on color variability and frequency domain attention as described in any one of claims 1 to 6, characterized in that, The process of step three is as follows: Step 3.1: Screen the original slit lamp images according to image quality criteria, focusing on the integrity of the lens structure, and remove samples with reflective occlusion or blurred key areas; Step 3.2: Perform region cropping on qualified images to ensure that the anatomical structure of the lens occupies the dominant area in the image; Step 3.3: For categories with a small number of samples, merge them reasonably based on the similarity of pathological characteristics; Step 3.4: Finally, construct a standardized dataset containing a set number of fine-grained categories, and use a stratified sampling strategy to divide it into training set, validation set and test set.
8. The cataract classification method based on color variability and frequency domain attention as described in any one of claims 1 to 6, characterized in that, The process of step four is as follows: Step 4.1: Deploy the optimal model weights obtained from training on the test set for comprehensive performance evaluation. Quantitative analysis is performed by calculating precision, recall, F1 score, accuracy, Matthews correlation coefficient, and Cohen-Kappa coefficient. Step 4.2: For ten fine-grained categories, including nuclear cataracts (grades 2 to 5), cortical cataracts (grades 1 to 4), posterior subcapsular cataracts, and non-cataracts, calculate the classification performance index for each category, analyze the differences in model performance in different cataract severity classifications, and identify the model's strengths and weaknesses in specific categories. Step 4.3: Comparative Experiment Verification; Under the same experimental environment, the proposed method is compared with existing cataract classification algorithms, including CNN-based methods, Transformer-based methods, and Mamba-based methods. Statistical tests are used to demonstrate the effectiveness and superiority of the proposed method in multi-granularity cataract classification scenarios.
9. A system for implementing the cataract classification method based on color variability and frequency domain attention as described in claim 1, characterized in that, The system includes: The CFC-Mamba network building module is used to build a color equivariance and frequency domain attention-enhanced classification network framework based on the VMamba backbone, integrating a color equivariance fusion module and a frequency domain channel attention module. The multi-granularity cataract classification network training module is used to perform the model training process, including learning rate warm-up and cosine annealing scheduling, AdamW optimizer optimization, loss function calculation and optimal weight saving; The slit lamp image preprocessing module is used to perform quality screening, uniform cropping, data augmentation, and category balancing on the input image to generate standardized data that meets the requirements of network input. The multi-granularity cataract classification test module is used to load the optimal model weights, perform forward inference calculations, and output prediction results for ten fine-grained categories.