A dual-chessboard autoregressive entropy coding method based on context prior learning

The dual chessboard autoregressive entropy coding method, which utilizes context prior learning, extracts contextual information from medical images using the CP-Net network. This addresses the problem of insufficient utilization of anatomical symmetry and spatial dependence in existing technologies, achieving efficient lossless compression and accurate reconstruction.

CN121940555BActive Publication Date: 2026-06-30HANGZHOU DIANZI UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HANGZHOU DIANZI UNIV
Filing Date
2026-03-24
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

Existing lossless compression methods for medical images have problems with residual modeling accuracy, making it difficult to fully utilize the anatomical symmetry and spatial dependence of the human body, thus limiting compression efficiency.

Method used

A dual chessboard autoregressive entropy coding method based on context prior learning is adopted. The context prior information of medical images is extracted through the CP-Net network, and lossless compression is performed by combining dual chessboard decomposition and autoregressive entropy model, realizing the integrated modeling of lossy and lossless compression.

Benefits of technology

It significantly reduces the encoded bit rate after compression, improves the accuracy of image reconstruction, enhances the storage and transmission efficiency of medical images, and balances compression efficiency with diagnostic fidelity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121940555B_ABST
    Figure CN121940555B_ABST
Patent Text Reader

Abstract

This invention relates to the field of medical image processing and data compression technology, and discloses a dual-chessboard autoregressive entropy coding method based on context prior learning for lossless compression of medical images. This method performs lossy compression on an input single-channel grayscale medical image to obtain a lossy reconstructed image and its residual image. A context prior learning network is used to extract features and generate context for the lossy reconstructed image, achieving structure-aware modeling of the residual features. Based on a dual-chessboard decomposition autoregressive entropy model, the residual image is divided into complementary sub-images. Pixel-level probability estimation is performed by combining context prior and coded block information, and a residual bitstream is generated through arithmetic coding. Finally, the bits are merged to obtain the lossless compressed bitstream of the medical image. This invention effectively reduces the bit rate while ensuring lossless reconstruction quality, is suitable for lossless compression of 2D and 3D medical images, and features high compression efficiency and strong robustness.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of medical image processing and data compression technology, and in particular to a dual chessboard autoregressive entropy coding method based on context prior learning for lossless compression of medical images. Background Technology

[0002] With the continuous iteration of medical technology and imaging equipment such as CT, MRI, and PET, medical institutions generate a massive amount of high-resolution medical images every day, posing a huge challenge to data storage, transmission, and real-time processing. Since medical images carry critical clinical diagnostic information, lossless compression techniques are typically used to meet diagnostic accuracy requirements and support long-term storage and precise comparison.

[0003] Traditional lossless compression methods largely rely on general statistical modeling techniques: for example, PNG format achieves compression through a combination of linear prediction filters, LZ77, and Huffman coding; JPEG2000 introduces Discrete Wavelet Transform (DWT) to support reversible lossless compression; while video coding standards such as HEVC (H.265) and VVC (H.266) support lossless modes in their intra-frame coding mechanisms, their core still relies on intra-block prediction and fixed-frequency transform. However, when processing medical images with complex structures and rich texture details, these traditional methods struggle to fully utilize prior knowledge such as the anatomical symmetry of the human body and deep semantic features inherent in the images, resulting in limited compression efficiency.

[0004] In recent years, deep learning has driven the rapid development of the image compression field: the L3C (Learning-Based Lossless Image Compression) model proposed by Fabian Mentzer et al. uses a hierarchical probabilistic model for pixel prediction; while R. Wang et al. have attempted to combine Gaussian Mixture Models (GMM) with attention mechanisms to capture spatial correlations in images. To integrate the stability of traditional methods with the strong modeling capabilities of deep learning, the "lossy baseline + lossless residual" framework has become the mainstream framework. That is, lossy base layers are generated through traditional encoders such as BPG and VVC, and then neural networks are used to perform lossless compression on the residual information. For example, LC-FDNet (Lossless Image Compression Based on Frequency Decomposition Network) proposed by Rhee et al. and LFC-UNet (Learning-Based Lossless Compression Network Based on Image Decomposition) proposed by Liao et al. both use traditional encoding results as prior information, and the deep network makes more accurate predictions on the remaining parts of the image.

[0005] Despite this, existing lossless compression methods for medical images still suffer from three main problems in residual modeling accuracy. First, the human anatomical structure exhibits subtle deformations, making it difficult for existing convolutional architectures to accurately align and capture the redundant information resulting from such structural symmetry. Second, existing entropy models, when processing residual images, fail to efficiently utilize the long-distance spatial dependencies between non-zero pixels (representing key diagnostic details) and global anatomical structures in the residual image, resulting in insufficient modeling ability for key asymmetric regions such as lesions. Third, existing autoregressive models, when utilizing inter-pixel spatial correlations for entropy encoding, lack refined data decomposition strategies, limiting further reductions in bit rate. Therefore, achieving more accurate residual probability modeling at low bit rates has become a critical technical problem urgently needing to be solved in the field of medical image processing. Summary of the Invention

