Multi-thread picture compression method and device and storage medium

By using the image semantic segmentation model to divide the tender document images into feature blocks and dynamically allocate threads, the problems of image compression distortion and inefficiency in the existing technology are solved, efficient and quality-optimized image compression is achieved, and the readability and transmission efficiency of the tender documents are improved.

CN120676162AInactive Publication Date: 2025-09-19HUBEI LINGCHUANG ENTERPRISE SERVICE CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202511024262.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-24
Publication Date
2025-09-19
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing image compression technology is unable to differentiate between different image contents in electronic bidding scenarios, resulting in blurred drawing details, broken table lines, jagged text edges, uncontrollable compression quality, and a lack of partitioned parallel compression mechanism, resulting in low processing efficiency, affecting the readability and transmission efficiency of bidding documents.

Method used

The image semantic segmentation model is used to divide large-size tender documents into feature blocks, generate metadata for the division of tables, images, and text blocks, dynamically allocate threads for compression, evaluate compression quality and adjust parameters in real time, repair seams and breaks, and generate a spliced ​​compressed image.

Benefits of technology

It achieves efficient and differentiated compression of large-size tender document images, improves image quality, optimizes file volume control, enhances the transmission and storage efficiency of graphic data, and avoids compression distortion and structural disorder.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120676162A_ABST
    Figure CN120676162A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of picture compression, and particularly discloses a multi-thread picture compression method and device and a storage medium, and the method comprises the steps: carrying out the feature block division of a to-be-compressed large-size bidding document picture through an image semantic segmentation model, generating division metadata, and executing a dynamic thread distribution strategy based on the division metadata, performing complexity evaluation calculation on each feature block to generate a block complexity score; establishing a thread distribution mapping table according to the complexity scores of the blocks, and starting a multi-stage compression thread group for the blocks with the complexity scores higher than a threshold value; starting a single-thread rapid compression channel for the block with the complexity score lower than a threshold value; performing space coordinate alignment splicing on the compressed blocks through the main thread to generate a spliced compressed image; and packaging and outputting the compressed image after the visual detection processing. The problems of serious compression distortion, low processing efficiency, disordered structure and the like when a traditional compression technology is used for processing a large-size bidding document image are effectively solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of image compression and relates to a multi-threaded image compression method, device and storage medium. Background Art

[0002] With the widespread adoption of electronic bidding, digital and online submission of bid documents has become the norm. However, with the increasing complexity of engineering projects, bid documents are also growing in size. This is especially true for PDF files containing large numbers of high-definition scanned drawings and mixed text and image pages, which often exceed 500MB in size. Since most electronic bidding platforms impose upload limits on individual file sizes, oversized bid documents are prone to upload failures, transmission interruptions, and network timeouts, severely impacting bid efficiency and even invalidating bids. Furthermore, since bidding platforms have specific requirements for the format, clarity, and content integrity of uploaded files, simple overall compression or image degradation often fails to strike a balance between file size and image quality. Therefore, efficient and intelligent compression of large images embedded in bid documents has become a key technical approach to improving the efficiency of electronic bid document transmission and ensuring bid success rates. Its importance and necessity cannot be underestimated.

[0003] However, current mainstream image compression technologies still suffer from numerous technical flaws and practical drawbacks when applied to e-bidding scenarios. First, traditional compression methods often employ a uniform compression rate or fixed-resolution scaling strategy, failing to differentiate between the different image contents within a bid document. This is particularly true when dealing with mixed images, such as drawings, tables, and text scans. These methods often result in blurred drawing details, broken table lines, and jagged text edges, severely impacting the bid's readability and professionalism. Second, existing compression tools generally lack the ability to intelligently identify image content complexity and dynamically adjust compression parameters based on information such as texture density, color variations, and structural features. This results in uncontrollable compression quality, potentially leading to noticeable visual distortion and even missing key content after compression. Furthermore, existing compression processes are mostly linear, lacking partitioned, parallel compression mechanisms for large images, resulting in low processing efficiency and insufficient capacity for rapidly processing large volumes of bid documents. Before uploading, users must manually use multiple tools to perform operations such as cropping, compression, and merging, which is cumbersome and error-prone. Furthermore, the lack of compression quality assessment and anomaly detection mechanisms often prevents timely detection of image corruption or missing content after compression. What is more serious is that some compression tools do not retain the spatial coordinate information of the original image during the compression process, resulting in disordered layout and uneven seams of the compressed image in the bid, affecting the overall layout appearance and even affecting the reading of information during the bid evaluation process. Summary of the Invention

[0004] In view of the above problems in the prior art, the present invention provides a multi-threaded image compression method, device and storage medium to solve the above technical problems.

[0005] In order to achieve the above-mentioned and other purposes, the technical solutions adopted by the present invention are as follows: A first aspect of the present invention provides a multi-threaded image compression method, the method comprising: Step S1: Using an image semantic segmentation model, the large-size tender document image to be compressed is divided into feature blocks, and segmentation metadata including table blocks, image blocks, and text blocks is generated. A spatial distribution heat map is created based on the pixel size of each block. Step S2: Execute a dynamic thread allocation strategy based on the partition metadata, perform a complexity evaluation calculation on each feature block, and generate a block complexity score; establish a processing priority queue based on the pixel ratio of each block in the spatial distribution heat map, and activate the priority processing flag for engineering drawing blocks that occupy a large space; Step S3: Establish a thread allocation mapping table based on the block complexity score, start a multi-stage compression thread group for blocks with a complexity score higher than a threshold; start a single-thread fast compression channel for blocks with a complexity score lower than the threshold; Step S4: progressively evaluate the quality of the compressed blocks output by each thread. When it is detected that the local compression distortion exceeds a preset threshold, the associated threads of the adjacent blocks are triggered to dynamically adjust the compression parameters. Step S5: The main thread performs spatial coordinate alignment and splicing on the compressed blocks to generate a spliced ​​compressed image; visual continuity detection is performed on the spliced ​​seam blocks; when seam anomalies are detected, the seam repair engine is activated to perform color transition filling on the color difference blocks and stroke connection reconstruction on the broken text; Step S6: Encapsulate and output the compressed image after visual inspection processing.

[0006] Exemplarily, step S1 includes the following sub-steps: Step S11: performing multi-channel decomposition processing on the compressed tender document image, extracting RGB three-channel data and brightness channel data, and performing Gaussian filtering on the image edge to reduce noise, thereby generating pre-processed four-channel image data; Step S12: Input the four-channel image data into the pre-trained semantic segmentation model, extract texture features through a multi-layer convolutional network, perform bounding box regression positioning on the table block, perform instance segmentation on the image block, perform connected domain analysis on the text block, and output segmentation metadata annotated with block type and coordinates, where block types are divided into table blocks, image blocks, and text blocks; Step S13: Based on the coordinate information recorded in the partition metadata, the pixel size of each block is counted and the relative proportion is calculated. The quantification formula is: block area proportion = number of pixels in the current block / total number of pixels in the entire image. The spatial coordinates of the center point of each block are also recorded. Step S14: Based on the block area ratio and center coordinate data, with the full map size as the reference coordinate system, Gaussian kernel density estimation is applied to the center point of each block. The kernel function radius is positively correlated with the block area ratio. A spatial distribution heat map is generated by superimposing the kernel density distribution of each block.

