Pathological whole slide image lossless secondary compression method and device based on hierarchical prediction and reference selection network and medium
Patent Information
- Application Number
- CN202611480870.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-22
- Publication Date
- 2026-10-27
AI Technical Summary
[0005]本发明实施例提供了一种基于层次预测与参考选择网络的病理全切片图像无损二次压缩方法、装置及介质,针对现有端到端神经压缩技术因像素域生成式机制存在病理伪影幻觉与破坏瓦片随机访问的缺陷,而传统无损重压缩技术局限于单瓦片内部统计且无法消除跨瓦片与跨层级的层次冗余,同时缺乏抑制算力浪费与文件体积膨胀的有效屏障等问题
1.本发明的解析过程仅在变换系数域执行可逆语法解析,不执行反量化、逆变换或像素重建;系数预测主路径为编解码两端相同的确定性整数规则,神经网络仅输出参考类别、概率参数与有界整型偏置,禁止输出任何病理图像像素;解码端通过预测系数与完整残差的定点整数加法精确恢复原量化变换系数,预测误差只增大残差而不破坏可逆恢复,从根本上排除了生成式模型对细胞形态、组织染色的改动风险,满足病理归档对像素一致性的严格要求。
Smart Images

Figure CN122989902A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of digital pathological image processing and data compression technology, and in particular to a method, apparatus and medium for lossless secondary compression of whole pathological slide images based on hierarchical prediction and reference selection networks. Background Technology
[0002] Digital whole-slide images (WSI) typically employ a multi-resolution pyramid structure for tissue analysis. A single slide is divided into tens of thousands to hundreds of thousands of tiles at the highest magnification, resulting in uncompressed data volumes ranging from gigabytes to tens of gigabytes. To meet standard storage and transmission requirements, existing pathology scanners and medical image archiving systems generally use industry-standard formats such as JPEG or JPEG2000 to perform independent primary compression on each tile and encapsulate them into specific medical image containers.
[0003] However, the scale of existing pathology image data is expanding exponentially, posing a severe storage cost challenge to medical institutions for long-term compliant archiving. To further reduce storage space, existing technologies are mainly evolving along two routes: One approach is end-to-end neural image compression technology based on deep learning, which typically employs autoencoder structures, latent variable quantization, and super-prior entropy models to replace traditional codecs. These methods primarily operate on the original RGB pixel domain, relying on deep neural networks to generate image textures from latent variable sampling at the decoding end. However, in medical and pathological scenarios, generative decoding mechanisms carry the risk of uncontrollable phantom artifacts, easily causing subtle cellular morphological changes, nuclear staining artifacts, and even the sudden appearance or disappearance of crucial micro-lesions, violating the absolute compliance red lines of pathological diagnosis and judicial evidence preservation. Simultaneously, the global latent variable flow deeply couples the entire slice, disrupting the tile indexing system and causing the millisecond-level random access mechanism for regions of interest (ROIs), crucial for clinical image interpretation, to fail.
[0004] Secondly, there are lossy or lossless secondary compression techniques for single images, such as arithmetic recoding in the discrete cosine transform (DCT) quantization coefficient domain using a learned conditional probability model. These techniques treat each tile as an independent, closed entity. Because pathological sections exhibit significant tissue continuity, consistent staining tone, and pyramidal scale correlations on the same slide, single-tile encoders cannot perceive spatial neighborhood redundancy across tile boundaries, scale redundancy from coarse low-magnification to fine high-magnification, and long-range semantic redundancy of homogeneous tissue structures. Furthermore, if existing recompression schemes directly perform complex candidate trial calculations and deep inference on the entire image without differentiation, when facing high-entropy tiles such as high-frequency noise or complex tumor infiltration areas, the increase in metadata can easily outweigh the savings in residuals, leading to negative secondary compression benefits (i.e., file size increases instead of decreasing), and causing significant unnecessary computational consumption at the encoding end. Summary of the Invention
[0005] This invention provides a lossless secondary compression method, apparatus, and medium for pathological whole-slice images based on hierarchical prediction and reference selection networks. It addresses the shortcomings of existing end-to-end neural compression technology, which suffers from pathological artifacts and random access to destroyed tiles due to pixel-domain generative mechanisms. Traditional lossless recompression technology is limited to statistics within a single tile and cannot eliminate hierarchical redundancy across tiles and levels. It also lacks effective barriers to suppress computational waste and file size expansion.
[0006] The core technology of this invention is to construct a finite candidate reference set containing spatial, scale, semantic, and prototype information and a physically isolated dual context on the quantization transformation coefficient domain of the encoded tiles. The target reference is selected by using lightweight network probabilistic sorting combined with actual code length trial encoding. Based on deterministic integer prediction rules, conditional probability residual entropy encoding and two-level anti-expansion gating, a lossless secondary compressed slice file with bounded reference depth tile-level index is generated under non-generative constraints.
[0007] In a first aspect, the present invention provides a lossless secondary compression method for whole-slice pathological images based on a hierarchical prediction and reference selection network, the method comprising the following steps: The system analyzes pathological whole-slice images that have completed first-level tile encoding, and extracts the integer quantization transformation coefficients, encoding head parameters, and pyramid geometry of each tile in the transformation coefficient domain; the analysis process does not perform inverse quantization, inverse transformation, or pixel reconstruction. The tiles are organized according to a causal processing order where the coarse resolution layer precedes the fine resolution layer, and tiles within the same layer are processed in a preset spatial order. Tiles that have completed secondary encoding are included in the referenceable set, and the maximum reference depth of the current tile relative to the referenced tile is limited to a preset upper limit. Extract coding end features from the quantization transform coefficients of the current tile, and generate a finite set of candidate references for the current tile based on the pyramid geometry, coding end features, and referenceable set, including at least two of the following: spatial neighborhood candidate references, pyramid parent layer candidate references, encoded similar candidate references, and organizational prototype candidate references. For each candidate reference, a candidate summary is generated and a candidate validity mask is set. An encoding decision context for reference decision and a decodeable context for synchronous reproduction at the decoding end are constructed respectively. The encoding decision context contains the encoding end features and the candidate summary of each candidate reference. The decodeable context contains the candidate summary and the candidate validity mask, but does not contain the quantization transformation coefficients of the current tile and its directly derived features. Compression benefit prediction is performed based on the coding decision context. When the predicted net data saving does not meet the first condition, the current tile is pre-marked as bypass mode and subsequent reference selection is skipped. When the predicted net data saving amount meets the first condition, the reference selection model is used to rank each candidate reference probabilistically according to the coding decision context and candidate validity mask. Based on the predetermined number of candidate references ranked first, the target reference and reference category are determined according to the criterion of minimizing the actual total number of coding bits, and the reference category and the corresponding reference identifier are written into the tile index. Based on the determined reference category, prediction coefficients are generated from the quantization transformation coefficients of the target reference through the deterministic integer prediction rules preset at both ends of the encoding and decoding. Calculate the integer residual between the quantization transform coefficients and the predicted coefficients of the current tile. Use the residual probability model to generate an integer frequency table based on the decodeable context, the determined reference category, and the causal history of the coded residuals in the current frequency band. Then, perform reversible entropy coding on the integer residuals accordingly. The actual total number of bits of coding obtained by using the target reference coding is compared with the actual number of bits of coding of the first-level tile directly using the bypass mode. The actual total number of bits of coding includes the reference identifier and category overhead, residual bitstream overhead, model side information overhead, and index table incremental overhead. The secondary compression load is retained only when the actual net number of bits saved meets the second condition; otherwise, the compression mode is forced to fall back to the bypass mode. The compression mode, reference category, reference identifier, reference depth, load storage offset, and model file identifier of each tile are written into the tile-level index and encapsulated to generate a secondary compressed pathological slide file that supports local random access to the region of interest. The input to the residual probability model does not include the current tile quantization transformation coefficients that have not yet been recovered; the outputs of both the reference selection model and the residual probability model are not used as pathological image pixels.
[0008] Furthermore, a finite set of candidate references is generated for the current tile, including at least two of the following: spatial neighborhood candidate references, pyramid parent layer candidate references, encoded similarity candidate references, and organizational prototype candidate references. Use the coded tiles in the referenceable set that are spatially adjacent to the current tile as spatial neighborhood candidate references; Use the previous coarse-resolution tile in the referenceable set that overlaps with the area covered by the current tile's physical coordinates as a candidate reference for the pyramid's parent layer. By using the feature vector extracted from the quantization transform coefficients of the current tile, similar tiles are retrieved from the anchor tiles in the referenceable set as encoded similar candidate references through locality-sensitive hashing; Extract the organizational prototypes built from anchor tiles and written into the file header during the coarse-resolution encoding stage as organizational prototype candidate references; Missing candidate references are filled with preset values and are indicated as invalid by a candidate validity mask.
[0009] Furthermore, the target reference and reference category are determined based on a predetermined number of candidate references ranked high, using a criterion of minimizing the actual total number of coding bits. This includes: The classification probability of each candidate reference is output using the reference selection model, and the top one to three candidate references with the highest probabilities are selected to form a short list of trial codes. For each candidate reference in the short list of trial coding, deterministic prediction and residual entropy coding are performed separately, and the actual total number of coding bits, including reference identifier and category overhead, residual bitstream overhead, model side information overhead, and index table incremental overhead, are calculated. The candidate reference with the smallest actual total number of coding bits is selected as the target reference.
[0010] Furthermore, by using the deterministic integer prediction rules pre-set at both ends of the encoding and decoding, prediction coefficients are generated from the quantization transformation coefficients of the target reference, including: When the reference category is a spatial neighborhood reference or an encoded similar reference, the quantization transformation coefficients of the reference tile are aligned and copied to the current grid according to the block coordinates; When the reference category is the pyramid parent layer reference, the DC conversion coefficient grid of the parent tile is amplified by fixed-point integer interpolation according to the physical overlap relationship between the two layers of tiles, the low-frequency AC conversion coefficient is copied, and the high-frequency AC conversion coefficient is set to zero. When the reference category is the organization prototype reference, only the DC conversion coefficients and the preset low-frequency coefficient group are predicted; When the bias enable flag indicates that prediction bias is enabled, the bias model generates a bounded small integer prediction bias based only on the decodeable context and reference category. The bounded small integer prediction bias is then extended to a preset frequency band position and superimposed on the baseline prediction coefficients output by the deterministic integer prediction rule. The bias model does not input the quantization transformation coefficients of the current tile.
[0011] Furthermore, invertible entropy encoding is performed on the integer residuals, including: The calculated integer residuals are split into luminance and chrominance channels, and DC and AC frequency band components. The residual probability model strictly isolates the true quantization transformation coefficients of the current tile and outputs discrete Laplace scale parameters or mixed probability distribution parameters of zero and non-zero amplitudes based on the decodeable context, the determined reference category and the historical statistics of the solved frequency bands. A normalized integer frequency table is constructed based on the probability distribution parameters, and the residual bit streams of each stream are generated by an rANS encoder or an arithmetic encoder. When the encoding end features of the current tile need to be input into the residual probability model, the corresponding features are written as side information before the residual bit stream.
[0012] Furthermore, an anchor tile is set every predetermined number of tiles in the same resolution layer. The anchor tile only uses bypass mode or only allows referencing the previous coarse resolution tile or file header organization prototype. Encoded similar candidate references are only allowed to point to encoded anchor tiles or coarse-resolution layer tiles; The maximum reference depth limit for dependency chains that can be established for any fine-resolution layer tile is set to 1 or 2 to limit the number of topology unroll dependencies during local parsing at the decoding end.
[0013] Furthermore, before writing the tile load into the secondary compressed pathological slide file, a reversible closed-loop verification step is performed: The same prediction coefficient generation rules and integer residual summation logic as the encoding end are called to reconstruct the restored quantization transform coefficients and then assemble the first-level bitstream in reverse. Compare each byte of the assembled Level 1 bitstream with the original input Level 1 bitstream; If any byte is inconsistent between the two, the compression mode of the current tile is forcibly changed from the reference mode to the bypass mode, and the uncompressed first-level tile bitstream is directly written.
[0014] Secondly, the present invention provides a lossless secondary compression device for whole-slice pathological images based on a hierarchical prediction and reference selection network, comprising: The syntax parsing module is used to parse the pathological whole slice image that has completed the first-level tile encoding. It extracts the integer quantization transformation coefficients, encoding head parameters and pyramid geometry of each tile in the transformation coefficient domain. The parsing process does not perform inverse quantization, inverse transformation or pixel reconstruction. The causal scheduling module is used to organize the tiles according to the causal processing order of coarse resolution layer before fine resolution layer and within the same layer according to the preset spatial order. It includes the tiles that have completed secondary encoding into the referenceable set and limits the maximum reference depth of the current tile relative to the referenced reference tile to not exceed the preset upper limit. The context construction module is used to extract encoding end features from the quantization transform coefficients of the current tile, generate a finite set of candidate references based on the pyramid geometry, encoding end features, and referenceable sets, including at least two of the following: spatial neighborhood candidate references, pyramid parent layer candidate references, encoded similar candidate references, and organizational prototype candidate references. It generates candidate summaries for each candidate reference and sets a candidate validity mask. It constructs an encoding decision context containing encoding end features and candidate summaries, as well as a decodeable context containing candidate summaries and candidate validity masks but not containing the quantization transform coefficients of the current tile and their directly derived features. The prediction gating module is used to predict compression benefits based on the coding decision context. When the predicted net data saving does not meet the first condition, the current tile is pre-marked as bypass mode and subsequent reference selection is skipped. The reference selection module is used to use the reference selection model to rank each candidate reference probabilistically according to the coding decision context and candidate validity mask when the predicted net data saving amount meets the first condition. Based on the predetermined number of candidate references ranked first, the target reference and reference category are determined according to the criterion of minimizing the actual total number of coding bits, and the reference category and the corresponding reference identifier are written into the tile index. The deterministic prediction module is used to generate prediction coefficients from the quantization transformation coefficients of the target reference based on a determined reference category and through the deterministic integer prediction rules preset at both ends of the encoder and decoder. The residual entropy coding module is used to calculate the integer residual between the quantization transform coefficients and the prediction coefficients of the current tile. It uses the residual probability model to generate an integer frequency table based on the decodeable context, the determined reference category, and the causal history of the encoded residuals in the current frequency band, and performs reversible entropy coding on the integer residuals accordingly. The actual gating module is used to compare the actual total number of bits of coding obtained by using the target reference coding with the actual number of bits of coding of the first-level tile directly using the bypass mode. The secondary compression load is retained only when the actual net number of bits saved meets the second condition; otherwise, the compression mode is forced to fall back to the bypass mode. The file container encapsulation module is used to write the compression mode, reference category, reference identifier, reference depth, load storage offset, and model file identifier of each tile into the tile-level index, and encapsulate and generate a secondary compressed pathological slide file that supports local random access to the region of interest. The input to the residual probability model does not include the current tile quantization transformation coefficients that have not yet been recovered; the outputs of both the reference selection model and the residual probability model are not used as pathological image pixels.
[0015] Thirdly, the present invention provides an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the above-described method for lossless secondary compression of pathological whole-slice images based on hierarchical prediction and reference selection networks.
[0016] Fourthly, the present invention provides a readable storage medium storing a computer program, which, when executed by a processor, implements the lossless secondary compression method for pathological whole-slice images based on hierarchical prediction and reference selection networks as described above.
[0017] The main contributions and innovations of this invention are as follows: 1. The parsing process of this invention performs reversible syntax parsing only in the transform coefficient domain, without performing inverse quantization, inverse transform, or pixel reconstruction; the main path of coefficient prediction follows the same deterministic integer rules at both ends of the encoding and decoding, and the neural network only outputs the reference class, probability parameters, and bounded integer bias, prohibiting the output of any pathological image pixels; at the decoding end, the original quantized transform coefficients are accurately recovered by fixed-point integer addition of the predicted coefficients and the complete residuals. The prediction error only increases the residuals without destroying the reversible recovery, fundamentally eliminating the risk of generative models altering cell morphology and tissue staining, and meeting the strict requirements of pathological archiving for pixel consistency.
[0018] 2. This invention constructs a finite candidate reference set that includes spatial neighborhood, pyramid parent layer, coded similar tiles, and tissue prototypes. It integrates the staining continuity of neighboring tiles, the low-pass correspondence between coarse and fine layers, the coefficient statistical similarity of similar tissues at a distance, and the staining tone and scanning band characteristics of the whole piece into prediction and probabilistic modeling. This significantly improves the sharpness of the residual distribution and achieves a compression rate superior to single-tile recompression and pure regular secondary compression.
[0019] 3. This invention employs a two-stage gating mechanism: the front stage predicts compression gains based on the coding decision context, pre-marks tiles that are not worth processing in depth and bypasses reference selection, saving inference and computational overhead; the back stage compares the actual total number of bits of the reference mode, which includes reference identifiers, residual loads, probability edge information and index increments, with the actual number of bits of the bypass mode, and retains the secondary compression load only when the actual net savings meet the conditions, otherwise it forces a fallback to the bypass mode, thus ensuring that the size of the secondary compressed file is no larger than the original file, and the negative gains of complex high-density organized regions are completely suppressed.
[0020] 4. This invention uses a causal order encoding where coarse layers precede fine layers, combined with upper limits on reference depth and periodic anchor point constraints, to ensure that the size of the reference closure required for decoding the region of interest is bounded. The tile-level index records the compression mode, reference category, reference identifier, reference depth, and payload offset tile by tile. The decoding end only needs to locate the target tile and its limited dependencies according to the index, without decompressing the entire slice, which meets the needs of image reading workstations, remote consultations, and artificial intelligence inference for rapid access to local patches.
[0021] 5. After the reference category and reference identifier of the present invention are written into the tile index, the decoding end does not need to run the reference selection model; when the residual probability model adopts the fixed frequency table in the file header and turns off the integer bias, the decoding end can completely avoid running the neural network and only perform deterministic rule prediction, entropy decoding and integer addition, so that the integration cost of the image reading software is close to that of ordinary codecs, forming an asymmetric deployment form with intelligent encoding end and light load on decoding end.
[0022] 6. The model of this invention is deployed by referencing the model file and distributing it with the software. Only the file number is saved in the file and no network weight is written, which ensures the size of the single file and the security of the version. The encoding end shortens the entire candidate set to a short list of a few candidates through a single network forward pass, replacing the repeated trial encoding of all candidates. While maintaining the actual code length limit, it reduces the encoding latency of batch archiving, so that the compression process can be connected to the acquisition pipeline for online execution.
[0023] Details of one or more embodiments of the present invention are set forth in the following drawings and description, so that other features, objects and advantages of the invention will be more readily understood. Attached Figure Description
[0024] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this invention, illustrate exemplary embodiments of the invention and are used to explain the invention, but do not constitute an undue limitation of the invention. In the drawings: Figure 1 This is the unified coding main line of S1-S10 and the S11 / S12 relationship flow of the lossless secondary compression method for pathological whole slice images based on hierarchical prediction and reference selection network according to an embodiment of the present invention. Figure 2 This is a schematic diagram illustrating the construction of four types of compressed domain contexts according to an embodiment of the present invention; Figure 3 This describes the relationship between the reference selection network, the rule prediction kernel, and the residual probability model according to an embodiment of the present invention. Figure 4 This is a schematic diagram of a secondary compression container, ProfileID, and tile index according to an embodiment of the present invention; Figure 5 This is a schematic diagram of the lossless secondary compression device module according to an embodiment of the present invention; Figure 6 This is a structural diagram of a deployment embodiment of the present invention, in which the encoding end has AI and the decoding end has no AI. Figure 7 This is a schematic diagram of the ROI local decoding timing according to an embodiment of the present invention. Detailed Implementation
[0025] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with one or more embodiments of this specification. Rather, they are merely examples of apparatuses and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.
[0026] It should be noted that the steps of the corresponding methods are not necessarily performed in the order shown and described in this specification in other embodiments. In some other embodiments, the methods may include more or fewer steps than described in this specification. Furthermore, a single step described in this specification may be broken down into multiple steps in other embodiments; and multiple steps described in this specification may be combined into a single step in other embodiments.
[0027] In the description of this invention, the term "first condition" refers to whether the predicted net data saving amount reaches a preset computing power balance threshold during the predicted revenue gating stage; the term "second condition" refers to whether the actual net bit saving reaches a preset anti-expansion safety threshold during the actual bit gating stage. The term "encoding end feature" refers to the numerical description extracted from the quantization transformation coefficients of the current tile and used for encoding end decision-making; the term "decodeable context" refers to context information that the decoding end can independently reconstruct, independent of the actual quantization transformation coefficients of the current tile; the term "candidate digest" refers to the descriptive data extracted from the compressed domain information of candidate references at a uniform fixed size.
[0028] For ease of description, the compression method and apparatus of this invention are collectively referred to as HP-TSC (Hierarchical Predictive Tile Secondary Compression). This invention uses a single current tile... As a unit of processing, the following symbols are used throughout the entire encoding and decoding process: Indicates the first The original level 1 bitstream of each tile; Indicates from Integer quantization transform coefficients obtained from syntax parsing; This represents the first-level encoding header parameters, such as the quantization table, entropy encoding table, and sampling factor. It means that it cannot be made by and The scan event, padding bit, or vendor-specific segment are the only deducible bypass bytes. Indicates the tile's layer, row and column number, and physical coordinates; This indicates the final compression mode generated by the encoding end for this tile, including the reference mode ( ) and bypass mode ( ); Indicates the selected reference category; The physical identifier of the selected specific reference object; Indicates the prediction coefficient; Represents integer residuals; Indicates the final tile load. Unless otherwise specified, the subscripts above indicate the symbols. All refer to the current processing number. A tile.
[0029] Model file By revenue gating model Reference selection model Residual probability model And optional integer bias model constitute. Offline training and localization are performed before deployment, as identified by the model file. Unique identifier. Except for the revenue gating and reference selection phases, any model input that needs to be reproduced at the decoding end can only come from a decoded reference, file header parameters, categories already written to the index, or solved causal residuals; it cannot rely on current tile quantization transform coefficients that have not yet been recovered. .
[0030] It should be noted that the outputs of the models involved in each step of this invention (reference selection model, residual probability model, revenue gating model, bias model) are limited to the reference class, distribution parameters, gating scalar and bounded integer bias. Under no circumstances will RGB or YCbCr color domain pixels, inverse quantization coefficients or reconstructed tile images be output. The decoding process is a fixed-point integer addition recovery of the predicted coefficients and the complete residual. The prediction error only increases the residual without changing the reversible recoverability.
[0031] Example 1 The input for this embodiment is a pathological whole-slice image that has been completed with JPEG, JPEG2000, or other first-level tile encoding, and its container format can be SVS, OME-TIFF, or DICOMWSI. Figure 1 As shown, online encoding executes steps S1 to S10 sequentially; region of interest (ROI) decoding executes step S11; and offline training and model solidification execute step S12.
[0032] This implementation provides two levels of fidelity: the first is a byte-level archived lossless file, which requires that the restored first-level bitstream be identical to the original first-level bitstream byte by byte. In this level, bypass bytes must be extracted and saved simultaneously. The second is to diagnose pixel-level consistency, which only requires the recovery of quantization transformation coefficients. Bypass information The original scan structure is consistent with the actual scan structure, and after inverse quantization and inverse transformation, diagnostic pixels consistent with the original first-level tiles are obtained. Two settings can be configured and selected according to archiving requirements.
[0033] like Figure 2As shown, the candidate references of the present invention include four types: spatial reference 201, scale reference 202, semantic reference 203, and global reference 204. After being concatenated into a compressed domain tensor by context construction 205, they are used by subsequent networks 206 (gating, selection, or probabilistic models). The network input is a DC grid and a frequency band summary, rather than RGB pixels.
[0034] like Figure 3 As shown, the compressed domain context 301 is input to the local branch 302 and the global branch 303 respectively. After feature fusion 304, the reference decision is output by the reference selection network 305. The deterministic prediction kernel 306 and the optional integer bias head 307 jointly generate prediction coefficients. The current tile quantization coefficient 308 only enters the residual calculation at the encoding end. The resulting residual 309 is output by the residual probability model 310 as the distribution parameter. Then, the residual bitstream is formed through entropy encoding.
[0035] like Figure 4 As shown, the secondary compressed file sequentially includes a file header (FileHeader 401), a shared header template dictionary (402), an organization prototype table (403), a model file number (ProfileID 404), a pyramid index (PyramidIndex 405), a tile index table (TileIndexTable 406), a tile data region (TileDataRegion), and an optional metadata region (408). Figure 6 As shown, this invention adopts an asymmetric system deployment model with intelligent decision-making at the encoding end and lightweight operation at the decoding end; as Figure 7 As shown, the decoding end uses a tile index table and a bounded depth cache to achieve millisecond-level timing response for local regions of interest.
[0036] The specific steps of the implementation of the encoding process of this invention are as follows: Step S1: Parse the encoded WSI container and form a uniform tile record. Parse SVS, OME-TIFF, or DICOM WSI containers to read the pyramid level number, level size, tile size, pixel pitch, tile row and column numbers, first-level bitstream offset, and length. For the... The first-level bitstream of each tile Perform reversible parsing: For JPEG bitstreams, parse SOI, APPn, DQT, DHT, SOF, DRI, SOS, EOI marker segments and entropy-coded events, and restore DC differential to absolute quantized DC; for JPEG2000 bitstreams, parse quantized wavelet subbands. The entire parsing process does not perform inverse quantization, IDCT, or RGB reconstruction.
[0037] This step enforces non-generative constraints on the program interface: the coefficient parsing module only outputs integer arrays, encoding parameters, and container metadata, and does not provide any interface for the model to output RGB or YCbCr pixels. When archive-level byte equality is required, bypass bytes are also extracted. .
[0038] This step outputs a uniform tile record:
[0039] in For the first A unified tile record for each tile. Subsequent step S2 uses this record. Determine the processing order, S3 uses Feature extraction, S10 uses , and Generate a reversible container.
[0040] Step S2: Establish causal coding order, anchor points, and reference depth Tiles are sorted in order of coarse resolution before fine resolution, and within the same layer, they are sorted by raster order or a predetermined space-fill curve (e.g., Hilbert curve or Z-order curve). A tile is added to the referenceable set only after step S10 has been completed. Therefore, the current tile cannot reference future tiles, ensuring that the encoding and decoding ends can independently reconstruct the reference relationship in the same order.
[0041] Every predetermined number of times in each layer Each tile is set with an anchor point tile. (The value is a preset positive integer, which can be configured by layer); anchor points are... The pattern, or simply a reference to the organization prototype in the coarse-resolution layer tiles or file header. Record the reference depth for each written tile. The current tile uses a reference tile. The resulting reference depth satisfies:
[0042] in For reference tiles Its own reference depth To determine the maximum allowable reference depth, the preferred method is... Choose 1 or 2. Encoded similar candidate references are only allowed to point to anchor tiles or coarse-resolution layer tiles, thus avoiding reference loops and long dependency chains from a topological perspective.
[0043] This step outputs the processing sequence number and the referenceable set. Anchor point markers and maximum depth The subsequent step S4 can only be performed from... Candidates are generated in S10, and the above information is written into the index in S11. Bounded decoding is then performed based on this information.
[0044] Step S3: Deduplication of shared header dictionary and feature extraction at the encoding end First, let's discuss the header parameters. Normalization and hash calculation are performed. The same DQT, DHT, SOF, sampling factor, and restart interval are only saved once in the header template dictionary. The current tile only saves the header template identifier. This eliminates a large amount of duplicate header data across the entire slice.
[0045] Then from Extracting encoding features This includes: a DC summary obtained by arranging the DC coefficients of each channel by block position and downsampling to integers. Statistical analysis of AC band energy accumulated according to preset zigzag frequency groups (To avoid conflict with referenceable collections) Confusion, here (Note the frequency band energy); calculate the chromaticity statistics by calculating the DC mean and variance of the Cb and Cr chromaticity components. Background markers determined based on brightness DC and high-frequency energy. (Used to indicate blank background areas); and to record layer number, tile type, and sampling format information. All the above quantities are calculated using integer addition, subtraction, absolute value, and shift operations, without involving floating-point operations, ensuring deterministic reproduction at both ends of the encoding and decoding process.
[0046] in This indicates that the fields are concatenated according to a preset field order. Because... Contains current tiles Information, by default not to include The residual probability model is directly input to the decoding end; if a certain implementation requires the use of some of these quantities, they must be quantized first and written as side information into the tile header before the residual bitstream.
[0047] This step outputs and .
[0048] Step S4: Generate a finite set of candidate references and construct a dual context. Based on pyramid geometry Encoding end features and referenceable collections Generate a finite set of candidate references for the current tile. ,include: 1. Space candidate: Referenceable set The coded tiles that are adjacent to the current tile in the same spatial layer typically include coded tiles located to the left, above, and to the upper left of the current tile (corresponding to...). Figure 2 Spatial reference 201, utilizing the glandular continuity and staining gradation characteristics of the neighborhood DC grid); 2. Scale Candidate: The coarsest parent tile that overlaps the physical coverage area of the current tile (corresponding scale reference 202, the parent tile is a low-pass version of the same physical region, and its DC grid can be aligned to the current layer after integer upsampling). 3. Semantic candidates: through Locality-Sensitive Hashing (LSH) key or quantized distance from a referenceable set Top- retrieved from anchor tile in the middle Similar tiles (corresponding to semantic reference 203, typically such as distant fat, smooth muscle, or blank areas) (The value is a preset positive integer). 4. Global Candidates: These are candidates whose organization prototype table 403 is created from coarse-resolution layer anchor tiles in the file header. Each tissue prototype (corresponding to global reference 204, representing the overall staining tone and scanner color cast) (The value is a preset positive integer). 5. Add an empty reference. , indicating independent encoding.
[0049] Generate a fixed-size candidate summary for each candidate. Spatial candidates are extracted by truncating the DC grid and low-frequency AC based on block coordinates; parent candidates are upsampled to integers based on physical overlap; semantic candidates are aligned to the same-layer block grid; prototype candidates are read from the DC prototype and frequency band statistics in the file header. Missing candidates are filled with preset values (such as all-zero tensors) and a candidate validity mask is set. Invalid selections are prohibited online.
[0050] This step constructs two different types of contexts:
[0051]
[0052] in This serves as the encoding decision context, used for gating and reference selection, and includes the current tile encoding end features. ; For a decodeable context, it consists of the candidate reference's own decoded coefficient summary and geometric information. , and candidate validity mask Composition, excluding the quantization transformation coefficients of the current tile. and its directly derived features (including) Therefore, the decoding end can synchronously reproduce the content based on the index and the already decoded reference. When enabled... In the implementation of the binding relationship, It may also include .
[0053] The semantic retrieval key is only responsible for recalling candidates from the encoded anchors and is not directly used as the information required for decoding; the final reference category and reference identifier will be written into the tile index, so the decoding end does not need to perform the retrieval again.
[0054] Step S5: Revenue Forecasting Gating (i.e. Figure 1 (The predicted net data saving amount meets the first condition) First, use a fixed parent reference rule Generate baseline predictions and calculate the unit coefficient mean absolute residuals of the parent reference rule predictions at the encoding end. If the current tile does not have a parent reference, then use an all-zero digest and set the missing parent reference position to 1. , Floor number and tile type Concatenate fields in a fixed order to form gated input:
[0055] in Since this step involves sequentially concatenating fields related to revenue prediction within the encoded decision context, the revenue prediction is a specific implementation of compressed revenue prediction based on the encoded decision context.
[0056] in The predicted net data savings (in bytes). This is a revenue-gated model, which can be implemented using a lightweight neural network or replaced with a preset rule threshold. It predicts the net data savings. Less than the first threshold (That is, the first condition is not met) When the preset threshold is used, the pre-mode Pick And skip the subsequent reference selection, directly proceed to step S10 to write the original first-level load or head de-weighting load; when When the first condition is met, the pre-mode is taken. Proceed to step S6.
[0057] It should be noted that the profit prediction in this step is only used to reduce subsequent computation and save inference costs, and is not the final basis for ensuring that the file does not bloat; the file does not bloat is guaranteed by the actual bit gating in step S9. The gating result does not need to be recalculated at the decoding end.
[0058] Step S6: Refer to the model selection sorting and actual code length parameter setting Reference Selection Model Output a score for each candidate; invalid candidates are masked by a candidate validity mask. Set to negative infinity, and then normalize using a mask to obtain the candidate ranking probability vector:
[0059] in This indicates that normalization is applied only to valid candidates. For example... Figure 3 As shown, Local branch 302 can be used ( The convolutional processing space (parent layer DC grid) and the global branch 303 (prototype distance or candidate attention) are a two-branch structure. The outputs of the two branches are concatenated in the candidate dimension after feature fusion 304. Finally, only the candidate ranking is output, and no pixels or coefficients are output.
[0060] from The highest scorer among them A short list of candidate components for trial coding. , Preferably, integers from 1 to 3. For each candidate in the short list The prediction in step S7 and the residual trial coding in step S8 are performed respectively. The actual total number of bits encoded, including reference identifier and category overhead, residual bitstream overhead, model side information overhead, and index table incremental overhead, are calculated. The smallest actual total number of bits in the encoding is selected as the final reference:
[0061] Therefore, the reference selection model only undertakes the task of "reducing all candidates to a few candidates," and the final selection still aligns with the compression objective (minimizing code length). The final reference category... Reference Mark Write the tile index, the decoder does not run. This will tell you which reference to use.
[0062] Step S7: Generate prediction coefficients using deterministic integer rules According to the reference category output by S6 Reference Marks and decodeable context Generate prediction coefficients. When When there is no reference, the prediction coefficients are set to zero or converted to independent encoding; when When using spatial reference, the quantization coefficients of the decoded reference tile are copied to the current grid by block coordinates; when When using the parent reference, the DC coefficient mesh of the parent tile is copied integers or upsampled integers bilinearly according to the physical overlap relationship. Low-frequency AC coefficients can be copied, while high-frequency AC coefficients are set to zero. When used as a semantic reference, copy according to the coordinates of blocks at the same level; when When used as a prototype reference, only the DC coefficient and the preset low-frequency coefficient group are predicted.
[0063] The default implementation uses only deterministic prediction rules. Optional implementation: Enable bias model When the bias enable flag is recorded in the tile index When the prediction bias is enabled, the bias model Based only on the decodable context and reference categories Generate a bounded small integer bias, which is then rounded and truncated to a value within a certain range. Within the interval ( The value is a preset small positive integer, which is preferred in specific implementations. ), and expand ( After being placed at the preset coefficient position, it is superimposed onto the baseline prediction:
[0064] in The current tile prediction coefficient, For reference tile quantization coefficient, for Flag (0 or 1). Bias model The quantization transform coefficients of the current tile must not be read. The decoding end uses the same The bias can then be reproduced. The source of the bias is only the parent layer / neighborhood reference context, used to absorb long-range gradual changes such as the brightness difference of the scan strips, rather than an inference of the current tissue morphology.
[0065] The output of this step It is not used as a pathological image, but only for calculating the residual in S8 and adding the residual to S11.
[0066] Step S8: Integer residual calculation and conditional probability entropy encoding The residual is obtained by subtracting integers from each coefficient at the encoding end.
[0067] This equation guarantees that any prediction error is fully incorporated into the residual. Streaming by Y, Cb, Cr channels and DC / AC frequency components: DC stream uses signed interleaving mapping (e.g., The bijective mapping is converted to a non-negative integer; the AC stream is split into three parts: zero / non-zero flag, position or zero run, and non-zero magnitude.
[0068] Residual probability model Only in a decodable context Reference Category Frequency group number And the causal history that has been encoded / decoded within the current frequency group. For input, output probability parameters:
[0069] Do not use or Unless the corresponding quantity has been written into the bitstream as side information before the residual bitstream. The encoder and decoder obtain the same integer frequency table based on the same input. It can be a discrete Laplace scaling parameter, or a mixed parameter of a Bernoulli distribution with zero / non-zero signature and a geometric distribution with non-zero amplitude; all floating-point results are... After processing according to the quantization and normalization rules specified in the standard, and constructing normalized integer frequencies, an rANS (Asymmetric Number System Entropy Code) encoder or an arithmetic encoder is used to process the frequencies. Encode and output residual bitstream and the actual number of residuals .
[0070] S6 compares the shortest list of candidates with the actual number of bits, and S9 uses this comparison to make the final anti-expansion judgment.
[0071] Step S9: Actual bit gating (i.e. Figure 1 (The actual net savings figure meets the second condition) Calculate the actual number of bits in bypass mode separately. (That is, the number of bits directly written to the original first-level load or head de-weight load) and the actual total number of bits in the reference mode. The total number of bits in the reference mode must include the reference category and reference identifier bits. residual bit depth The number of bits for probability or bias edge information Adding new indexes and checksum bits We cannot simply compare the residuals themselves:
[0072] in This represents the actual net benefit (net savings) of the tile. The final compression mode is determined as follows:
[0073] in To achieve the minimum actual savings in digits (the second condition), it can be calculated as follows: Alternatively, configure the deployment. The reference mode is used only if the actual net income meets the second condition; otherwise, a forced fallback to bypass mode is implemented. This step, rather than S5's predictive gating, provides the ultimate guarantee against file bloat.
[0074] Step S10: Write to a randomly accessible secondary compression container like Figure 4 As shown, the container structure includes: a FileHeader 401, which stores the identifier, format version, source file hash, pyramid description, and rule version; and a shared header template dictionary 402, which stores the deduplicated DQT / DHT / SOF / sampling parameters. Tiles only reference these parameters. ;Organize prototype table 403, which stores the data established from coarse-layer anchor points. Each compressed domain prototype and stripe statistics; Model file number ProfileID 404, only the archive number, not the network weights; PyramidIndex 405, storing the layer size, tile grid, pixel pitch, and physical coordinates; TileIndexTable 406, storing the data for each tile. , , , , , , , , and Fields, using a fixed-length or hierarchical table structure, are located by (level, row, column), and the reference chain depth does not exceed [a certain value]. TileDataRegion407 stores load data independently for each tile. ,include Level 1 bitstream Residual bitstream, optional edge information and CRC check, do not string the entire residual into a single sequential bitstream; optional metadata area 408, saves tag map, macro map, color management ICC, scan XML, DICOM mapping, etc.
[0075] When byte-level lossless archiving is enabled, the encoder performs a reversible closed-loop check before submitting tile records: it calls the prediction coefficient generation rules and integer residual summation logic that are completely identical to those of the decoder to reconstruct and restore the quantization transformation coefficients. and combined and Reverse assembly to produce a level 1 bitstream Byte-by-byte comparison and If any byte of the two is inconsistent, the compression mode of the current tile will be forcibly changed from the reference mode to the current mode. Directly write to the uncompressed first-level tile bitstream to ensure:
[0076] That is, the recovered bitstream has the same length and each byte as the original level 1 bitstream.
[0077] This step outputs a double-compressed WSI file with tile-level indexing and a bounded reference graph.
[0078] Step S11: Implementation of Bounded Decoding Process Combination Figure 7 As shown, the inputs to step S11 are the secondary compression file, the target compression ratio, and the ROI coordinates. Through the coordinated operation of the viewing interface (UI), the tile scheduler, the tile index table 406, the local cache, and the fixed-point decompression engine, the following time-series interactive sub-steps are executed: S11-1: The physician initiates a local ROI field of view request through the image reading interface. The tile scheduler maps the ROI to a set of target tiles based on the geometric information in the pyramid index 405, and reads the index record of each target tile from the tile index table 406. S11-2: Compression mode for The tiles, read the bypass load and combine Restore the first-level bitstream from the shared header template dictionary (402) and directly present it to the interface; S11-3: To for The tiles, along the index Read the dependency closure; since step S2 has limited the reference depth to no more than ( The required number of fine-layer reference tiles does not exceed ; By “coarse layer / anchor point” refer to The topological order of the "target tile" is used to recover the reference coefficients step by step. It also caches and reuses the decoded parent tiles and reference tiles to avoid the same reference being decoded repeatedly. S11-4: According to the index , and The prediction coefficients are reconstructed using the same deterministic integer rule as in step S7. Then, using a decodeable context , The causal history of the decoded residuals is invoked using the same residual probability model as in step S8. Reconstruct the integer frequency table and perform entropy decoding to obtain the complete residual. ; S11-5: Perform integer addition to recover the quantization transform coefficients:
[0079] and combined and Reverse assemble the first-level bitstream (byte-level archiving mode), or dequantize according to the original quantization table and perform IDCT to obtain diagnostic pixels consistent with the original first-level tiles (diagnostic pixel consistency mode).
[0080] If the tile index is If the rule version or CRC checksum does not match, the decoder will refuse to output the target tile and report an error, will not use other models as substitutes, and will not generate approximate pathological images. Therefore, the decoder output is not the pathological pixels generated by the model, but rather the raw data from point-to-point reconstruction; the decoder does not run the revenue-gated model or the reference selection model.
[0081] Step S12: Implementation of Offline Model Training and Consolidation Step S12 does not participate in the online reversible recovery of a single file, but instead generates the fixed model used in steps S5, S6, and S8 before deployment.
[0082] The training samples were obtained by multi-organ H&E staining WSI according to steps S1 to S4, without requiring pixel-level pathological annotation. An offline exhaustive teacher search method was used: a candidate reference set for the training samples was established. Each candidate in the algorithm undergoes complete steps S7 to S9 for trial coding to obtain the true net profit. Actual optimal reference and residual , used as supervisory labels. The total training loss is:
[0083] in For the profit-gated model, the profit regression or classification loss (in terms of...) Or whether it has been achieved (for supervision) Cross-entropy loss for the reference class (with) (for supervision) The negative log-likelihood loss of the residuals (in terms of...) (for the goal) For the optional bias model, the regularization term aims only to minimize the coefficient residual code length and does not use perceptual loss, adversarial loss or structural similarity SSIM and other perceptual loss types. , , The default loss weights are used. Furthermore, explicit code length estimation or exhaustive coding of candidate references is only used by offline teachers to generate supervisory labels, and is not a core method in the online path. The online path uses a trained gating, selection, and residual probability model to provide reference decisions and fit the residual distribution in a single forward pass, thereby reducing trial calculations at the encoding end.
[0084] After training, fixed-point quantization is performed on the model weights, activations, normalization parameters, etc., to form a read-only array. ; It also binds the model hash, input field order, quantization scale, and arithmetic rules. Trainable weights are not saved in the secondary compressed file.
[0085] After deployment, the coding end should at least use a revenue gating model. and reference selection model The decoding end does not need to be... and Because the compression mode and reference identifier have been written to the tile index; but when the residual probability model Or bias model When participating in decoding, the decoding end must load the same code as the encoding end. The model file management module verifies the data at runtime. .
[0086] The compression effect and deployment performance of the embodiments of the present invention can be verified by the following indicators: the consistency rate between the restored quantization transform coefficients and the original analytical quantization transform coefficients (simultaneously verifying the byte-by-byte consistency rate of the first-level bitstream under byte-level archiving); the P99 latency of ROI decoding; the single-tile encoding / decoding latency of the fixed-point model; and the volume comparison relative to the original file, general byte compression, single-tile recompression, and pure rule-based secondary compression. The above verifications can be directly executed in the processing pipeline constituted by steps S1 to S12.
[0087] Example 2 like Figure 5 As shown, this embodiment provides a non-destructive secondary compression device for pathological whole slide images, which includes the following modules. Figure 5 The modules shown are divided according to logical functions. In actual implementation, each module can be integrated into a single processor or distributed across multiple processors or physical devices. Syntax parsing module (corresponding) Figure 5 The WSI and coefficient adaptation module 501 is used to execute step S1, which parses the pathological whole-slice image that has completed first-level tile encoding, extracts the integer quantization transformation coefficients, encoding head parameters and pyramid geometry of each tile in the transformation coefficient domain, and does not perform inverse quantization, inverse transformation or pixel reconstruction during the parsing process, and outputs a unified tile record. ; Causal scheduling module (corresponding) Figure 5 The scheduling logic integrated within the context construction module 502 is used to execute step S2, which organizes the tiles according to the causal processing order of coarse resolution layer before fine resolution layer and the same layer according to the preset spatial order, includes the tiles that have completed secondary encoding into the referenceable set, and limits the maximum reference depth to no more than the preset upper limit. Context constructor module (corresponding) Figure 5 The context construction module 502 is used to perform steps S3 and S4, extracting encoding end features from the quantization transformation coefficients of the current tile, generating a finite set of candidate references based on the pyramid geometry, encoding end features and referenceable set, including at least two of the following: spatial neighborhood candidate references, pyramid parent layer candidate references, encoded similar candidate references and organizational prototype candidate references, generating candidate summaries for each candidate reference and setting a candidate validity mask, and constructing an encoding decision context and a decodeable context. Predictive gating module (corresponding) Figure 5 The revenue gating module AI-1 (503) is used to perform step S5, which performs compression revenue prediction based on the coding decision context. When the predicted net data saving amount does not meet the first condition, the current tile is pre-marked as bypass mode and subsequent reference selection is skipped. Reference selection module (corresponding) Figure 5 The reference selection module AI-2a (504) is used to perform step S6. When the predicted net data saving amount meets the first condition, the reference selection model is used to rank each candidate reference by probability. Based on the predetermined number of candidate references ranked first, the target reference and reference category are determined according to the criterion of minimizing the actual total number of coding bits. The reference category and reference identifier are written into the tile index. Deterministic prediction module (corresponding) Figure 5 The reversible prediction module 505 is used to execute step S7, which generates prediction coefficients from the quantization transformation coefficients of the target reference based on the determined reference category and through the deterministic integer prediction rules preset at both ends of the encoding and decoding. Residual entropy coding module (corresponding) Figure 5 The residual probability and entropy coding module 506 is used to execute step S8, calculate integer residuals, generate an integer frequency table using the residual probability model, and perform reversible entropy coding. Actual gate control module (corresponding) Figure 5 The actual bit verification unit in the index and random access module 508 is used to perform step S9, comparing the actual total bit length of the reference mode with the actual bit length of the bypass mode, and retaining the secondary compression load only when the actual net bit length saved meets the second condition; otherwise, it is forced to fall back to the bypass mode. File container encapsulation module (corresponding) Figure 5The container encapsulation unit in the index and random access module 508 is used to perform step S10, which writes the compression mode, reference category, reference identifier, reference depth, load storage offset and model file identifier into the tile-level index, and encapsulates and generates a secondary compressed pathological slide file that supports local random access to the region of interest.
[0088] Furthermore, the device may also include collaborative support components: an online adaptive module 507, used to refresh the symbol frequency table and prototype statistics with the same update rules as the decoder after each tile is encoded, without transmitting new training weights; and a model file management module 509, used to load fixed-point model files. And verify at runtime. The following steps are prohibited: enabling model-related functions without a file is required; the random access decoding module 510, used to execute step S11, is deployed on the client to complete ROI location, bounded reference closure reading, rule prediction reconstruction, residual entropy decoding, and accurate coefficient recovery. These modules can be deployed on the same physical device or separately according to the configuration of the deployment carrier architecture 511: the encoding side is deployed on the archiving GPU / NPU server, running gating and selection networks; the decoding side is deployed on a regular image reading workstation, using an asymmetric configuration of intelligent decision-making at the encoding end and light-load operation at the decoding end; the model uses... It is distributed with the software and is not written to every WSI file.
[0089] Combination Figure 6 As shown, this invention provides an asymmetric system deployment structure with intelligent decision-making at the encoding end and lightweight operation at the decoding end. The entire system includes an encoding end 601, a storage and distribution medium 602, and a decoding end 603. Encoding end 601 (deployed on archiving GPU / NPU server or scanner industrial control end): runs syntax parsing module 501, context construction module 502, revenue gating module 503, reference selection module 504, reversible prediction module 505 and residual probability and entropy encoding module 506. During the batch compression process, the AI model completes the optimal reference decision and parameter inference, and after comparison with actual bit gating, the decision results (compression mode, reference category, reference identifier and offset, etc.) are directly solidified and written into the tile index table. Storage and distribution medium 602: The slice file is encapsulated and output by the encoder and stored in the medium. The file only contains the tile index and residual load, and does not embed any large weight parameters of the neural network; it is a read-only model file. Distributed independently with the software from within the hospital system, and through Perform verification binding; Decoding terminal 603 (deployed on a general pathologist's PC workstation for reading slides): integrates only a lightweight random access decoding module 510.
[0090] When the physician accesses the local ROI field of view, the decoding end reads the tile index through a single I / O jump, directly bypassing the gating model and the reference selection model (without running the forward inference of either), and directly calling the CPU fixed-point integer prediction kernel recovery based on the reference category recorded in the index. The residuals are recovered using a preset frequency table or a lightweight probabilistic model. Adding fixed-point integers Restored the original coefficients. This configuration completely eliminates the hardware dependence of the video reader on high-end AI graphics cards.
[0091] Example 3 This embodiment also provides an electronic device, including a memory and a processor. The memory stores a computer program, and the processor is configured to call and execute the computer program to implement the encoding method constituted by steps S1 to S10 above, or to implement the decoding method constituted by step S11. The physical form of the electronic device may be an archiving server, a scanner integrated workstation, a film reading workstation, or a portable film reading terminal, and the processor may include one or more of a central processing unit (CPU), a graphics processing unit (GPU), a neural processing unit (NPU), and a field-programmable gate array (FPGA).
[0092] This embodiment also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the above-described encoding method or the steps of the above-described decoding method. The storage medium includes, but is not limited to, read-only memory (ROM), random access memory (RAM), solid-state drive (SSD), optical disk, magnetic disk, and network storage devices.
[0093] Typical deployment examples are as follows: Example 1 (Default product profile: Intelligent encoding, lightweight decoding): Combining Figure 6 As shown, the reference selection model only runs on the archive server (i.e., encoding end 601), and will and Write the tile index; the reading end (i.e., the decoding end 603) only performs deterministic rule prediction and residual rANS decoding; residual probability model. Use a fixed frequency table in the file header and disable the bias header. The decoding end does not run the neural network at all; the file is still reversible, and the model does not enter the diagnostic network. This configuration is suitable for integration with existing hospital image reading software.
[0094] Example 2 (encoding and decoding both run probabilistic networks, no bias head): The viewing terminal loads the same fixed point. The residual distribution parameters are recalculated from the decodeable context. This configuration avoids writing probabilistic side information into the bitstream, achieving a compression ratio superior to Example 1, and adds a small forward inference step at the decoding end. This configuration is suitable for central-end image archiving and preview services.
[0095] Example 3 (Enable Integer Bias): The bias enable flag is set to 1, and the bias model output is enabled. Bounded small integer bias within (preferred in specific implementations) It extends to a preset frequency band location to absorb the brightness difference of the scanned strips. The bias is derived from the parent / neighborhood reference context, rather than an inference of the current tissue morphology; the coefficients are still accurately recovered.
[0096] Example 4 (Gated Bypass Protection): For high-nuclear-density regions such as poorly differentiated adenocarcinoma, the disordered tissue structure leads to a unit coefficient mean absolute residual in the parent reference rule prediction. The data volume is relatively large, and the net data savings predicted by the revenue gating model do not meet the first condition. Therefore, this tile is pre-marked as a bypass, and the pattern in the index is marked as... Compared to the controllable configuration, this type of area avoids the volume increase caused by secondary compression.
[0097] Example 5 (Long-distance semantic reference): The reference selection model outputs a high-confidence probability for a certain encoded fat anchor semantic candidate. The encoder uses this anchor as a reference and the residual entropy encoding bit is the smallest. Finally, this semantic reference is selected. Compared with the control configuration that only allows left neighbor / parent layer reference, the overall compression ratio is further improved, and the reference depth of this tile is still 1.
[0098] Example 6 (Cross-Layer Scale Dominance): In homogeneous stroma regions, the reference selection model shows a significant advantage in selecting the parent layer reference output (e.g., a probability greater than 0.5), consistent with the statistical regularity of the explained staining tone in low-magnification layers. In regions of structural abrupt change, such as tumor margins, the model shifts to an empty reference or a spatial left-neighbor reference. This interpretable selection behavior indicates that the model output is a reference class decision rather than a black-box generation.
[0099] Example 7 (Profile mismatch, plot rejected): Human error Decoding of secondary compressed files, decoder verification The system refuses to output the target tile and reports an error after rule version and CRC failures, instead of outputting an incorrect cell image, reflecting medical data security constraints.
[0100] Example 8 (JPEG2000 tile): When the primary encoding is JPEG2000, the DC coefficient is compared with the LL subband and the AC frequency group is compared with the high-frequency subband. The feature extraction at the encoding end is changed to LL subband thumbnail statistics. The parent reference upsampling in step S7 is changed to LL subband integer upsampling. The rest of the process is the same as the JPEG implementation.
[0101] Example 9 (Offline exhaustive search for teachers and online network students): First, exhaustive coding or explicit residual code length estimation is performed on candidate references to obtain the optimal reference label. Then, the reference selection network 305 is trained by distillation. After going online, the network replaces repeated residual scans of multiple candidates with a single forward pass, reducing coding latency and finally the code length is close to the teacher's exhaustive search result.
[0102] Example 10 (Scanner Simultaneous Imaging and Compressing): For coarse-resolution layers, the tissue prototype table 403 is updated as soon as the data is written; for fine-resolution layers, each row is encoded as soon as it is scanned. Revenue Gating Threshold The performance is appropriately enhanced, prioritizing real-time data acquisition, with automatic bypassing in complex areas. This implementation demonstrates that the method can be embedded in a data acquisition pipeline for online execution.
[0103] Alternative implementation methods are as follows: 1. The reference selection model can be replaced with Gradient Boosting Tree (GBDT), Logistic Regression, or a shallow multilayer perceptron; the two-branch structure of local and global branches can be replaced with a small Transformer that scans the DC grid in one dimension, but its input tokens must be block-level frequency domain features rather than pixel-level ones. The core lies in the mapping from the compressed domain context to a limited number of reference classes, rather than a specific network backbone.
[0104] 2. The residual probability model can be replaced by histogram lookup table, mixed geometric distribution, or autoregressive frequency band model; the core is to establish conditional probabilities for integer residuals after deterministic rule prediction.
[0105] 3. The revenue gating can be replaced by a pure rule-based threshold judgment. For example, when the mean absolute residual of the unit coefficient predicted by the parent reference rule is greater than a preset threshold, it can be directly pre-marked as a bypass and the reference selection can be skipped. At this time, the actual bit gating in step S9 is still retained to ensure that the file does not expand. The core is to estimate the net revenue before the secondary compression depth calculation and allow bypassing; the gating is implemented by rule thresholds as a subordinate implementation method.
[0106] 4. The primary encoding format can be JPEG, JPEG2000, or other quantization transform-based tile encoding based on block transform, with the corresponding working domain being quantized DCT coefficients or quantized wavelet coefficients.
[0107] 5. If the bias model deepens the network structure but still only outputs bounded integer biases and does not read the current quantization transformation coefficients, it still belongs to the implementation method of this invention; once it is changed to output color gamut pixels, it does not belong to this solution.
[0108] 6. The training method can be supervised distillation or reinforcement learning with the direct goal of minimizing the code length, as long as the action space is the reference class and probability distribution parameters. Instead of generating pixels.
[0109] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated here.
[0110] Generally, various embodiments can be implemented in hardware or dedicated circuitry, software, logic, or any combination thereof. Some aspects of the invention can be implemented in hardware, while others can be implemented by firmware or software executed by a controller, microprocessor, or other computing device, but the invention is not limited thereto. Although various aspects of the invention may be shown and described as block diagrams, flowcharts, or using some other graphical representation, it should be understood that, by way of non-limiting example, these blocks, apparatuses, systems, techniques, or methods described herein can be implemented in hardware, software, firmware, dedicated circuitry or logic, general-purpose hardware or controllers or other computing devices, or some combination thereof.
[0111] Embodiments of the present invention can be implemented by computer software, which may be executable by a data processor of a mobile device, such as a processor entity, or by hardware, or by a combination of software and hardware. Computer software or programs (also referred to as program products) including software routines, applets, and / or macros can be stored in any device-readable data storage medium, and they include program instructions for performing specific tasks. The computer program product may include one or more computer-executable components configured to perform the embodiments when the program is run. The one or more computer-executable components may be at least one piece of software code or a portion thereof. Additionally, it should be noted in this respect that, as Figure 1 Any box in the logical flow can represent a program step, or interconnected logic circuits, boxes and functions, or a combination of program steps and logic circuits, boxes and functions. Software can be stored on physical media such as memory chips or blocks of storage implemented within a processor, magnetic media such as hard disks or floppy disks, and optical media such as DVDs and their data variants, CDs, etc. The physical medium is a non-transient medium.
[0112] Those skilled in the art should understand that the technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments have been described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0113] The above embodiments are merely illustrative of several implementations of the present invention, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these all fall within the protection scope of the present invention. Therefore, the protection scope of the present invention should be determined by the appended claims.
Claims
1. A lossless secondary compression method for whole-section pathological images based on hierarchical prediction and reference selection networks, characterized in that, Includes the following steps: The system analyzes pathological whole-slice images that have completed first-level tile encoding, and extracts the integer quantization transformation coefficients, encoding head parameters, and pyramid geometry of each tile in the transformation coefficient domain; the analysis process does not perform inverse quantization, inverse transformation, or pixel reconstruction. The tiles are organized according to a causal processing order where the coarse resolution layer precedes the fine resolution layer, and tiles within the same layer are processed in a preset spatial order. Tiles that have completed secondary encoding are included in the referenceable set, and the maximum reference depth of the current tile relative to the referenced tile is limited to a preset upper limit. Extract the encoding end features from the quantization transform coefficients of the current tile, and based on the pyramid geometry, the encoding end features and the referenceable set, generate a finite set of candidate references for the current tile, including at least two of the following: spatial neighborhood candidate references, pyramid parent layer candidate references, encoded similar candidate references and organizational prototype candidate references. For each candidate reference, a candidate summary is generated and a candidate validity mask is set. An encoding decision context for reference decision and a decodeable context for synchronous reproduction at the decoding end are constructed respectively. The encoding decision context includes the encoding end features and the candidate summary of each candidate reference. The decodeable context includes the candidate summary and the candidate validity mask, but does not include the quantization transformation coefficients of the current tile and its directly derived features. Based on the encoding decision context, compression benefit prediction is performed. When the predicted net data saving amount does not meet the first condition, the current tile is pre-marked as bypass mode and subsequent reference selection is skipped. When the predicted net data saving amount meets the first condition, the reference selection model is used to rank each candidate reference probabilistically according to the coding decision context and the candidate validity mask. Based on the predetermined number of candidate references ranked first, the target reference and reference category are determined according to the criterion of minimizing the actual total number of coding bits, and the reference category and the corresponding reference identifier are written into the tile index. Based on the determined reference category, prediction coefficients are generated from the quantization transformation coefficients of the target reference using deterministic integer prediction rules preset at both ends of the encoding and decoding. Calculate the integer residual between the quantization transform coefficients of the current tile and the predicted coefficients. Use the residual probability model to generate an integer frequency table based on the decodeable context, the determined reference category, and the causal history of the encoded residuals in the current frequency band. Then, perform reversible entropy coding on the integer residuals accordingly. The actual total number of coding bits obtained by using the target reference coding is compared with the actual number of coding bits of the first-level tile directly using the bypass mode. The actual total number of coding bits includes the reference identifier and category overhead, residual bitstream overhead, model side information overhead, and index table incremental overhead. The secondary compression load is retained only when the actual net number of bits saved meets the second condition; otherwise, the compression mode is forcibly reverted to the bypass mode. The compression mode, reference category, reference identifier, reference depth, load storage offset, and model file identifier of each tile are written into the tile-level index and encapsulated to generate a secondary compressed pathological slide file that supports local random access to the region of interest. The input of the residual probability model does not include the current tile quantization transformation coefficients that have not yet been recovered; the outputs of both the reference selection model and the residual probability model are not used as pathological image pixels.
2. The lossless secondary compression method for whole-slice pathological images based on hierarchical prediction and reference selection networks as described in claim 1, characterized in that, Generate a finite set of candidate references for the current tile, including at least two of the following: spatial neighborhood candidate references, pyramid parent layer candidate references, encoded similarity candidate references, and organizational prototype candidate references. The coded tiles in the referenceable set that are spatially adjacent to the current tile in the same layer are used as spatial neighborhood candidate references; The coarse-resolution tile in the previous layer that overlaps with the physical coordinate coverage area of the current tile in the referenceable set is used as a candidate reference for the pyramid parent layer. Using the feature vector extracted from the quantization transformation coefficients of the current tile, similar tiles are retrieved from the anchor tiles in the referenceable set as encoded similar candidate references through local sensitive hashing; Extract the organizational prototypes built from anchor tiles and written into the file header during the coarse-resolution encoding stage as organizational prototype candidate references; Missing candidate references are filled with preset values and are indicated as invalid by the candidate validity mask.
3. The method for lossless secondary compression of whole-slice pathological images based on hierarchical prediction and reference selection networks as described in claim 1, characterized in that, Target references and reference categories are determined based on a predetermined number of candidate references ranked high, using a criterion of minimizing the actual total number of coding bits. These include: The classification probability of each candidate reference is output using the reference selection model, and the top one to three candidate references with the highest probabilities are selected to form a short list of trial codes. For each candidate reference in the short list of test codes, deterministic prediction and residual entropy coding are performed respectively, and the actual total number of coding bits, including reference identifier and category overhead, residual bitstream overhead, model side information overhead, and index table incremental overhead, are calculated. The candidate reference with the smallest actual total number of encoded bits is selected as the target reference.
4. The method for lossless secondary compression of whole-slice pathological images based on hierarchical prediction and reference selection networks as described in claim 1, characterized in that, By using deterministic integer prediction rules preset at both ends of the encoding and decoding, prediction coefficients are generated from the quantization transformation coefficients of the target reference, including: When the reference category is a spatial neighborhood reference or an encoded similar reference, the quantization transformation coefficients of the reference tile are aligned and copied to the current grid according to the block coordinates; When the reference category is the pyramid parent layer reference, the DC conversion coefficient grid of the parent tile is amplified by fixed-point integer interpolation according to the physical overlap relationship between the two layers of tiles, the low-frequency AC conversion coefficient is copied, and the high-frequency AC conversion coefficient is set to zero. When the reference category is an organizational prototype reference, only the DC conversion coefficient and the preset low-frequency coefficient group are predicted; When the bias enable flag indicates that prediction bias is enabled, the bias model generates a bounded small integer prediction bias based solely on the decodeable context and the reference category. The bounded small integer prediction bias is then extended to a preset frequency band position and superimposed on the baseline prediction coefficients output by the deterministic integer prediction rule. The bias model does not input the quantization transform coefficients of the current tile.
5. The method for lossless secondary compression of whole-slice pathological images based on hierarchical prediction and reference selection networks as described in claim 1, characterized in that, The reversible entropy encoding of the integer residual includes: The calculated integer residuals are split into luminance and chrominance channels, and DC and AC frequency band components. The residual probability model strictly isolates the true quantization transformation coefficients of the current tile and outputs discrete Laplace scale parameters or mixed probability distribution parameters of zero and non-zero amplitudes based on the decodeable context, the determined reference category, and the historical statistics of the solved frequency bands. A normalized integer frequency table is constructed based on the probability distribution parameters, and residual bit streams for each stream are generated by an rANS encoder or an arithmetic encoder. When the encoding end features of the current tile need to be input into the residual probability model, the corresponding features are written as side information before the residual bit stream.
6. The method for lossless secondary compression of whole-slice pathological images based on hierarchical prediction and reference selection networks as described in claim 1, characterized in that, An anchor tile is set every predetermined number of tiles in the same resolution layer. The anchor tile only uses bypass mode or only allows referencing the previous coarse resolution tile or file header organization prototype. Encoded similar candidate references are only allowed to point to encoded anchor tiles or coarse-resolution layer tiles; The maximum reference depth limit for dependency chains that can be established for any fine-resolution layer tile is set to 1 or 2 to limit the number of topology unroll dependencies during local parsing at the decoding end.
7. The method for lossless secondary compression of whole-section pathological images based on hierarchical prediction and reference selection networks as described in claim 1, characterized in that, Before writing the tile load into the secondary compressed pathological slide file, a reversible closed-loop verification step is performed: The same prediction coefficient generation rules and integer residual summation logic as the encoding end are called to reconstruct the restored quantization transform coefficients and then assemble the first-level bitstream in reverse. Compare each byte of the assembled Level 1 bitstream with the original input Level 1 bitstream; If any byte is inconsistent between the two, the compression mode of the current tile is forcibly changed from the reference mode to the bypass mode, and the uncompressed first-level tile bitstream is directly written.
8. A lossless secondary compression device for whole-slice pathological images based on hierarchical prediction and reference selection networks, characterized in that, include: The syntax parsing module is used to parse the pathological whole slice image that has completed the first-level tile encoding. It extracts the integer quantization transformation coefficients, encoding head parameters and pyramid geometry of each tile in the transformation coefficient domain. The parsing process does not perform inverse quantization, inverse transformation or pixel reconstruction. The causal scheduling module is used to organize the tiles according to the causal processing order of coarse resolution layer before fine resolution layer and within the same layer according to the preset spatial order. It includes the tiles that have completed secondary encoding into the referenceable set and limits the maximum reference depth of the current tile relative to the referenced reference tile to not exceed the preset upper limit. The context construction module is used to extract encoding end features from the quantization transform coefficients of the current tile, generate a finite set of candidate references based on the pyramid geometry, the encoding end features, and the referenceable set, including at least two of the following: spatial neighborhood candidate references, pyramid parent layer candidate references, encoded similar candidate references, and organizational prototype candidate references. It generates candidate summaries for each candidate reference and sets a candidate validity mask. It constructs an encoding decision context containing the encoding end features and candidate summaries, and a decodeable context containing candidate summaries and candidate validity masks but not containing the quantization transform coefficients of the current tile and their directly derived features. The prediction gating module is used to predict compression benefits based on the coding decision context. When the predicted net data saving does not meet the first condition, the current tile is pre-marked as bypass mode and subsequent reference selection is skipped. The reference selection module is used to, when the predicted net data saving amount meets the first condition, use the reference selection model to perform probability ranking of each candidate reference according to the coding decision context and the candidate validity mask, determine the target reference and reference category based on the predetermined number of candidate references with the highest ranking and the criterion of minimizing the actual total number of coding bits, and write the reference category and the corresponding reference identifier into the tile index. The deterministic prediction module is used to generate prediction coefficients from the quantization transformation coefficients of the target reference based on the determined reference category and through the deterministic integer prediction rules preset at both ends of the encoder and decoder. The residual entropy coding module is used to calculate the integer residual between the quantization transformation coefficients of the current tile and the prediction coefficients. It uses the residual probability model to generate an integer frequency table based on the decodeable context, the determined reference category, and the causal history of the encoded residuals in the current frequency band, and performs reversible entropy coding on the integer residuals accordingly. The actual gating module is used to compare the actual total number of bits of coding obtained by using the target reference coding with the actual number of bits of coding of the first-level tile directly using the bypass mode. The secondary compression load is retained only when the actual net number of bits saved meets the second condition; otherwise, the compression mode is forced to fall back to the bypass mode. The file container encapsulation module is used to write the compression mode, reference category, reference identifier, reference depth, load storage offset, and model file identifier of each tile into the tile-level index, and encapsulate and generate a secondary compressed pathological slide file that supports local random access to the region of interest. The input to the residual probability model does not include the current tile quantization transform coefficients that have not yet been recovered; The outputs of the reference selection model and the residual probability model are not used as pixels in the pathological image.
9. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the lossless secondary compression method for pathological whole-slice images based on hierarchical prediction and reference selection networks as described in any one of claims 1 to 7.
10. A readable storage medium, characterized in that, The readable storage medium stores a computer program that, when executed by a processor, implements the lossless secondary compression method for pathological whole-slice images based on a hierarchical prediction and reference selection network as described in any one of claims 1 to 7.