[0006] To improve the coding efficiency of medical images in lossless compression and fully utilize the anatomical symmetry and structural prior information of medical images, this invention proposes a dual chessboard autoregressive entropy coding method based on a Context-Prior Network (CP-Net). This method achieves integrated modeling of lossy and lossless compression within a collaborative framework of traditional video codecs and deep neural networks, significantly reducing the compressed bit rate (BPP) and improving image reconstruction accuracy.

[0007] To achieve the above objectives, the present invention provides a dual-chessboard autoregressive entropy encoding method based on context prior learning, comprising the following steps:

[0008] Step S1: Obtain the original medical image with single-channel grayscale input width and height of W and H; perform lossy encoding and decoding processing on the original medical image based on video coding standards; generate a lossy bitstream through a VTM video encoder; obtain a lossy reconstructed image through a decoder; obtain the residual image by calculating the pixel-by-pixel difference between the original medical image and the lossy reconstructed image.

[0009] Step S2: Construct a context prior learning network (CP-Net) to extract context prior information from the lossy reconstructed image and perform probabilistic modeling on the residual image. The CP-Net includes a feature extraction module and a context-prior generation module.

[0010] The feature extraction module performs multi-scale feature extraction on the lossy reconstructed image to obtain a high-dimensional feature representation.

[0011] The feature extraction module, from input to output, includes: a first 3×3 convolutional layer (Conv2d 3x3s1), a LeakyReLU activation function, two concatenated feature extraction blocks (FEB_s2, FEB_s1), a second 3×3 convolutional layer, and four concatenated residual blocks; wherein, FEB_s2 uses a convolution with a stride of 2 to achieve downsampling, and FEB_s1 uses a convolution with a stride of 1 to achieve feature refinement; the first 3×3 convolutional layer and the second 3×3 convolutional layer have the same content.

[0012] The high-dimensional feature representation is optimized by the context generation module to generate contextual prior features;

[0013] The context generation module sequentially includes a multi-scale deformable dilated convolution (DefAtrousConv) module, a first affine transformation layer, a structure-aware attention module (SAAB), a feed-forward network, a second affine transformation layer, a residual block (ResBlock), and a context fusion submodule (Context Fusion). The content of the first affine transformation layer and the second affine transformation layer is the same.

[0014] Step S3: Construct an autoregressive entropy model based on double chessboard decomposition, divide the residual image into multiple structurally complementary sub-images, combine contextual prior features and encoded sub-image information to perform pixel-level probability modeling, and generate residual bitstream through arithmetic encoding;

[0015] Step S4: Merge the residual bitstream with the lossy bitstream to obtain a lossless compressed bitstream of medical images;

[0016] Step S5: Decoding stage, the lossy bitstream is decoded by the video decoder to obtain the lossy reconstructed image, the contextual prior information of the lossy reconstructed image is extracted by the CP-Net decoding module, the residual bitstream is decoded by the dual chessboard autoregressive entropy decoding module to obtain the residual reconstructed image, and the two are added pixel by pixel to achieve lossless reconstruction of medical images.

[0017] Furthermore, in S1, the VTM video encoder adopts VTM 23.0 version AllIntra coding mode, with quantization parameter QP=37, to obtain lossy reconstructed image and residual image.

[0018] Furthermore, in S2, the feature extraction module is implemented as follows:

[0019] A 3×3 convolutional layer (Conv2d 3x3 s1) performs feature mapping on the lossy reconstructed image with a stride of 1, converting the single-channel input into a high-dimensional feature map. The number of convolutional kernels is set to 64, and padding=1 to keep the resolution consistent with the input. A non-linear transformation is introduced through the LeakyReLU activation function to enhance the flexibility and generalization ability of feature representation.

[0020] The generated feature stream passes through two concatenated feature extraction blocks (FEBs) in sequence: FEB s2 uses a 3×3 convolutional layer with a stride of 2 to expand the receptive field and compress the spatial dimension to extract global semantic features; FEB s1 uses a 3×3 convolutional layer with a stride of 1 to maintain the spatial resolution and refine the details of the middle layer structure.

[0021] The final feature stream passes through a 3×3 convolutional layer (Conv2d 3x3 s1) and then enters four cascaded standard ResBlock modules, providing high-quality feature representations for subsequent context modeling.

[0022] Furthermore, in S2, the specific implementation methods of each sub-module of the context generation module are as follows:

[0023] (1) Multi-scale deformable dilated convolution (DefAtrousConv) module:

[0024] Parallel dilated convolution branches with different dilation rates are employed to capture contextual dependencies at different scales through multi-layered receptive fields. The outputs of the dilated convolution branches are concatenated with the outputs of parallel deformable convolutions, with the deformable convolutions adaptively adjusting the receptive field shape to align with symmetrical regions of subtle deformation. The concatenated features are then fused through a 1×1 convolutional layer to generate an intermediate feature map containing multi-scale structural alignment features. Finally, this intermediate feature map is added to the input feature map via residual connections. The process is as follows:

[0025]

[0026]

[0027]

[0028]

[0029] in Indicates input features, Indicates channel splicing. Denotes a dilated convolution operation with an inflation rate of d, used to construct multi-layered receptive fields, where The convolution kernel weights are dilation coefficients d. This represents deformable convolution operation. This represents a 1×1 convolution used to fuse multi-scale features and deformable features. Finally, the features processed by the multi-scale deformable dilated convolution module are combined with the original features. Fusion generates features that contain multi-scale contextual information. .