[0007] Exemplarily, step S12 includes: Step S121: normalize the input four-channel image data so that the values ​​of each channel are mapped to the range of 0-1 to generate standardized image data; input the standardized data into the first convolutional layer of the semantic segmentation model, extract primary texture features through a 3×3 convolution kernel, and output an initial feature map; Step S122: downsampling and upsampling operations are performed on the initial feature map in sequence: a low-resolution global feature map is generated by performing three maximum pooling operations with a step size of 2; the global feature map and the initial feature map are weighted fused channel by channel, with the weight distribution ratio of global features to local features to be 0.6 and 0.4, respectively; the fused feature map is transposed convolutionally restored to the original image resolution, and an enhanced feature map is output; Step S123: Extracting table candidate blocks from the enhanced feature map. The specific operations are as follows: scanning the feature map through a sliding window to detect blocks with horizontal / vertical line segment density greater than a threshold; performing bounding box regression on the candidate blocks to calculate the offset of the bounding box coordinates (x_min, y_min, x_max, y_max); using the non-maximum suppression algorithm to merge redundant boxes with an overlap rate greater than 0.7, and outputting a table block coordinate set; Step S124: Segment the image for non-table blocks. The specific operations are as follows: generate candidate masks on the enhanced feature map and select blocks with color variance higher than a threshold; perform dilation-erosion processing on the edges of the candidate blocks using the mask refinement module to eliminate jagged edges; and output the binary mask and the corresponding image block coordinates. Step S125: Perform text recognition on the remaining unmarked blocks. The specific operations are as follows: adaptively binarize the brightness channel of the enhanced feature map and calculate the local threshold T = block average brightness × 0.8; mark connected domains based on the 8-neighborhood connectivity rule and exclude noise blocks with less than 20 pixels; expand the minimum bounding rectangle of each connected domain by 10% of its original size and output the coordinates of the text block; Step S126: Generate JSON-formatted partition metadata based on the coordinates of the table, image, and text blocks, including the block type, coordinate range, and area ratio; if the overlapping area of ​​two blocks exceeds 15% of the area of ​​the smaller block, they are merged into the same block, and finally the partition metadata of the table block, image block, and text block are output.

[0008] Exemplarily, step S4 includes the following sub-steps: Step S41: performing a block-by-block quality check on the pixel matrix of each compressed block, and generating a quality score table by calculating a structural similarity index; wherein the structural similarity index is calculated by comparing differences in block brightness, contrast, and structural features; Step S42: Loading a preset quality threshold δ, screening blocks with a structural similarity index lower than δ in the quality score table, generating a list of abnormal blocks; and recording the spatial coordinates and corresponding thread IDs of the abnormal blocks; Step S43: Based on the block adjacency data of the spatial distribution heat map, find the associated blocks adjacent to the abnormal block in the four directions of east, south, west and north, and extract the thread ID and current compression parameter configuration of the associated blocks; Step S44: dynamically adjust the compression parameters of the associated threads; generate an adjusted parameter configuration file and push it to the corresponding threads.

[0009] Exemplarily, dynamically adjusting the compression parameters of the associated threads specifically includes the following sub-steps: Step S441: Calculate the JPEG quantization step adjustment coefficient K_quant based on the deviation ratio between the structural similarity index of the abnormal block and the quality threshold. The calculation formula is: K_quant = 1.2 × (δ - SSIM) / δ. When K_quant > 1, the quantization step is adjusted to K_quant times the original value. When K_quant ≤ 1, the original step remains unchanged. Where SSIM represents the structural similarity index of the abnormal block. Step S442: Based on the current WEBP compression ratio and structural similarity index of the associated block, the compression ratio target value C_new is recalculated according to the reverse compensation mechanism. The specific calculation logic is: C_new = C × (1 + (δ-SSIM) / 0.15). When C_new > 95%, the upper limit value is 95%; where C represents the current WEBP compression ratio of the associated block; Step S443: Extract the edge density value of the text block in the pre-processing stage, and adjust the binarization threshold T_bin = original threshold × (1-0.4 × E) according to the edge preservation requirement. If the adjusted threshold is lower than the minimum threshold T_min = 50, reset it to T_min; E is the edge density value in the pre-processing stage; Step S444: Integrate the above calculation results to generate an adjusted parameter configuration file, including the quantization step size multiple, WEBP compression ratio and binarization threshold parameters, and push it to the corresponding thread in real time to overwrite the original configuration.

[0010] Exemplarily, step S5 includes the following sub-steps: Step S51: Based on the original coordinate information of the blocks recorded in the partition metadata, a reference coordinate system is established with the upper left corner of the tender image as the origin, and the geometric position of the compressed blocks is calibrated; the blocks are spliced ​​row by row and column by column in the order of their center coordinates on the X / Y axis to generate a preliminary spliced ​​image and record the coordinates of the seam positions; Step S52: Extract RGB data of 3 pixels wide on both sides of the seam, calculate the color difference ΔE between adjacent pixels = √(ΔR² + ΔG² + ΔB²), and count the maximum and average ΔE values ​​in the seam area. When the maximum ΔE exceeds the threshold, mark it as an abnormal color difference area, and record the coordinate range and ΔE value of the abnormal seam. Step S53: Calling a pre-trained OCR model to recognize the text content after splicing, and comparing the recognition result with the OCR text of the original block character by character; locating the bounding box coordinates of the missing characters, extracting the binary image of the missing area and calculating the length of the broken gap of the strokes. If the gap length is ≥ 2 pixels, it is marked as a broken text area; Step S54: Merge the color difference abnormality and the text break abnormality coordinate data, and generate a repair priority according to the following rules: color difference abnormality priority = max (ΔE) × 20, text break priority = gap length × 50; generate a global repair task queue based on the priority values ​​from high to low; Step S55: Expand a 5-pixel buffer area to both sides of the seam line as the center, perform bilinear interpolation blending on the RGB channels of the pixels in the buffer area, and linearly attenuate the interpolation weight according to the distance from the seam; Step S56: extracting stroke endpoints based on the coordinates of the broken gaps in the text, generating a third-order Bezier curve connection path based on the endpoint coordinates, and keeping the path width consistent with the average width of the original strokes; performing anti-aliasing processing on the reconstructed path, and filling the path to generate continuous strokes; Step S57: re-perform color difference detection and OCR recognition on the repaired seam. If max (ΔE) ≤ 3 and the length of the text gap ≤ 1 pixel, the repair is marked as successful; if it fails to meet the requirements, the abnormal area is added back to the repair queue.