[0030]

[0031] (2) Affine Transform Layer:

[0032] A learnable affine transformation matrix is ​​applied to the feature map output by DefAtrousConv, learned through a Spatial Transformation Network (STN). The affine transformation performs geometric correction on the feature map through sampling operations, further optimizing the alignment accuracy of symmetrical regions and enhancing the structural consistency of the features. Enhance the results using learnable affine transformation matrices in a spatial transformation network. .

[0033] (3) Structure-Aware Attention Module (SAAB):

[0034] The Structure-Aware Attention Module (SAAB) includes a coordinate attention branch and a strippooling spatial attention branch. SAAB integrates the coordinate attention mechanism and the strippooling spatial attention mechanism, and can automatically select and enhance the response to key regions and important semantic features in the image.

[0035] Coordinate attention branch: Global average pooling is performed on the input feature map along the vertical and horizontal directions respectively to generate positional attention weights, which are then multiplied element-wise with the original feature map to enhance positional information; the calculation of the coordinate attention mechanism can be expressed as:

[0036]

[0037] in, Represents the original feature map. and These are the height and width positional attention weights generated from the statistical features after global pooling.

[0038] Strip pooling spatial attention branch: Horizontal and vertical strip pooling are used to aggregate global information from the feature map, modeling long-range dependencies and generating a spatial attention weight map, which is then multiplied element-wise with the feature map enhanced by coordinate attention. The strip pooling spatial attention mechanism can be represented as:

[0039]

[0040] in, Represents the original feature map. and These are the attention weights in the height and width directions, respectively, generated from the local long-range features of strip pooling modeling.

[0041] Normalized Convolutional Units (GNConv): Group normalization is applied before and after the attention branch to alleviate the instability caused by mini-batch training; finally, a 1×1 convolutional layer is used. Integrate attention features;

[0042] The SAAB module represents its calculation formula as follows:

[0043]

[0044] in This indicates a coordinate attention mechanism. This represents the spatial attention mechanism of strip pooling. This is processed for normalized convolutional units.

[0045] (4) Feed-forward network and ResBlock:

[0046] Feedforward networks consist of multiple layers of convolutions and activation functions, enhancing the nonlinear transformation capability of features;

[0047] The feedforward network output, after undergoing an affine transformation layer, is optimized using cascaded ResBlock modules. Residual connections reduce the risk of vanishing gradients. This enhances features. Input feedforward network generates contextual features :

[0048]

[0049] in Indicates channel splicing. This represents a feedforward network. To further correct for symmetry, It is further enhanced by an affine transformation layer, and then processed with the initial features by a residual block (ResBlock). Adding them together gives Finally, we use the context fusion submodule to generate high-quality context priors. , for use in entropy coding.

[0050] (5) Context Fusion submodule:

[0051] The feature map processed in step (4) above is fused with the original feature map output by the feature extraction module, and the global and local context information is fused through a 3×3 convolutional layer.

[0052] Furthermore, the specific implementation of the autoregressive entropy model based on the double chessboard decomposition is as follows:

[0053] (1) Residual image decomposition:

[0054] The first stage adopts a chessboard segmentation strategy, which divides the residual image into two interleaved sub-images according to the parity of the pixel coordinates;

[0055] The second stage further performs odd-even row (or odd-even column) decomposition on each sub-image, ultimately yielding four structurally complementary sub-images; the sub-image decomposition is defined by the following formula:

[0056]

[0057] in and Represents the coordinates of pixels in the residual image. Represents row index, This represents the column index. This hierarchical partitioning method can more effectively capture spatial correlations, improving the accuracy and compression performance of autoregressive probability modeling. For residual images... Perform double chessboard decomposition and extract four sub-images. This lays the foundation for subsequent probability estimation. For simplicity, the above sub-images are represented by... express.

[0058] (2) Autoregressive entropy model:

[0059] The model combines global context features and encoded subgraph Autoregressive information to predict the current subgraph The pixel probability distribution, the main modules include:

[0060] Autoregressive Context Extraction Module: Utilizes a convolutional neural network... Extracting context from encoded subimages :

[0061]

[0062] in, This indicates splicing along the channel dimension.

[0063] The parameter estimation module (ParamEstimator) incorporates the global context. and autoregressive context via the internet Predicted sub-image of (Probability):

[0064]

[0065] in , For batch size, Given the sub-image resolution, predict 511-dimensional probability channels with residual values ​​in the range of [-255, 255]. 511 corresponds to probability channels in the discrete range of [−255, 255].

[0066] When modeling the probability distribution for each sub-image, the prediction is obtained by... A softmax operation is applied to convert the data into a probability mass function (PMF), ensuring that the sum of probabilities over the discrete range [-255, 255] is 1. Next, the PMF is converted into a cumulative distribution function (CDF), normalized, and then input into an arithmetic encoder along with the sub-images to generate a compressed bitstream. The decoding process proceeds in the same order, progressively reconstructing pixel values ​​using the decoded sub-images and global context.