[0011] Exemplarily, step S56 includes the following sub-steps: Step S561: Based on the binary image generated in step S53, the precise pixel coordinates of the ends of the strokes on both sides of the gap are extracted and recorded as the first endpoint P1 (x1, y1) and the second endpoint P2 (x2, y2) respectively; Step S562: Calculate the direction angle θ=arctan[(y2-y1) / (x2-x1)] of the line connecting endpoints P1 and P2, and determine the basic width of the connection path based on the average unit pixel width W of the original stroke calculated in the preprocessing stage; Step S563: Generate two control points based on the endpoint coordinates and the direction angle θ: Control point C1 is obtained by offsetting 0.3 times the line segment length from P1 along the θ direction; control point C2 is obtained by offsetting 0.3 times the line segment length from P2 in the opposite direction along the θ+180° direction; The calculation formula for the control point offset is: Δx=0.3×(x2-x1), Δy=0.3×(y2-y1); Step S564: Connect endpoint P1, control points C1 and C2, and endpoint P2 to generate a cubic Bezier curve. The path width is set to the average pixel width W of the stroke. A vector description file containing the path coordinates and width is generated. Step S565: Calculate the coverage of path boundary pixels, set the RGB value of pixels with coverage ≥ 50% to (0, 0, 0), and fill the pixels with coverage < 50% with grayscale proportionally. The RGB value of pixels with coverage < 50% = coverage × 255. Step S566: Convert the anti-aliased path data into a binary image, perform a 3×3 pixel morphological closing operation on the path coverage area, eliminate edge burrs and fill internal gaps, and output a continuous and smooth repair stroke.

[0012] A second aspect of the present invention provides a multi-threaded image compression device, comprising a processor, a memory, and a communication bus; The memory stores a computer-readable program executable by the processor; The communication bus realizes the connection and communication between the processor and the memory; When the processor executes the computer-readable program, it is executed to implement a multi-threaded image compression method as described in any one of the present inventions.

[0013] A third aspect of the present invention provides a multi-threaded compressed image storage medium, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor, the steps of a multi-threaded image compression method as described in any one of the present invention are implemented.

[0014] As described above, the multi-threaded image compression method, device, and storage medium provided by the present invention have at least the following beneficial effects: This method not only technically implements multiple key capabilities, including image content perception, dynamic scheduling of compression resources, real-time compression quality control, and image structure restoration, but also effectively addresses the severe compression distortion, low processing efficiency, and structural disorganization issues that plague traditional compression technologies when processing large-scale tender documents. It possesses significant technical value and broad application prospects in improving image compression quality, optimizing file size control, and enhancing the efficiency of image and text data transmission and storage. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0016] Figure 1 It is a schematic diagram of the connection of each step of the method of the present invention. DETAILED DESCRIPTION

[0017] The above contents described below in conjunction with the implementation of the present invention are merely examples and explanations of the concept of the present invention. Those skilled in the art may make various modifications or additions to the described specific embodiments or replace them in a similar manner. As long as they do not deviate from the concept of the invention or exceed the scope defined by the claims, they shall fall within the scope of protection of the present invention.

[0018] Example 1 See also Figure 1 As shown, a multi-threaded image compression method includes: Step S1: Using an image semantic segmentation model, the large-size tender document image to be compressed is divided into feature blocks, and segmentation metadata including table blocks, image blocks, and text blocks is generated. A spatial distribution heat map is created based on the pixel size of each block. The step S1 includes the following sub-steps: Step S11: performing multi-channel decomposition processing on the compressed tender document image, extracting RGB three-channel data and brightness channel data, and performing Gaussian filtering on the image edge to reduce noise, thereby generating pre-processed four-channel image data; Step S12: Input the four-channel image data into the pre-trained semantic segmentation model, extract texture features through a multi-layer convolutional network, perform bounding box regression positioning on the table block, perform instance segmentation on the image block, perform connected domain analysis on the text block, and output segmentation metadata annotated with block type and coordinates, where block types are divided into table blocks, image blocks, and text blocks; Step S13: Based on the coordinate information recorded in the partition metadata, the pixel size of each block is counted and the relative proportion is calculated. The quantification formula is: block area proportion = number of pixels in the current block / total number of pixels in the entire image. The spatial coordinates of the center point of each block are also recorded. Step S14: Based on the block area ratio and center coordinate data, with the full map size as the reference coordinate system, apply Gaussian kernel density estimation to the center point of each block. The kernel function radius is positively correlated with the block area ratio. By superimposing the kernel density distribution of each block, a spatial distribution heat map is generated. Specifically, it includes the following sub-steps: The original size of the tender image is used as the reference coordinate system, with the horizontal axis defined as the X-axis and the vertical axis as the Y-axis. The initial radius of the Gaussian kernel is calculated based on the block area ratio, with R_base = 10% of the diagonal length of the entire image, and the scaling factor k = 5. Perform kernel density calculation for each block: adjust the kernel radius R = R_base × k × P_area according to the block area ratio P_area, where P_area = number of block pixels / number of full-image pixels; use the block center coordinates (X_c, Y_c) as the center point of the Gaussian distribution, generate a two-dimensional Gaussian kernel distribution surface in the base coordinate system, and the kernel function standard deviation σ = R / 3; output the kernel density distribution matrix of the current block; Perform pixel-by-pixel overlay operation on the kernel density distribution matrices of all blocks. The specific operation logic is: align each matrix according to the original coordinate system position, perform arithmetic accumulation on the density values ​​of the overlapping blocks, and output the total density distribution map after preliminary overlay; Normalize the total density distribution map: calculate the maximum value D_max and the minimum value D_min of the density of the entire map; map the density value to the range of 0-1 according to the formula D_normalized=(D_current-D_min) / (D_max-D_min); convert the normalized data into the HSV color space, and the density value corresponds to the hue H gradually changing from blue (0) to red (1), thereby generating a spatial distribution heat map, where D_current refers to the original superimposed density value of the pixel point, and D_normalized is the standard density value after normalization.

[0019] This step first creates a reference coordinate system using the original bid image's width as the X-axis and its height as the Y-axis. The initial radius of the Gaussian kernel is set to one-tenth the diagonal length of the entire image. The actual diagonal pixel value is obtained by taking the square root of the sum of the squared width and height of the image, and then taking 10% of this as the base radius. A scaling factor of five is introduced to expand the adjustment range. For each feature block, the kernel's range is dynamically adjusted based on its pixel area relative to the total pixel area of ​​the entire image. Specifically, blocks with a high area ratio receive a larger kernel radius, ensuring a positive correlation between thermal distribution and actual content density. A kernel density surface is constructed using a two-dimensional normal distribution function, with the block's center coordinate as the center point of the Gaussian distribution. The standard deviation of the distribution curve is set to one-third of the kernel radius to ensure that high-density areas within the kernel radius precisely match the kernel radius range. The independent density matrices for all blocks are superimposed pixel by pixel at the original coordinate location, and the density values ​​of the overlapping areas are accumulated. The superimposed value for each pixel represents the combined density of the multiple blocks at that location. After completing the global overlay, the entire image is traversed to find the maximum and minimum density values. The current density value of each pixel is normalized: the difference between the current density value of the point and the minimum density value of the entire image is subtracted, and then divided by the difference between the maximum and minimum density values. The original density value is linearly mapped to a standardized range from zero to one. Finally, the normalized value is mapped to the HSV color space. The hue parameter H is gradually changed from zero to one, corresponding to the color wheel angle from 240 degrees (blue) to zero degrees (red). The saturation S and brightness V are fixed at their maximum values. The color gradient intuitively displays the spatial density distribution characteristics, thereby generating a heat map.