[0067] Furthermore, the dual-chessboard autoregressive entropy encoding method based on context prior learning of the present invention also includes the weighted cross-entropy loss function used in the CP-Net training process, the loss function being defined as:

[0068]

[0069] in and These are the true and predicted probability distributions, respectively. Let M be the weight of the j-th class, M be the number of samples, N = 511 be the number of classes, and the corresponding residual sign range is [-255, 255].

[0070] Based on the residual distribution characteristics, the following adaptive settings are applied: for high-frequency categories with absolute residual values ​​in the range of [-20, 20], lower weights are assigned; for low-frequency categories with absolute residual values ​​greater than 20, higher weights are assigned; the total weights are normalized to match the number of categories, and in actual operation, the residuals are normalized to [0, 510] for processing to ensure the balance of loss calculation.

[0071] The training optimizer uses the Adam optimizer and introduces the ReduceLROnPlateau scheduler. When the loss does not decrease for 5 consecutive epochs of training, the learning rate is reduced to 0.75 of the original value. The total number of training epochs is 200, and an early stopping mechanism (patience=10) is enabled to avoid model overfitting.

[0072] Furthermore, the medical images include single-channel grayscale medical images such as MRI images (e.g., knee MRI, brain MRI) and CT images (e.g., lung CT), and are adapted to common high-resolution medical image data formats in clinical practice (e.g., Numpy array, DICOM format).

[0073] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0074] 1. The present invention provides a dual chessboard autoregressive entropy coding method based on context prior learning, which, in view of the complex anatomical structures and strong spatial dependencies of medical images, can achieve unified optimization of lossy and lossless collaborative compression, structure-aware modeling and pixel-level probability estimation. This method has both high compression ratio and completely lossless reconstruction capability, significantly improving the storage and transmission efficiency of medical images, and has broad clinical and scientific research application value.

[0075] 2. The present invention provides a dual chessboard autoregressive entropy encoding method based on context prior learning, wherein the DefAtrousConv module effectively aligns symmetrical structures with deformation in medical images, reduces feature redundancy, improves the ability to model subtle symmetrical relationships, and makes its multi-scale structure alignment capability strong.

[0076] 3. The present invention provides a dual chessboard autoregressive entropy coding method based on context prior learning. Its SAAB module automatically identifies lesion regions through an attention mechanism, enabling on-demand bit rate allocation, balancing compression efficiency and diagnostic fidelity, and providing adaptive protection for key diagnostic information.

[0077] 4. The present invention provides a dual chessboard autoregressive entropy coding method based on context prior learning. Its dual chessboard decomposition structure can significantly reduce serial dependence while maintaining the spatial dependence between pixels, thereby improving the entropy coding speed. It is suitable for real-time transmission scenarios of medical images and can achieve efficient autoregressive probability modeling. Attached Figure Description

[0078] Figure 1 This is the overall framework for lossless compression of medical images based on the entropy coding method proposed in this invention;

[0079] Figure 2 This invention is based on context prior knowledge. The double chessboard autoregressive entropy coding structure diagram (AE: arithmetic coding);

[0080] Figure 3 This is the network structure of the context prior learning network (CP-Net) constructed in this invention;

[0081] Figure 4 This is a structural diagram of the multi-scale deformable atrous convolution (DefAtrousConv) module in this invention;

[0082] Figure 5 This is a structural diagram of the Structure-Aware Attention Module (SAAB) in this invention;

[0083] Figure 6 This is a diagram of the residual image double chessboard decomposition method in this invention;

[0084] Figure 7 This is a framework diagram of the autoregressive entropy model in this invention;

[0085] Figure 8 For the residual image pixel value frequency histograms of the datasets MRNet-Axial, Lung-CT, and ADNI-MRI;

[0086] Figure 9 The weight distribution diagram for the weighted cross-entropy loss function;

[0087] Figure 10 This is a framework diagram of an inter-frame context prior model based on CP-Net and ConvGRU. Detailed Implementation

[0088] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0089] This invention discloses a dual chessboard autoregressive entropy encoding method based on context prior learning. The following detailed description of the implementation process and technical details will ensure that those skilled in the art can replicate this invention based on this description.

[0090] Example 1

[0091] The present invention discloses a dual chessboard autoregressive entropy encoding method based on context prior learning. Its core implementation logic is a hybrid encoding paradigm of "traditional VTM lossy compression + CP-Net deep learning residual lossless compression". The complete implementation process includes key steps such as image preprocessing, lossy encoding and decoding, CP-Net construction, dataset training and configuration, residual entropy encoding, bitstream merging, and decoding and reconstruction. Each step is closely linked, and finally, lossless compression and reconstruction of medical images are achieved.

[0092] The present invention provides a dual-chessboard autoregressive entropy encoding method based on context prior learning, comprising the following steps:

[0093] Step 1: Medical Image Preprocessing and Lossy Encoding / Decoding Implementation

[0094] Image input: Acquire the original medical image to be compressed. The original medical image is a single-channel grayscale image that supports common medical image resolutions (such as 256×164, 256×256, 300×300, etc.) and covers mainstream medical image types such as MRI (magnetic resonance imaging), CT (computed tomography), and PET (positron emission tomography).