[0020] The step S12 includes: Step S121: normalize the input four-channel image data so that the values ​​of each channel are mapped to the range of 0-1 to generate standardized image data; input the standardized data into the first convolutional layer of the semantic segmentation model, extract primary texture features through a 3×3 convolution kernel, and output an initial feature map; Step S122: downsampling and upsampling operations are performed on the initial feature map in sequence: a low-resolution global feature map is generated by performing three maximum pooling operations with a step size of 2; the global feature map and the initial feature map are weighted fused channel by channel, with the weight distribution ratio of global features to local features to be 0.6 and 0.4, respectively; the fused feature map is transposed convolutionally restored to the original image resolution, and an enhanced feature map is output; Step S123: Extracting table candidate blocks from the enhanced feature map. The specific operations are as follows: scanning the feature map through a sliding window to detect blocks with horizontal / vertical line segment density greater than a threshold; performing bounding box regression on the candidate blocks and calculating the offset of the bounding box coordinates (x_min, y_min, x_max, y_max); using the non-maximum suppression algorithm to merge redundant boxes with an overlap rate greater than 0.7, and outputting a table block coordinate set, where (x_min, y_min) and (x_max, y_max) represent the horizontal and vertical start and end pixel positions of the block in the image coordinate system, respectively; Step S124: Segment the image for non-table blocks. The specific operations are as follows: generate candidate masks on the enhanced feature map and select blocks with color variance higher than a threshold; perform dilation-erosion processing on the edges of the candidate blocks using the mask refinement module to eliminate jagged edges; and output the binary mask and the corresponding image block coordinates. Step S125: Perform text recognition on the remaining unmarked blocks. The specific operations are as follows: adaptively binarize the brightness channel of the enhanced feature map and calculate the local threshold T = block average brightness × 0.8; mark connected domains based on the 8-neighborhood connectivity rule and exclude noise blocks with less than 20 pixels; expand the minimum bounding rectangle of each connected domain by 10% of its original size and output the coordinates of the text block; Step S126: Generate JSON-formatted partition metadata based on the coordinates of the table, image, and text blocks, including the block type, coordinate range, and area ratio; if the overlapping area of ​​two blocks exceeds 15% of the area of ​​the smaller block, they are merged into the same block, and finally the partition metadata of the table block, image block, and text block are output.

[0021] This step first normalizes the four-channel input image by dividing the pixel values ​​of each channel by the maximum value allowed by its data type (for example, by 255 for the R / G / B channels and by 1 for the alpha channel in RGBA format). This normalizes all values ​​to the range of 0 to 1, eliminating dimensionality differences and generating standardized image data. This data is then fed into the first convolutional layer of the semantic segmentation network. A 3×3 convolution kernel is used to slide across the image plane. At each location, the weighted sum of the central pixel and its eight neighboring pixels (weights obtained through model training) is calculated to extract basic texture features and output an initial feature map. The feature map resolution is then gradually compressed using three max-pooling operations with a stride of 2. Each pooling operation retains the pixel with the largest value within the 3×3 window, thereby capturing global context and forming a low-resolution feature map. After restoring the global feature map to its original resolution using bilinear interpolation, it is then weightedly fused with the original feature map according to the channel dimension, with global features receiving a 60% weight and local features receiving a 40% weight. This allows the network to simultaneously focus on both macrostructure and microscopic details. The fused feature map is reconstructed through transposed convolution, and the parameters of the transposed convolution kernel are dynamically adjusted through deconvolution operations, ultimately outputting an enhanced feature map of the same size as the original image. During the table detection phase, a sliding window is used to traverse the enhanced feature map. Within each window area, the pixel ratios of horizontal and vertical line segments are counted. Areas where the density of line segments in both directions exceeds a preset threshold are marked as table candidates. Bounding box regression is performed on the candidate areas, outputting the coordinates of the upper left corner (x_min, y_min) and lower right corner (x_max, y_max) of the rectangular box. Non-maximum suppression is used to filter out redundant boxes with an overlap of more than 70%, retaining the set of candidate boxes with the highest confidence. For non-table areas, candidate segmentation masks are generated on the enhanced feature map. Regions with a color variance above a threshold are selected as image candidates. Morphological dilation is used to expand the block edges, and erosion is used to smooth jagged edges, forming a continuous, closed image mask. For the remaining unclassified areas, the brightness channel was extracted and adaptively binarized. Binary segmentation was performed using a local threshold of 80% of the block's average brightness. Eight-neighborhood connected text regions were marked, and noise points with fewer than 20 pixels were filtered out. The bounding rectangle of the retained connected text region was expanded by one-tenth in both length and width to ensure the integrity of the text edges. Finally, the coordinates, type, and area ratio of all blocks were integrated to generate structured metadata.

[0022] Step S2: Execute a dynamic thread allocation strategy based on the partition metadata, perform a complexity evaluation calculation on each feature block, and generate a block complexity score; establish a processing priority queue based on the pixel ratio of each block in the spatial distribution heat map, and activate the priority processing flag for engineering drawing blocks that occupy a large space; Step S2 includes the following sub-steps: Step S21: Extract the type label and coordinate range of each block from the partition metadata, load the normalized density value of the spatial distribution heat map, and extract the RGB pixel matrix of the corresponding block from the original bid image according to the block type to generate a feature dataset to be processed; Step S22: Calculate the color level variance for each block in the feature data set to be processed, convert the RGB pixel matrix into the HSV color space and calculate the variance value of the hue channel; use the Sobel operator to detect the block edge and calculate the edge pixel ratio; generate a block complexity score table based on the color level variance value and the edge pixel ratio according to the preset weight coefficient; Step S23: A multi-level thread allocation strategy is set according to the block complexity score table. When the score exceeds the upper threshold, 4 threads are allocated. When the score is between the upper and lower thresholds, 2 threads are allocated. When the score is below the lower threshold, 1 thread is allocated. A thread allocation mapping table is generated and the correspondence between the block ID and the number of threads is recorded. Step S24: combining the pixel ratio data of each block in the heat map and the complexity score table, applying priority weights to engineering drawing blocks, calculating comprehensive priority parameters, and sorting them from high to low according to parameter values ​​to generate a global processing queue; Step S25: preload pixel data for the first N high-priority blocks in the processing queue, assign priority processing tasks to idle threads in the thread pool, and set a preemptive scheduling flag to allow high-priority tasks to interrupt thread occupancy of low-priority tasks.

[0023] This step extracts each block's type label (e.g., table, image, text), coordinate range, and normalized heatmap density value from the segmentation metadata. Based on this coordinate information, the corresponding RGB pixel matrix is ​​extracted from the original bid document image to form a feature dataset. For each block, the variance of pixel values ​​across the three RGB channels is calculated to characterize color complexity. The pixel data is converted to HSV color space, and the hue (H) channel is extracted. The distribution variance is then calculated to reflect color monotonicity. A Sobel edge detection operator is used to perform horizontal and vertical gradient operations on the block image. Edge pixels are detected and their proportion is calculated. The color variance and edge pixel proportion are weighted together using a preset 60:40 weighting ratio, with color representing 60% and edge representing 40% to generate a block complexity score. A three-level thread allocation strategy is implemented based on the complexity score: high and low thresholds are set. Blocks with scores exceeding the high threshold are processed in parallel using four threads, blocks between the thresholds are processed using two threads, and blocks below the low threshold are processed using a single thread. A mapping table between block ID and thread number is generated. Furthermore, based on the pixel area ratio (ratio of block area to the total map) recorded in the heat map, a priority weighting is applied to engineering drawing blocks. Specifically, the pixel ratio of these blocks is multiplied by 1.5 and then weighted with the complexity score at a 50:50 ratio to calculate a comprehensive priority parameter (comprehensive value = pixel ratio × 1.5 × 0.5 + complexity score × 0.5). Non-engineering drawing blocks are weighted directly at a 40:60 ratio of pixel ratio to complexity score. All blocks are sorted in descending order by the comprehensive parameter value to form a global processing queue. Data is preloaded (pixel matrices are pre-cached to video memory) for the top 20% of the queue's high-priority engineering drawing blocks. A preemptive scheduling mechanism is also enabled: when a high-priority task arrives, it is allowed to immediately preempt the compute thread occupied by a low-priority task. The context state of any interrupted task is saved in a cache and automatically resumed upon completion of the high-priority task, thereby precisely optimizing the processing timeliness of critical blocks.

[0024] Step S3: Establish a thread allocation mapping table based on the block complexity score, start a multi-level compression thread group for blocks with a complexity score higher than the threshold; start a single-thread fast compression channel for blocks with a complexity score lower than the threshold. The specific steps include the following: Step S31: setting complexity classification threshold parameters, determining a high complexity threshold θ_high and a low complexity threshold θ_low according to the statistical distribution of historical compression data, and forming a threshold segmentation interval; Step S32: Traverse the block complexity score table, mark the blocks with score values ​​greater than θ_high as high complexity blocks, mark the blocks with score values ​​between θ_low and θ_high as medium complexity blocks, and mark the blocks with score values ​​less than θ_low as low complexity blocks, and generate a block classification label table; Step S33: Establish a multi-level thread allocation rule based on the block classification label table: allocate a 4-thread parallel compression group to high-complexity blocks, a 2-thread compression group to medium-complexity blocks, and a single-thread compression channel to low-complexity blocks. Generate a thread allocation mapping table and record the thread configuration parameters of each block. Step S34: Initialize the multi-threaded compression task pool, load the lossless compression algorithm and multiple quantization parameter configurations for the compression thread group of high-complexity blocks, load the standard compression parameter template for medium-complexity blocks, and enable the fast binarization preprocessing channel for low-complexity blocks; Step S35: Start the distributed compression executor, dynamically allocate computing resources according to the thread allocation mapping table, enable the load balancer to perform sub-task sharding for high-complexity block tasks, directly call the single-threaded fast compression interface for low-complexity block tasks, monitor the thread execution status in real time and recycle idle resources.

[0025] Step S4: progressively evaluate the quality of the compressed blocks output by each thread. When it is detected that the local compression distortion exceeds a preset threshold, the associated threads of the adjacent blocks are triggered to dynamically adjust the compression parameters. Step S4 includes the following sub-steps: Step S41: performing a block-by-block quality check on the pixel matrix of each compressed block, and generating a quality score table by calculating a structural similarity index; wherein the structural similarity index is calculated by comparing differences in block brightness, contrast, and structural features; Step S42: Loading a preset quality threshold δ, screening blocks with a structural similarity index lower than δ in the quality score table, generating a list of abnormal blocks; and recording the spatial coordinates and corresponding thread IDs of the abnormal blocks; Step S43: Based on the block adjacency data of the spatial distribution heat map, find the associated blocks adjacent to the abnormal block in the four directions of east, south, west and north, and extract the thread ID and current compression parameter configuration of the associated blocks; Step S44: dynamically adjust the compression parameters of the associated threads; generate an adjusted parameter configuration file and push it to the corresponding threads.

[0026] This step compares the pixel matrices of the original and compressed blocks in multiple dimensions: extracting the mean difference in the luminance component to represent global brightness deviation, calculating the contrast component (based on the standard deviation of pixel values) to reflect loss of texture detail, and measuring the degree of structural feature matching through covariance analysis. These three components are weighted according to preset weights (20% for luminance, 30% for contrast, and 50% for structural features) to calculate the composite structural similarity index (SSIM) to generate a block quality score. A preset threshold δ (typically determined based on experimental data on human visual sensitivity) is then applied to filter out blocks with SSIM values ​​below the threshold. Their spatial coordinates and associated thread IDs are recorded to form an outlier list. Based on the adjacency data pre-stored in the spatial distribution heatmap, a four-way neighborhood search is performed for each outlier block to locate its directly adjacent blocks in the east, south, west, and north directions. The thread IDs and current compression parameters (such as JPEG quantization table version, WEBP compression ratio, and binarization threshold) of these blocks are then extracted. Dynamically adjust the compression parameters of associated threads: for example, for areas adjacent to high-distortion blocks, reduce the JPEG quantization step by 15% of the original value, increase the WEBP compression rate by 20%, and for text areas, lower the binarization threshold by 5% to enhance edge preservation. Generate an adjustment parameter configuration file and push it to the corresponding thread in real time.

[0027] Dynamically adjust the compression parameters of the associated thread, including the following sub-steps: Step S441: Calculate the JPEG quantization step adjustment coefficient K_quant based on the deviation ratio between the structural similarity index of the abnormal block and the quality threshold. The calculation formula is: K_quant = 1.2 × (δ - SSIM) / δ. When K_quant > 1, the quantization step is adjusted to K_quant times the original value. When K_quant ≤ 1, the original step remains unchanged. Where SSIM represents the structural similarity index of the abnormal block. Step S442: Based on the current WEBP compression ratio and structural similarity index of the associated block, the compression ratio target value C_new is recalculated according to the reverse compensation mechanism. The specific calculation logic is: C_new = C × (1 + (δ-SSIM) / 0.15). When C_new > 95%, the upper limit value is 95%; where C represents the current WEBP compression ratio of the associated block; Step S443: Extract the edge density value of the text block in the pre-processing stage, and adjust the binarization threshold T_bin = original threshold × (1-0.4 × E) according to the edge preservation requirement. If the adjusted threshold is lower than the minimum threshold T_min = 50, reset it to T_min; E is the edge density value in the pre-processing stage; Step S444: Integrate the above calculation results to generate an adjusted parameter configuration file, including the quantization step size multiple, WEBP compression ratio and binarization threshold parameters, and push it to the corresponding thread in real time to overwrite the original configuration.

[0028] After detecting the structural similarity index of anomaly blocks, the system first dynamically adjusts JPEG compression parameters based on the degree of deviation between the index and a preset quality threshold. The system calculates the ratio of the difference between the quality threshold and the measured structural similarity index to the quality threshold and multiplies this ratio by a factor of 1.2, which serves as the quantization step size adjustment factor. When this factor is greater than 1, the original quantization step size is increased by this factor to improve compression strength; otherwise, the original step size remains unchanged. Secondly, the WEBP compression process for associated blocks applies inverse compensation based on the deviation between the current compression ratio and the structural similarity index. Using the current compression ratio as a baseline, the system incrementally adjusts the quality deviation relative to the 0.15 baseline factor to generate a new compression target. If the calculated result exceeds the 95% compression rate cap, the compression rate is automatically truncated to this threshold. For special text blocks, the edge pixel density feature calculated in the preprocessing phase is extracted and the original binarization threshold is negatively reduced by 40% of the edge density value (higher edge density results in a larger threshold reduction). A grayscale value of 50 is set as a minimum protection threshold to prevent over-adjustment. Finally, the three parameters of quantization step adjustment coefficient, WEBP new compression rate and binarization threshold are integrated to generate a dynamic configuration file, which overwrites the original configuration through the thread-level real-time push mechanism.