[0095] VTM codec configuration: VVC video codec version VTM 23.0 is used. Lossless compression of 2D medical images uses All Intra (AI) coding mode, and the quantization parameter (QP) is set to 37. This parameter configuration can maximize the redundancy mining space of subsequent residual compression while ensuring the quality of lossy reconstructed images.

[0096] Destructive reconstruction and residual calculation: such as Figure 1 and Figure 2 As shown, the input medical image is lossily encoded by a VTM encoder to generate a lossy bitstream; the lossy bitstream is then decoded by a VTM decoder to obtain a lossy reconstructed image; the original medical image to be compressed is subtracted pixel by pixel from the lossy reconstructed image to calculate a residual image, which reflects the detailed differences between the original medical image and the lossy reconstructed image.

[0097] Step 2: CP-Net network structure construction and entropy coding

[0098] like Figure 3 As shown, the CP-Net network (context-prior learning network) includes a feature extraction module and a context-prior generation module. The specific construction methods of each module are as follows:

[0099] The Feature Extraction module employs a multi-level hybrid structure, sequentially connecting the initial 3×3 convolutional layer (stride 1), the Leaky ReLU activation function, two feature extraction blocks (FEBs2 and FEBs1), a second 3×3 convolutional layer (stride 1), and four residual blocks (ResBlocks) from input to output. The internal structure of each FEB is a concatenated combination of a 3×3 convolutional layer and the Leaky ReLU activation function. FEBs2 uses a convolutional operation with a stride of 2 to expand the receptive field and compress spatial dimensions, while FEBs1 uses a convolutional operation with a stride of 1 to maintain spatial resolution and refine features. For simplified representation... Figure 2 The convolutional layer in the FEB module is "Conv2d 3×3 sn", where sn represents the stride of the convolution and n is the stride size. Each ResBlock contains two 3×3 convolutional layers, a batch normalization layer, and a LeakyReLU activation function. It achieves efficient feature transfer through residual connections and alleviates the gradient vanishing problem.

[0100] The Context-prior Generation module takes the high-dimensional features output by the feature extraction module as input and sequentially builds a multi-scale deformable dilated convolution (DefAtrousConv) module, the first affine transformation layer, the structure-aware attention module (SAAB), the feed-forward network, the second affine transformation layer, the residual block (ResBlock), and the context fusion sub-module (ContextFusion). The content of the first affine transformation layer is the same as that of the second affine transformation layer.

[0101] Multi-scale alignment and feature enhancement: such as Figure 4 As shown, high-dimensional features are input into the DefAtrousConv module, which captures multi-scale contextual dependencies in parallel through dilated convolutions with different dilation rates. Then, deformable convolutions adaptively adjust the receptive field shape to achieve precise alignment of symmetrical regions with subtle deformations in medical images. Multi-scale features and deformable convolution features are fused through a 1×1 convolutional layer, concatenated with the original input features, and activated by LeakyReLU to generate enhanced features.

[0102] Affine transformation correction: An affine transformation is applied to the enhanced features. By learning deformable translation and scaling parameters, subtle deformations in the symmetrical regions are further corrected, thereby improving feature alignment accuracy.

[0103] Structural perception and attention enhancement: such as Figure 5As shown, the features after affine transformation are input into the SAAB module. First, they are grouped and normalized to alleviate batch dependency in mini-batch training. Then, global average pooling is performed in the vertical and horizontal directions through the coordinate attention mechanism to generate positional attention weights to encode positional and channel dependencies. The spatial attention mechanism of strip pooling is used to generate spatial attention weights by employing depthwise separable convolutions in the horizontal and vertical directions to capture long-range structural dependencies. The two attention weights are multiplied element-wise and then input into the normalized convolutional unit to strengthen the coupled expression of channel and spatial attention. Finally, the structure-aware features are output through residual connections.

[0104] Feature fusion and optimization: After the structure-aware features are enhanced with a feedforward network to enhance their nonlinear expressive power, they are further optimized through affine transformation and added to multiple cascaded ResBlock output features to achieve residual fusion. Finally, the local features and global features are fused through the context fusion submodule to generate high-quality contextual prior features, which provide support for subsequent residual probability modeling.

[0105] Autoregressive entropy encoding module: Constructs a dual chessboard decomposition (Split) and autoregressive entropy model. The dual chessboard decomposition implements the sub-image division of the residual image according to the two-stage strategy of "chessboard segmentation + parity decomposition".

[0106] The first stage involves dividing the board, such as... Figure 6 As shown, the image is divided into two staggered sub-regions. In the second stage, parity row (or parity column) decomposition is further performed within each sub-region, ultimately yielding four spatially complementary sub-images. The sub-image decomposition is defined by the following formula:

[0107] (14)

[0108] in and Represents the coordinates of pixels in the residual image. Represents row index, This represents the column index. This hierarchical partitioning method can more effectively capture spatial correlations, improving the accuracy and compression performance of autoregressive probability modeling. For residual images... Perform double chessboard decomposition and extract four sub-images. This lays the foundation for subsequent probability estimation. For simplicity, the above sub-images are represented by... This involves modeling and encoding the subgraphs sequentially.