[0029] Step S5: The main thread performs spatial coordinate alignment and splicing on the compressed blocks to generate a spliced ​​compressed image; visual continuity detection is performed on the spliced ​​seam blocks; when seam anomalies are detected, the seam repair engine is activated to perform color transition filling on the color difference blocks and stroke connection reconstruction on the broken text; Step S5 includes the following sub-steps: Step S51: Based on the original coordinate information of the blocks recorded in the partition metadata, a reference coordinate system is established with the upper left corner of the tender image as the origin, and the geometric position of the compressed blocks is calibrated; the blocks are spliced ​​row by row and column by column in the order of their center coordinates on the X / Y axis to generate a preliminary spliced ​​image and record the coordinates of the seam positions; Step S52: Extract RGB data of 3 pixels wide on both sides of the seam, calculate the color difference ΔE between adjacent pixels = √(ΔR² + ΔG² + ΔB²), and count the maximum and average ΔE values ​​in the seam area. When the maximum ΔE exceeds the threshold, mark it as an abnormal color difference area, and record the coordinate range and ΔE value of the abnormal seam. Step S53: Calling a pre-trained OCR model to recognize the text content after splicing, and comparing the recognition result with the OCR text of the original block character by character; locating the bounding box coordinates of the missing characters, extracting the binary image of the missing area and calculating the length of the broken gap of the strokes. If the gap length is ≥ 2 pixels, it is marked as a broken text area; Step S54: Merge the color difference abnormality and the text break abnormality coordinate data, and generate a repair priority according to the following rules: color difference abnormality priority = max (ΔE) × 20, text break priority = gap length × 50; generate a global repair task queue based on the priority values ​​from high to low; Step S55: Expand a 5-pixel buffer area to both sides of the seam line as the center, perform bilinear interpolation blending on the RGB channels of the pixels in the buffer area, and linearly attenuate the interpolation weight according to the distance from the seam; Step S56: extracting stroke endpoints based on the coordinates of the broken gaps in the text, generating a third-order Bezier curve connection path based on the endpoint coordinates, and keeping the path width consistent with the average width of the original strokes; performing anti-aliasing processing on the reconstructed path, and filling the path to generate continuous strokes; Step S57: re-perform color difference detection and OCR recognition on the repaired seam. If max (ΔE) ≤ 3 and the length of the text gap ≤ 1 pixel, the repair is marked as successful; if it fails to meet the requirements, the abnormal area is added back to the repair queue.

[0030] This step first establishes a reference coordinate system based on the original block coordinate information recorded in the partition metadata, with the upper left corner of the bid image as the origin. The compressed blocks are then geometrically calibrated. The X / Y coordinates of each block's center point are aligned with the reference coordinate system. The blocks are then spliced ​​row by row and column by column from left to right and top to bottom to generate a preliminary stitched image and record the seam coordinates of adjacent blocks. Color difference detection is performed on each seam: RGB data with a width of 3 pixels on either side of the seam is extracted. The square root of the sum of the squared differences between the red, green, and blue channels of adjacent pixels is calculated as the color difference ΔE. The maximum and average ΔE values ​​within the seam are calculated. Any maximum value exceeding the visual perception threshold is marked as a color difference anomaly, and the abnormal coordinate range and corresponding ΔE value are recorded. A pre-trained OCR model is simultaneously used to recognize the text content after splicing. The recognized text is compared character by character with the OCR results of the original block. Missing character areas are located and their bounding box coordinates are extracted. The continuity of the stroke breaks within the missing area along the text direction is calculated. A break exceeding 2 pixels is considered a text break anomaly. The color difference and text break anomaly data are combined, and a repair priority value is generated by multiplying the maximum color difference ΔE by 20 and the length of the break by 50. A higher value indicates greater urgency for repair, thus creating a global repair task queue. When performing gradient repair on color difference seams, a 5-pixel-wide buffer is expanded from the seam line to both sides. Within this buffer, bilinear interpolation is performed on the RGB channel values ​​of each pixel. Interpolation weights are assigned based on the distance of the pixel from the seam line, with pixels closer to the seam line receiving higher weights. This weighted calculation achieves a smooth transition. For broken characters, the coordinates of the stroke endpoints on either side of the gap are extracted. A cubic Bezier curve path is generated based on the direction of the line connecting the endpoints. The path width is strictly consistent with the average width of the original strokes. Anti-aliasing is also performed on the path edge pixels. The grayscale value is adjusted based on the proportion of the pixel area covered by the path to eliminate stair-step edges. After the repair is completed, the maximum color difference in the seam area and the length of the text gap are re-checked. If the color difference ΔE does not exceed 3 and the gap length does not exceed 1 pixel, the repair is considered successful. Otherwise, the abnormal area is reinserted into the repair queue and iterated until the quality requirements are met or the maximum number of iterations is reached.

[0031] Step S56 includes the following sub-steps: Step S561: Based on the binary image generated in step S53, the precise pixel coordinates of the ends of the strokes on both sides of the gap are extracted and recorded as the first endpoint P1 (x1, y1) and the second endpoint P2 (x2, y2) respectively; Step S562: Calculate the direction angle θ=arctan[(y2-y1) / (x2-x1)] of the line connecting endpoints P1 and P2, and determine the basic width of the connection path based on the average unit pixel width W of the original stroke calculated in the preprocessing stage; Step S563: Generate two control points based on the endpoint coordinates and the direction angle θ: Control point C1 is obtained by offsetting 0.3 times the line segment length from P1 along the θ direction; control point C2 is obtained by offsetting 0.3 times the line segment length from P2 in the opposite direction along the θ+180° direction; The calculation formula for the control point offset is: Δx=0.3×(x2-x1), Δy=0.3×(y2-y1); Step S564: Connect endpoint P1, control points C1 and C2, and endpoint P2 to generate a cubic Bezier curve. The path width is set to the average pixel width W of the stroke. A vector description file containing the path coordinates and width is generated. Step S565: Calculate the coverage of path boundary pixels, set the RGB value of pixels with coverage ≥ 50% to (0, 0, 0), and fill the pixels with coverage < 50% with grayscale proportionally. The RGB value of pixels with coverage < 50% = coverage × 255. Step S566: Convert the anti-aliased path data into a binary image, perform a 3×3 pixel morphological closing operation on the path coverage area, eliminate edge burrs and fill internal gaps, and output a continuous and smooth repair stroke.