[0109] like Figure 7As shown, the autoregressive entropy model includes an autoregressive context extraction module (composed of multiple Conv2d 3×3 s1 (3×3 convolutional layers with a stride of 1) connected to the LeakyReLU activation function) and a parameter estimation module (composed of multiple Conv2d 3×3 s1 (3×3 convolutional layers with a stride of 1) connected to the LeakyReLU activation function). The final entropy model output is fed into an arithmetic encoder to generate a bitstream. In this model, global context priors are incorporated. and encoded subgraph Autoregressive information to predict the current subgraph The pixel probability distribution, whose main modules include:

[0110] Autoregressive Context Extraction Module: Utilizes a convolutional neural network... Extracting context from encoded subimages :

[0111] (15)

[0112] in, This indicates splicing along the channel dimension.

[0113] The parameter estimation module (ParamEstimator) incorporates the global context. and autoregressive context via the internet Predicted sub-image of :

[0114] (16)

[0115] in , For batch size, Given the sub-image resolution, the number of probability channels corresponding to the discrete range [−255, 255] is 511.

[0116] When modeling the probability distribution for each sub-image, the prediction is obtained by... A softmax operation is applied to convert the data into a probability mass function (PMF), ensuring that the sum of probabilities over the discrete range [-255, 255] is 1. Next, the PMF is converted into a cumulative distribution function (CDF), normalized, and then input into an arithmetic encoder along with the sub-images to generate a compressed bitstream. The decoding process proceeds in the same order, progressively reconstructing pixel values ​​using the decoded sub-images and global context.

[0117] Step 3: Implement Dataset Training Configuration

[0118] Optimizer settings: The Adam optimizer is used, with an initial learning rate of 1e-4. Momentum parameters β1=0.9 and β2=0.999 are set, and the weight decay coefficient is set to 1e-5. These parameters are used to configure the convergence speed and generalization ability of the balanced model.

[0119] Training batch and epoch settings: Set the batch size (batch_size) to 4 to adapt to small batch training scenarios; set the total number of training epochs to 200 to ensure that the model fully learns the structural features and residual distribution patterns of medical images.

[0120] Learning rate scheduling implementation: The ReduceLROnPlateau learning rate scheduler is introduced, which uses the training set loss as a monitoring metric. When the training set loss does not decrease for 5 consecutive epochs (preset rounds), the current learning rate is reduced to 0.75 of the original value, and the model parameters are gradually refined to improve convergence accuracy.

[0121] Early Stopping Mechanism Implementation: An early stopping mechanism is adopted, using the validation set loss as the monitoring metric. When the validation set loss does not decrease for 10 consecutive epochs (preset rounds), training is immediately stopped and the current optimal model parameters are saved to avoid model overfitting.

[0122] Training acceleration and hardware environment: Mixed precision training (FP16) is used to accelerate convergence and reduce memory usage during training; the hardware environment uses a computing platform equipped with a high-performance GPU (such as NVIDIA RTX 2080Ti and above) to ensure efficient and stable operation of the training process.

[0123] Loss function configuration: The weighted cross-entropy loss function is used to optimize model training. The expression of the loss function is as follows:

[0124] (17)

[0125] in and These are the true and predicted probability distributions, respectively. N is the weight of the j-th class, M is the number of samples. For common 8-bit images, N = 511 is the number of classes, corresponding to the residual sign range [-255, 255].

[0126] like Figure 8As shown, most residual values ​​are concentrated in the range close to 0 (approximately -20 to +20), exhibiting a distinct peak structure, indicating that most pixels have small errors after reconstruction. However, there are still low-frequency residual value regions distributed on both sides, but their numbers are significantly smaller. In this context, if the standard cross-entropy loss function is used directly for model training, the model will tend to prioritize optimizing the prediction performance of high-frequency residual values ​​(such as those near 0) because these regions dominate the samples. Conversely, low-frequency regions (such as those with large absolute residual values) contribute less to the loss due to the scarcity of samples, and the model is prone to ignoring these difficult-to-predict but important regions, leading to modeling bias. To alleviate the above problems, a weighted cross-entropy loss function is introduced as an improvement method.

[0127] Specifically, such as Figure 9 As shown, we assign corresponding weights to each discrete residual value based on the image residual distribution: lower weights to high-frequency regions and higher weights to low-frequency regions. This strategy effectively increases the model's attention to rare but important residual regions, enhancing its generalization ability under complex image structures. It's worth noting that the cross-entropy loss function is suitable for this task because we discretized the residual values, dividing them into 511 possible discrete integer values ​​(e.g., from -255 to 255). For each pixel location, the model outputs a prediction distribution containing 511 probabilities, representing the probability that the pixel residual belongs to each discrete value. In this case, cross-entropy, as a standard for measuring the difference between the true residual distribution and the model's predicted distribution, is a natural and reasonable choice. This approach not only accommodates probabilistic modeling but also efficiently optimizes residual prediction performance through classification.

[0128] Step 4: Implement compressed bitstream merging

[0129] The lossy bitstream generated by VTM lossy encoding in step 1 and the residual compressed bitstream generated by entropy encoding in step 2 are merged sequentially to obtain a lossless compressed bitstream of medical images. The merged bitstream can be used for storage or transmission, which greatly reduces storage space occupation and transmission bandwidth requirements.

[0130] Step 5: Decoding and Reconstruction Implementation

[0131] The decoding process is symmetrical to the encoding process, and the specific implementation steps are as follows:

[0132] Bitstream reception: Receive the merged bitstream after transmission or storage, and separate it into lossy bitstream and residual bitstream.

[0133] Lossy reconstructed image restoration: The lossy bitstream is decoded by the VTM decoder to restore the lossy reconstructed image. The decoding configuration is completely consistent with the VTM configuration in the encoding stage to ensure decoding accuracy.

[0134] Residual reconstruction image restoration: The residual bitstream is decoded by the CP-Net decoding module. According to the encoding order, the residual pixel values ​​are restored block by block by using the global context prior features and the local context of the decoded sub-images. The four restored sub-images are then stitched together to obtain the complete residual reconstruction image.

[0135] Non-destructive reconstruction: The lossy reconstructed image and the residual reconstructed image are added pixel by pixel to obtain the final non-destructive reconstructed image. The non-destructive reconstructed image has no information loss from the original medical image to be compressed, which meets the accuracy requirements of clinical diagnosis and the needs of long-term preservation and accurate comparison.

[0136] To verify the effectiveness of the dual-chessboard autoregressive entropy coding method based on context prior learning of this invention, experimental results were conducted. The method was validated on the publicly available MRNet-Axial medical image dataset using the specific implementation described above. 80% of the images in this dataset were used as the training set, and the remaining 20% ​​as the test set. The results are shown in Table 1. Table 1 uses three evaluation metrics: BPP (bits per pixel), Compression Ratio (the ratio of the number of bits encoded before compression to the number of bits encoded after compression), and Bitrate Saving Ratio (the bitrate saved by other methods compared to the FLIF method, using the FLIF method as a benchmark).

[0137] Table 1 Performance comparison of lossless image compression methods on the MRNet-Axial dataset

[0138]

[0139] As shown in Table 1, all comparative methods and the proposed-2D method employ 2D compression, meaning compression is performed using only the current slice (image). The compression performance of the proposed method is 4.46, Compression Ratio, and BitrateSaving Ratio, respectively. All these indicators are superior to traditional compression methods (PNG, JPEG2000, WebP, FLIF (a free lossless image compression format), JPEG-XL) and existing learning-based compression methods (L3C, LC-FDNet, LFC-UNet), verifying that the present invention significantly improves the compression efficiency of medical images while ensuring lossless reconstruction quality.

[0140] Example 2

[0141] To further verify the adaptability and superiority of this invention in 3D medical image compression scenarios, extended 3D compression experiments were conducted on the MRNet-Axial dataset. This involved using forward and backward reference slices (images) to enhance the compression of the current slice (image). The experiments focused on inter-slice context dependency mining and cross-frame redundancy removal. Specific settings were as follows: VTM 23.0 random access (RA) coding mode was used, with a group of images (GOP) of 16, a quantization parameter (QP) of 37, and a hierarchical B-frame coding structure to determine the reference slice for 3D encoding.

[0142] Indicates the current encoded slice.

[0143] This indicates the forward reference slice (the previously encoded slice).

[0144] This indicates the backward reference slice (the coded next layer slice).

[0145] All three are lossy reconstructed slices output by the VTM decoder, providing structural priors for context modeling between slices.

[0146] like Figure 10 As shown, in the feature extraction stage, the feature extraction module and context generation module of CP-Net are used to respectively extract features... , , High-dimensional feature maps are extracted from three slices to fully capture contextual information such as anatomical symmetry and local structure. In the cross-slice feature fusion stage, a Convolutional Gated Recurrent Unit (ConvGRU) is introduced. The feature maps from the three slices are input along the time dimension in slice order. A dynamic gating mechanism fuses the spatiotemporal dependencies between slices, constructing a global 3D contextual prior, thus compensating for the insufficient utilization of inter-layer redundancy in traditional 2D compression. In the residual coding stage, based on the fused 3D contextual prior, dual chessboard decomposition and autoregressive entropy coding are performed on the residual image of the current slice, fully exploiting the dual redundancy within and between slices to improve overall compression efficiency.

[0147] The experimental results in Table 1 show that, using the 3D compression method (Proposed-3D) of this patent, the image compression BPP is reduced to 4.43, which is 0.03 lower than the BPP of the 2D compression method we proposed above. The Compression Ratio and Bitrate Saving Ratio are improved by 0.006 and 0.6%, respectively. This verifies the significant optimization effect of the 3D context fusion mechanism in inter-layer redundancy mining. Therefore, the 3D context fusion mechanism proposed in this invention can effectively improve the ability to mine and utilize inter-layer redundancy, thereby further improving the compression performance of medical images.

[0148] The embodiments and implementation process of the present invention have been described in detail above with reference to the accompanying drawings and tables, but the present invention is not limited to the described embodiments. For those skilled in the art, various changes, modifications, substitutions, and variations can be made to these embodiments, including components, without departing from the principles and spirit of the present invention, and these variations still fall within the protection scope of the present invention.

Claims