[0032] This step extracts the precise coordinates of the stroke ends on either side of the gap from the binary image of the broken text gap generated in step S53. By scanning the pixel connectivity boundary of the gap area, the pixel coordinates of endpoints P1 and P2 are located and recorded as geometric point pairs on a two-dimensional plane. The stroke direction angle θ is calculated based on the endpoint coordinates: by taking the inverse tangent of the longitudinal and transverse coordinate differences between the two points, the horizontal inclination angle of the connecting line is obtained. This angle is used to control the direction of the generated curved path. The average unit pixel width W of the strokes calculated in the preprocessing stage (obtained by calculating the average width of all horizontal sections within the original stroke area) is also loaded as the base width for the reconstructed path to maintain visual consistency of the text. During the control point generation phase, a dynamic offset strategy is implemented along the endpoint line: control point C1 is generated by offsetting the starting point P1 by 30% of the total line length in the θ direction. Control point C2 is generated by offsetting the endpoint P2 in the opposite direction (θ+180°) by the same amount. The specific offsets are 30% of the horizontal difference in the line segment value as Δx, and 30% of the vertical difference as Δy. This symmetrical control point layout ensures a natural flow between the curve path and the original stroke direction. A cubic Bézier curve path is constructed by connecting P1-C1-C2-P2. The path width strictly inherits the original stroke mean value W, and a vector description file containing the coordinate sequence and width parameters is generated. When anti-aliasing the path boundary, the grayscale value is dynamically adjusted based on the area coverage of each pixel by the path (for example, a path covering the upper left quarter of a pixel is considered 25% coverage). Pixels with coverage exceeding 50% are set to pure black, while those with coverage below 50% are proportionally filled with grayscale (for example, 30% coverage corresponds to an RGB value of 76.5). Finally, the anti-aliased path is converted into a binary image, and a 3×3 pixel morphological closing operation is applied to the area covered by the path. First, a dilation operation is performed to expand the edge of the path to eliminate broken gaps, and then an erosion operation is performed to smooth burrs and fill internal gaps, outputting continuous repair strokes without breakpoints.

[0033] It should be added that the direction angle θ is calculated based on the longitudinal difference Δy=y2-y1 and the lateral difference Δx=x2-x1 of the coordinates of the two end points of the gap, θ=arctan(Δy / Δx), which represents the angle between the line segment and the horizontal axis (in radians) and is used to determine the offset direction of the control point.

[0034] Step S6: Encapsulate and output the compressed image after visual inspection processing.

[0035] Example 2 A multi-threaded image compression device includes a processor, a memory, and a communication bus; The memory stores a computer-readable program executable by the processor; The communication bus realizes the connection and communication between the processor and the memory; When the processor executes the computer-readable program, it is executed to implement a multi-threaded image compression method as described in any one of the present inventions.

[0036] Example 3 A multi-threaded compressed image storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of a multi-threaded image compression method as described in any one of the present inventions.

[0037] It should be noted that the intervals and thresholds are set for ease of comparison. The threshold size depends on the amount of sample data and the cardinality set by those skilled in the art for each set of sample data, as long as it does not affect the proportional relationship between the parameter and the quantized value. Furthermore, the above formulas are all dimensionless numerical calculations. These formulas are derived from software simulations of the most recent real-world conditions using large amounts of data. The preset parameters in these formulas are set by those skilled in the art based on actual conditions.

[0038] It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0039] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

[0040] Finally: The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A multi-threaded image compression method, characterized in that: The following steps are involved: Step S1: Using an image semantic segmentation model, the large-size tender document image to be compressed is divided into feature blocks, and segmentation metadata including table blocks, image blocks, and text blocks is generated. A spatial distribution heat map is created based on the pixel size of each block. Step S2: Execute a dynamic thread allocation strategy based on the partition metadata, perform complexity evaluation calculations on each feature block, and generate a block complexity score; Establish a processing priority queue based on the pixel ratio of each block in the spatial distribution heat map, and activate the priority processing flag for engineering drawing blocks that occupy a large space; Step S3: establishing a thread allocation mapping table based on the block complexity score, and starting a multi-level compression thread group for blocks with a complexity score higher than a threshold; Start a single-threaded fast compression channel for blocks with complexity scores below the threshold; Step S4: progressively evaluate the quality of the compressed blocks output by each thread. When it is detected that the local compression distortion exceeds a preset threshold, the associated threads of the adjacent blocks are triggered to dynamically adjust the compression parameters. Step S5: The main thread performs spatial coordinate alignment and splicing on the compressed blocks to generate a spliced ​​compressed image; visual continuity detection is performed on the spliced ​​seam blocks; when seam anomalies are detected, the seam repair engine is activated to perform color transition filling on the color difference blocks and stroke connection reconstruction on the broken text; Step S6: Encapsulate and output the compressed image after visual inspection processing.

2. A multi-threaded image compression method according to claim 1, characterized in that: The step S1 includes the following sub-steps: Step S11: performing multi-channel decomposition processing on the compressed tender document image, extracting RGB three-channel data and brightness channel data, and performing Gaussian filtering on the image edge to reduce noise, thereby generating pre-processed four-channel image data; Step S12: Input the four-channel image data into the pre-trained semantic segmentation model, extract texture features through a multi-layer convolutional network, perform bounding box regression positioning on the table block, perform instance segmentation on the image block, perform connected domain analysis on the text block, and output segmentation metadata annotated with block type and coordinates, where block types are divided into table blocks, image blocks, and text blocks; Step S13: Based on the coordinate information recorded in the partition metadata, the pixel size of each block is counted and the relative proportion is calculated. The quantification formula is: block area proportion = number of pixels in the current block / total number of pixels in the entire image. The spatial coordinates of the center point of each block are also recorded. Step S14: Based on the block area ratio and center coordinate data, with the full map size as the reference coordinate system, Gaussian kernel density estimation is applied to the center point of each block. The kernel function radius is positively correlated with the block area ratio. A spatial distribution heat map is generated by superimposing the kernel density distribution of each block.

3. A multi-threaded image compression method according to claim 2, characterized in that: The step S12 includes: Step S121: normalize the input four-channel image data so that the values ​​of each channel are mapped to the range of 0-1 to generate standardized image data; input the standardized data into the first convolutional layer of the semantic segmentation model, extract primary texture features through a 3×3 convolution kernel, and output an initial feature map; Step S122: downsampling and upsampling operations are performed on the initial feature map in sequence: a low-resolution global feature map is generated by performing three maximum pooling operations with a step size of 2; the global feature map and the initial feature map are weighted fused channel by channel, with the weight distribution ratio of global features to local features to be 0.6 and 0.4, respectively; the fused feature map is transposed convolutionally restored to the original image resolution, and an enhanced feature map is output; Step S123: Extracting table candidate blocks from the enhanced feature map. The specific operations are as follows: scanning the feature map through a sliding window to detect blocks with horizontal / vertical line segment density greater than a threshold; performing bounding box regression on the candidate blocks to calculate the offset of the bounding box coordinates (x_min, y_min, x_max, y_max); using the non-maximum suppression algorithm to merge redundant boxes with an overlap rate greater than 0.7, and outputting a table block coordinate set; Step S124: Segment the image for non-table blocks. The specific operations are as follows: generate candidate masks on the enhanced feature map and select blocks with color variance higher than a threshold; perform dilation-erosion processing on the edges of the candidate blocks using the mask refinement module to eliminate jagged edges; and output the binary mask and the corresponding image block coordinates. Step S125: Perform text recognition on the remaining unmarked blocks. The specific operations are as follows: adaptively binarize the brightness channel of the enhanced feature map and calculate the local threshold T = block average brightness × 0.8; mark connected domains based on the 8-neighborhood connectivity rule and exclude noise blocks with less than 20 pixels; expand the minimum bounding rectangle of each connected domain by 10% of its original size and output the coordinates of the text block; Step S126: Generate JSON-formatted partition metadata based on the coordinates of the table, image, and text blocks, including the block type, coordinate range, and area ratio; if the overlapping area of ​​two blocks exceeds 15% of the area of ​​the smaller block, they are merged into the same block, and finally the partition metadata of the table block, image block, and text block are output.