1. A method of double chessboard auto-regressive entropy coding based on context prior learning, characterized in that, Includes the following steps, Step S1: Obtain the original medical image in single-channel grayscale, perform lossy encoding and decoding processing on the original medical image based on video coding standards to generate a lossy bitstream and a lossy reconstructed image; obtain the residual image by calculating the pixel-by-pixel difference between the original medical image and the lossy reconstructed image; Step S2: Construct a context prior learning network, which includes a feature extraction module and a context generation module; perform multi-scale feature extraction on the lossy reconstructed image through the feature extraction module to obtain a high-dimensional feature representation; and optimize the high-dimensional feature representation through the context generation module to generate context prior features. Step S3: Construct an autoregressive entropy model based on double chessboard decomposition, divide the residual image into multiple structurally complementary sub-images, combine contextual prior features and encoded sub-image information to perform pixel-level probability modeling, and generate residual bitstream through arithmetic encoding; Step S4: Merge the residual bitstream with the lossy bitstream to obtain a lossless compressed bitstream of medical images; Step S5: Decoding stage, the lossy bitstream is decoded by the video decoder to obtain the lossy reconstructed image, the context prior learning network is used to extract the context prior information of the lossy reconstructed image, the residual bitstream is decoded by the dual chessboard autoregressive entropy decoding module to obtain the residual reconstructed image, and the two are added pixel by pixel to achieve lossless reconstruction of medical images. The decomposition of the double chessboard includes two stages: The first stage adopts a chessboard segmentation strategy, which divides the residual image into two interleaved sub-images according to the parity of the pixel coordinates; The second stage further performs a parity row or parity column decomposition on each sub-image, resulting in four sub-images The sub-image decomposition is defined by the following equation: ; in and Represents the coordinates of pixels in the residual image. Represents row index, This represents the column index; this hierarchical partitioning method can more effectively capture spatial correlations. The autoregressive entropy model includes an autoregressive context extraction module and a parameter estimation module; wherein, the autoregressive context extraction module uses masked convolution to extract local context features from the encoded sub-image; the parameter estimation module fuses global context prior features and local context features to predict the probability channels with residual values ​​in the range of [-255, 255], and performs arithmetic encoding after Softmax normalization and cumulative distribution function transformation; It also includes the weighted cross-entropy loss function used in the context prior learning network training process, the loss function being defined as: ; in and These are the true and predicted probability distributions, respectively. Let M be the weight of the j-th category, M be the number of samples, N be the number of categories, and the corresponding residual sign range be [-255, 255]. High-frequency categories with residual values ​​in the range of [-20, 20] are assigned lower weights, and low-frequency categories with absolute values ​​greater than 20 are assigned higher weights. The total weights are normalized to be consistent with the number of categories. The method can be applied to two-dimensional medical image compression. It extracts contextual prior features from the lossy reconstructed image, and the autoregressive entropy coding module combines the contextual prior features to perform residual pixel-level probability modeling and arithmetic coding. The method can also be used for 3D medical image compression, using convolutional gated recurrent units to fuse spatiotemporal dependencies between slices.

2. The dual chessboard autoregressive entropy coding method based on context prior learning according to claim 1, characterized in that: The feature extraction module, from input to output, includes: a first 3×3 convolutional layer, a LeakyReLU activation function, two concatenated feature extraction blocks FEB_s2 and FEB_s1, a second 3×3 convolutional layer, and four concatenated residual blocks; wherein, FEB_s2 uses a convolution with a stride of 2 to achieve downsampling, and FEB_s1 uses a convolution with a stride of 1 to achieve feature refinement.

3. The dual chessboard autoregressive entropy coding method based on context prior learning according to claim 2, characterized in that: The context generation module sequentially includes a multi-scale deformable dilated convolution module, a first affine transformation layer, a structure-aware attention module, a feedforward network, a second affine transformation layer, a residual block, and a context fusion submodule. The multi-scale deformable dilated convolution module extracts features in parallel with dilated convolution branches and deformable convolution branches with different dilation rates, then concatenates the channels, fuses the output through 1×1 convolution, and adds the residuals with the input feature map to generate multi-scale structure-aligned features.

4. The dual chessboard autoregressive entropy coding method based on context prior learning according to claim 3, characterized in that: The first affine transformation layer has the same content as the second affine transformation layer. The affine transformation layer learns deformable affine matrices through a spatial transformation network and performs geometric correction on the feature maps output by the multi-scale deformable dilated convolution module to optimize the spatial alignment accuracy of symmetrical structural regions and improve the consistency of features across organ regions.

5. The dual chessboard autoregressive entropy coding method based on context prior learning according to claim 3, characterized in that: The structure-aware attention module includes a coordinate attention branch and a strip pooling spatial attention branch; the coordinate attention branch performs global average pooling along the horizontal and vertical directions to generate positional attention weights; the strip pooling spatial attention branch generates spatial attention weights through horizontal and vertical strip pooling. The two attention branches are connected to the grouping normalization layer before and after, and finally the attention features are fused by 1×1 convolution to enhance the response of key structural regions.

6. The dual chessboard autoregressive entropy coding method based on context prior learning according to claim 3, characterized in that: The context fusion submodule fuses the feature map output by the residual block with the high-dimensional feature map output by the feature extraction module, and then fuses global and local context information through a 3×3 convolutional layer to generate contextual prior features for residual probability modeling.