4. A multi-threaded image compression method according to claim 1, characterized in that: Step S4 includes the following sub-steps: Step S41: performing block-by-block quality detection on the pixel matrix of each compressed block, and generating a quality score table by calculating the structural similarity index; The structural similarity index is calculated by comparing the differences in brightness, contrast and structural features of the blocks; Step S42: Loading a preset quality threshold δ, screening blocks with a structural similarity index lower than δ in the quality score table, generating a list of abnormal blocks; and recording the spatial coordinates and corresponding thread IDs of the abnormal blocks; Step S43: Based on the block adjacency data of the spatial distribution heat map, find the associated blocks adjacent to the abnormal block in the four directions of east, south, west and north, and extract the thread ID and current compression parameter configuration of the associated blocks; Step S44: dynamically adjusting the compression parameters of the associated threads; Generate the adjusted parameter configuration file and push it to the corresponding thread.

5. A multi-threaded image compression method according to claim 4, characterized in that: Dynamically adjust the compression parameters of the associated thread, including the following sub-steps: Step S441: Calculate the JPEG quantization step adjustment coefficient K_quant based on the deviation ratio between the structural similarity index of the abnormal block and the quality threshold. The calculation formula is: K_quant = 1.2 × (δ - SSIM) / δ. When K_quant > 1, the quantization step is adjusted to K_quant times the original value. When K_quant ≤ 1, the original step remains unchanged. Where SSIM represents the structural similarity index of abnormal blocks; Step S442: Based on the current WEBP compression ratio and structural similarity index of the associated block, the compression ratio target value C_new is recalculated according to the reverse compensation mechanism. The specific calculation logic is: C_new = C × (1 + (δ-SSIM) / 0.15). When C_new > 95%, the upper limit value of 95% is taken. Where C represents the current WEBP compression ratio of the associated block; Step S443: Extract the edge density value of the text block in the pre-processing stage, and adjust the binarization threshold T_bin = original threshold × (1-0.4 × E) according to the edge preservation requirement. If the adjusted threshold is lower than the minimum threshold T_min = 50, reset it to T_min; E is the edge density value in the pre-processing stage; Step S444: Integrate the above calculation results to generate an adjusted parameter configuration file, including the quantization step size multiple, WEBP compression ratio and binarization threshold parameters, and push it to the corresponding thread in real time to overwrite the original configuration.

6. A multi-threaded image compression method according to claim 1, characterized in that: Step S5 includes the following sub-steps: Step S51: Based on the original coordinate information of the blocks recorded in the partition metadata, a reference coordinate system is established with the upper left corner of the tender image as the origin, and the geometric position of the compressed blocks is calibrated; the blocks are spliced ​​row by row and column by column in the order of their center coordinates on the X / Y axis to generate a preliminary spliced ​​image and record the coordinates of the seam positions; Step S52: Extract RGB data of 3 pixels wide on both sides of the seam, calculate the color difference ΔE between adjacent pixels = √(ΔR² + ΔG² + ΔB²), and count the maximum and average ΔE values ​​in the seam area. When the maximum ΔE exceeds the threshold, mark it as an abnormal color difference area, and record the coordinate range and ΔE value of the abnormal seam. Step S53: Calling a pre-trained OCR model to recognize the text content after splicing, and comparing the recognition result with the OCR text of the original block character by character; locating the bounding box coordinates of the missing characters, extracting the binary image of the missing area and calculating the length of the broken gap of the strokes. If the gap length is ≥ 2 pixels, it is marked as a broken text area; Step S54: Merge the color difference abnormality and the text break abnormality coordinate data, and generate a repair priority according to the following rules: color difference abnormality priority = max (ΔE) × 20, text break priority = gap length × 50; generate a global repair task queue based on the priority values ​​from high to low; Step S55: Expand a 5-pixel buffer area to both sides of the seam line as the center, perform bilinear interpolation blending on the RGB channels of the pixels in the buffer area, and linearly attenuate the interpolation weight according to the distance from the seam; Step S56: extracting stroke endpoints based on the coordinates of the broken gaps in the text, generating a third-order Bezier curve connection path based on the endpoint coordinates, and keeping the path width consistent with the average width of the original strokes; performing anti-aliasing processing on the reconstructed path, and filling the path to generate continuous strokes; Step S57: re-perform color difference detection and OCR recognition on the repaired seam. If max (ΔE) ≤ 3 and the length of the text gap ≤ 1 pixel, the repair is marked as successful; if it fails to meet the requirements, the abnormal area is added back to the repair queue.

7. A multi-threaded image compression method according to claim 6, characterized in that: Step S56 includes the following sub-steps: Step S561: Based on the binary image generated in step S53, the precise pixel coordinates of the ends of the strokes on both sides of the gap are extracted and recorded as the first endpoint P1 (x1, y1) and the second endpoint P2 (x2, y2) respectively; Step S562: Calculate the direction angle θ=arctan[(y2-y1) / (x2-x1)] of the line connecting endpoints P1 and P2, and determine the basic width of the connection path based on the average unit pixel width W of the original stroke calculated in the preprocessing stage; Step S563: Generate two control points based on the endpoint coordinates and the direction angle θ: Control point C1 is obtained by offsetting 0.3 times the line segment length from P1 along the θ direction; control point C2 is obtained by offsetting 0.3 times the line segment length from P2 in the opposite direction along the θ+180° direction; The calculation formula for the control point offset is: Δx=0.3×(x2-x1), Δy=0.3×(y2-y1); Step S564: Connect endpoint P1, control points C1 and C2, and endpoint P2 to generate a cubic Bezier curve. The path width is set to the average pixel width W of the stroke. A vector description file containing the path coordinates and width is generated. Step S565: Calculate the coverage of path boundary pixels, set the RGB value of pixels with coverage ≥ 50% to (0, 0, 0), and fill the pixels with coverage < 50% with grayscale proportionally. The RGB value of pixels with coverage < 50% = coverage × 255. Step S566: Convert the anti-aliased path data into a binary image, perform a 3×3 pixel morphological closing operation on the path coverage area, eliminate edge burrs and fill internal gaps, and output a continuous and smooth repair stroke.

8. A multi-threaded image compression device, characterized in that: It is implemented based on a multi-threaded image compression method according to any one of claims 1 to 7, and includes a processor, a memory, and a communication bus; The memory stores a computer-readable program executable by the processor; The communication bus realizes the connection and communication between the processor and the memory; When the processor executes the computer-readable program, it implements the multi-threaded image compression method according to any one of claims 1 to 7.

9. A multi-threaded compressed image storage medium, characterized in that: The storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of a multi-threaded image compression method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Multi-thread image printing method, printing controller, medium and product

    CN120929030A

  • Plane image compression method

    CN121000883A