Image coding method and device based on dynamic partitioning, equipment and medium
By employing dynamic block segmentation and hybrid entropy coding techniques, the problems of insufficient block size and resource utilization in image compression are solved, achieving efficient image coding suitable for rapid compression of high-resolution video, medical images, and satellite remote sensing data.
Patent Information
- Application Number
- CN202511180791.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-22
- Publication Date
- 2025-11-18
AI Technical Summary
In existing image compression technologies, insufficient fixed block size leads to low coding efficiency, entropy coding technology relies on predefined probability tables, resulting in high costs for commercial applications, and insufficient utilization of heterogeneous computing resources fails to fully leverage the parallel computing potential of GPUs and CPUs.
Dynamic block segmentation technology is adopted to adaptively adjust the block size according to local image features. Combined with Range-ANS entropy coding and adaptive Huffman entropy coding, the collaborative processing of GPU and CPU is optimized to improve hardware resource utilization.
It significantly improves image coding efficiency, and is particularly suitable for high-resolution video processing, medical image transmission and storage, and rapid compression of satellite remote sensing data. It improves coding speed and compression efficiency, and reduces the cost of hardware resources.
Smart Images

Figure CN120980239A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image compression and coding, and particularly relates to an image coding method and device based on dynamic block, equipment and medium. BACKGROUND
[0002] Traditional JPEG2000 realizes efficient compression of images through discrete wavelet transform and EBCOT coding, but the core MQ arithmetic coding has the problems of strong seriality and difficulty in parallelization. Although the subsequent development of HTJ2K improves the processing speed through MEL / VLC coding, it still relies on the fixed size of the four-tuple division structure, which leads to insufficient compression efficiency in complex image areas. That is, the main limitations of the prior art are as follows:
[0003] 1. The adaptability of fixed block is insufficient. The traditional method uses a uniform block size, which cannot be dynamically adjusted according to the complexity of the local content of the image. When processing high-texture areas, small-size blocks are not fully utilized, resulting in a decrease in compression efficiency. Using small-size blocks in smooth areas causes waste of computing resources. In mixed images containing complex textures and simple backgrounds, fixed blocks can cause a 12-18% loss of coding efficiency.
[0004] 2. Technical monopoly problem of entropy coding technology. The MEL / VLC coding used by HTJ2K is highly dependent on the pre-defined probability table structure, and these core implementation methods have technical monopoly. This not only limits the flexible application and improvement space of the technical solution, but also increases the cost of commercial application.
[0005] 3. Insufficient utilization of heterogeneous computing resources. The existing scheme lacks depth optimization in GPU and CPU cooperative processing. The parallel computing capability of GPU is not fully utilized for processing high-parallelism entropy coding tasks, and CPU also fails to exert the acceleration potential of AVX and other instruction sets when processing serial tasks. The hardware resource utilization rate of the traditional scheme on a typical service platform is less than 60%. SUMMARY
[0006] To solve the above problems, the present application provides an image coding method, device, equipment and medium based on dynamic block, which improves compression efficiency through content-aware dynamic block technology, avoids technical monopoly of the prior art by using an open entropy coding scheme, and maximizes hardware resource utilization rate based on a heterogeneous computing architecture optimized by GPU and CPU in cooperation.
[0007] The present application adopts the following technical solutions:
[0008] In a first aspect, an image coding method based on dynamic block is provided, which comprises:
[0009] An image to be encoded is acquired, and frequency domain processing is performed on the image to be encoded to determine a high frequency subband and a low frequency subband of the image to be encoded.
[0010] The image regions corresponding to the high frequency subband and the low frequency subband are respectively dynamically divided into a plurality of sub-image blocks of different sizes.
[0011] Range-ANS entropy coding technology is used to generate a high frequency code stream for each sub-image block of the high frequency subband, adaptive Huffman entropy coding technology is used to generate a low frequency code stream for each sub-image block of the low frequency subband, and the high frequency code stream and the low frequency code stream are combined into an encoding code stream of the image to be encoded.
[0012] In a second aspect, an image encoding device based on dynamic division is provided, and the device comprises:
[0013] A transform unit is configured to acquire an image to be encoded, perform frequency domain processing on the image to be encoded, and determine a high frequency subband and a low frequency subband of the image to be encoded.
[0014] A division unit is configured to dynamically divide image regions corresponding to the high frequency subband and the low frequency subband into a plurality of sub-image blocks of different sizes.
[0015] An encoding unit is configured to use Range-ANS entropy coding technology to generate a high frequency code stream for each sub-image block of the high frequency subband, use adaptive Huffman entropy coding technology to generate a low frequency code stream for each sub-image block of the low frequency subband, and combine the high frequency code stream and the low frequency code stream into an encoding code stream of the image to be encoded.
[0016] In a third aspect, the present application further provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the image encoding method based on dynamic division when executing the computer program.
[0017] In a fourth aspect, the present application further provides a computer readable storage medium storing a computer program, wherein the computer program implements the steps of the image encoding method based on dynamic division when being instructed by a processor.
[0018] The above at least one technical solution adopted by the present application can achieve the following beneficial effects:
[0019] The method provided in the present application obtains a to-be-encoded image, performs frequency domain processing on the to-be-encoded image, determines a high-frequency subband and a low-frequency subband of the to-be-encoded image, dynamically divides image regions corresponding to the high-frequency subband and the low-frequency subband into a plurality of sub-image blocks of different sizes respectively, generates a high-frequency code stream by using Range-ANS entropy coding technology on each sub-image block of the high-frequency subband, generates a low-frequency code stream by using adaptive Huffman entropy coding technology on each sub-image block of the low-frequency subband, and combines the high-frequency code stream and the low-frequency code stream into an encoding code stream of the to-be-encoded image. The method provided in the present application is particularly suitable for application scenarios such as high-resolution video processing, medical image transmission and storage, and rapid compression of satellite remote sensing data, and can significantly improve coding efficiency while maintaining high-quality image restoration. BRIEF DESCRIPTION OF DRAWINGS
[0020] The accompanying drawings, which are included to provide a further understanding of the present application, constitute a part of the present application and illustrate embodiments of the present application and specific examples thereof, which serve to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0021] Figure 1 A flowchart of an image coding method based on dynamic block division according to one embodiment of the present application is shown;
[0022] Figure 2 A schematic diagram of a to-be-encoded image according to one embodiment of the present application is shown;
[0023] Figure 3 A schematic diagram of image overall gradient distribution of a to-be-encoded image according to one embodiment of the present application is shown;
[0024] Figure 4 A schematic diagram of dynamic block division results of a to-be-encoded image according to one embodiment of the present application is shown;
[0025] Figure 5 A flowchart of an image coding method based on dynamic block division according to another embodiment of the present application is shown;
[0026] Figure 6 A structural schematic diagram of an image coding device based on dynamic block division according to one embodiment of the present application is shown;
[0027] Figure 7 A structural schematic diagram of an electronic device according to one embodiment of the present application is shown. DETAILED DESCRIPTION
[0028] In order to make the purposes, technical solutions and advantages of the present application clearer, the technical solutions of the present application will be described clearly and completely below in combination with specific embodiments of the present application and corresponding drawings. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work belong to the scope of protection of the present application.
[0029] Figure 1 A flowchart of an image coding method based on dynamic block proposed in an embodiment of the present application is shown. Referring to Figure 1 , the method comprises steps S110-S130:
[0030] In step S110, an image to be coded is obtained, and the image to be coded is processed in the frequency domain to determine a high-frequency subband and a low-frequency subband of the image to be coded.
[0031] In application scenarios such as high-resolution video processing, medical image transmission and storage, and fast compression of satellite remote sensing data, it is necessary to improve coding efficiency while ensuring high-quality image restoration. Therefore, an image coding method based on dynamic block and hybrid entropy coding is proposed in an embodiment of the present application.
[0032] An image to be coded is obtained. The image to be coded can be a frame of high-resolution video, a medical image, a satellite remote sensing data, etc. The method of obtaining the image to be coded is not specifically limited.
[0033] The image to be coded is subjected to frequency domain transformation to generate a frequency coefficient matrix of the image to be coded. The frequency coefficient matrix is divided into a high-frequency subband and a low-frequency subband according to the frequency level.
[0034] The division of the high-frequency subband and the low-frequency subband can be determined according to experience, as long as part of the image to be coded belongs to the high-frequency subband and another part of the image to be coded belongs to the low-frequency subband.
[0035] In some optional embodiments, in step S110, an image to be coded is obtained, and the image to be coded is processed in the frequency domain to determine a high-frequency subband and a low-frequency subband of the image to be coded, comprising: obtaining the image to be coded; performing frequency domain processing on the image to be coded by using CDF 9 / 7 wavelet transform or LeGall 5 / 3 wavelet transform; and determining the high-frequency subband and the low-frequency subband of the image to be coded according to a predefined division rule.
[0036] When performing frequency domain processing on the to-be-encoded image, a CDF 9 / 7 wavelet transform or a LeGall 5 / 3 wavelet transform can be used to obtain a frequency coefficient matrix of the to-be-encoded image. Then, the to-be-encoded image is divided into a high-frequency subband and a low-frequency subband according to a pre-defined division rule based on experience.
[0037] In step S120, the image regions corresponding to the high-frequency subband and the low-frequency subband are dynamically divided into a plurality of sub-image blocks of different sizes, respectively.
[0038] In the present application, a dynamic adaptive block partitioning (DABP) is used when the image regions corresponding to the high-frequency subband and the low-frequency subband are divided. The dynamic adaptive block partitioning means that intelligent division of adaptive sizes is realized by analyzing local features of the image.
[0039] For image positions including complex details and texture information, smaller sizes are used for division, and for image positions belonging to smooth backgrounds and the like, larger sizes are used for division. Through intelligent division of adaptive sizes, small-size blocks can be fully utilized when high-texture positions are processed, and large-size blocks can be used for smooth positions to reduce resource consumption.
[0040] In some optional embodiments, in step S120, the image regions corresponding to the high-frequency subband and the low-frequency subband are dynamically divided into a plurality of sub-image blocks of different sizes, respectively, including: dividing the image regions corresponding to the high-frequency subband and the low-frequency subband into a plurality of basic regions, respectively; calculating a gradient mean value of each basic region; determining an overall gradient distribution of the to-be-encoded image according to the gradient mean values of all the basic regions; determining a plurality of gradient ranges with different complexities according to the overall gradient distribution of the image; dividing each basic region into a sub-region of a corresponding size based on the gradient range to which the basic region belongs, wherein the higher the complexity of the gradient range to which the basic region belongs, the smaller the size of the sub-region to which the basic region is divided; and determining a plurality of sub-image blocks according to the distribution of the sub-regions.
[0041] For example, when the dynamic adaptive block partitioning is performed, the image regions corresponding to the high-frequency subband and the low-frequency subband are divided into a plurality of basic regions, and the size of each basic region can be 16x16 pixels. To avoid block effects, an overlapping window technique can be used to consider boundary problems.
[0042] For each basic region, an improved Sobel operator with a 3x3 convolution kernel is used to calculate the horizontal gradient G x and the vertical gradient G y of each pixel in the basic region, so as to improve the accuracy of classification of the basic region.
[0043] The horizontal gradient G x and the vertical gradient G y of each pixel in the basic region are calculated by using an improved Sobel operator with a 3x3 convolution kernel, so as to improve the accuracy of classification of the basic region.x and vertical gradient G y The gradient amplitude G(x, y) of each pixel is calculated based on formula (1):
[0044]
[0045] wherein x represents the horizontal coordinate of the pixel, and y represents the vertical coordinate of the pixel.
[0046] According to the gradient amplitude G(x, y), the gradient amplitude integral graph S(i, j) is constructed based on formula (2):
[0047]
[0048] wherein i represents the row index of the pixel, and j represents the column index of the pixel.
[0049] According to the gradient amplitude integral graph S(i, j), the gradient mean μ of the base region is calculated based on formula (3):
[0050]
[0051] wherein (x1, y1) represents the upper left corner coordinate of the base region, and (x2, y2) represents the lower right corner coordinate of the base region.
[0052] The gradient means of all the base regions are sorted to obtain the image overall gradient distribution {μ1, μ2, …, μM×N} of the image to be encoded, wherein MxN represents the number of the base regions, M represents the row, and N represents the column. M×N} of the image to be encoded, wherein MxN represents the number of the base regions, M represents the row, and N represents the column.
[0053] The gradient mean corresponding to the 70th percentile in the image overall gradient distribution is taken as the high complexity boundary T1, and the gradient mean corresponding to the 30th percentile in the image overall gradient distribution is taken as the low complexity boundary T2.
[0054] When the gradient mean of a base region is not lower than T1, the base region is divided into a 16x16 pixel sub-region to retain details.
[0055] When the gradient mean of a base region is not lower than T2 and lower than T1, the base region is divided into a 32x32 pixel sub-region to balance the compression efficiency and the detail retention.
[0056] When the gradient mean of a base region is lower than T2, the base region is divided into a 64x64 pixel sub-region for efficient compression.
[0057] According to the distribution of the plurality of sub-regions, the base regions are integrated into a plurality of sub-image blocks of different sizes.
[0058] The above process is only an exemplary illustration of dynamic adaptive partitioning. The specific manner of dividing the gradient range (i.e., determining the complexity boundary of a value), and the manner of dividing the sub-regions into different sizes can be flexibly adjusted according to actual conditions.
[0059] For example: Figure 2 A schematic diagram of an image to be encoded is shown. Figure 3 A schematic diagram of the overall gradient distribution of an image to be encoded is shown. Figure 3 The warmer the color in the color gradient distribution, the higher the gradient. The cooler the color, the lower the gradient. Figure 4 A schematic diagram of the dynamic partitioning result of an image to be encoded is shown. Figure 4 The blue color in the color gradient distribution represents a 64x64 pixel sub-region, the yellow color represents a 32x32 pixel sub-region, and the red color represents a 16x16 pixel sub-region.
[0060] In some optional embodiments, the step S120 of dynamically partitioning the image regions corresponding to the high-frequency sub-band and the low-frequency sub-band into a plurality of sub-image blocks of different sizes includes: performing parallel processing of the partitioning tasks of each base region by a plurality of threads of a GPU; and storing the partitioning result of the image to be encoded into a plurality of sub-image blocks in a shared memory.
[0061] In order to improve the efficiency of dynamic adaptive partitioning, a gradient calculation kernel is designed based on the architecture of a graphics processing unit (GPU). Each thread of the GPU processes each base region, thereby achieving a speedup of several times that of a central processing unit (CPU).
[0062] The partitioning result is stored in a shared memory to reduce the access delay of a global memory.
[0063] The step S130 of generating a high-frequency code stream for each sub-image block of the high-frequency sub-band using Range-ANS entropy coding technology, generating a low-frequency code stream for each sub-image block of the low-frequency sub-band using adaptive Huffman entropy coding technology, and combining the high-frequency code stream and the low-frequency code stream into an encoded code stream of the image to be encoded.
[0064] After the preprocessing of the image to be encoded is completed through frequency domain transformation and dynamic partitioning, a high-frequency code stream is generated for each sub-image block of the high-frequency sub-band using Range-ANS entropy coding technology, a low-frequency code stream is generated for each sub-image block of the low-frequency sub-band using adaptive Huffman entropy coding technology, and then the high-frequency code stream and the low-frequency code stream are combined into an encoded code stream of the image to be encoded, thereby realizing the compression and encoding of the image to be encoded. The high-frequency sub-band encoding and the low-frequency sub-band encoding are parallel.
[0065] In some optional embodiments, in step S130, the Range-ANS entropy coding technique is used to generate the high-frequency code stream for each sub-image block of the high-frequency sub-band, including: determining a significant point set in a 3x3 neighborhood for each target high-frequency pixel in a sub-image block of the high-frequency sub-band, wherein the significant point is a neighborhood point with a coefficient value greater than 10% of the maximum coefficient value; determining a target context index value according to the binary result of each significant point set; determining a target probability model according to each target context index value; and encoding each target high-frequency pixel in the sub-image block to generate a high-frequency code stream segment according to the probability table maintained by each target probability model; wherein in the encoding process, each probability table maintained by each target probability model is continuously updated by an exponentially weighted moving average algorithm; and combining each high-frequency code stream segment generated by each sub-image block in the order of the position of the sub-image block to form the high-frequency code stream.
[0066] The flow of Range-ANS entropy coding for each sub-image block of the high-frequency sub-band is as follows:
[0067] 1. Modeling.
[0068] For a high-frequency pixel in a sub-image block, its 3x3 neighborhood includes 8 neighborhood points. If the coefficient value of a neighborhood point is greater than 10% of the maximum coefficient value of the sub-image block, the neighborhood point is determined as a significant point.
[0069] The 8 neighborhood points are converted into binary patterns according to "whether they are significant points". For example, "1" represents significant, and "0" represents insignificant. The context index value can be generated according to formula (4):
[0070]
[0071] wherein r represents the order number of the neighborhood point, δ represents the indicator function, P r represents the coefficient value of the neighborhood point, and θ represents 10% of the maximum coefficient value of the sub-image block; δ takes 1 when P r > θ, and δ takes 0 when P r ≤ θ.
[0072] A corresponding probability model (i.e., 256 probability models) is established for each context index value, and each probability model maintains the probability distribution of 256 symbols, i.e., each context index value corresponds to a probability model, and each probability model corresponds to a probability table.
[0073] 2. Encoding.
[0074] For each target high-frequency pixel in a sub-image block, the significant point set of the 8 neighborhood points in the 3x3 neighborhood of each target high-frequency pixel is determined, and the target context index value corresponding to each target high-frequency pixel can be determined according to the binary result of the significant point set.
[0075] Each target context index value is matched in all context index values generated in the modeling stage, i.e., each target probability model corresponding to each target context index value and each target probability table maintained by each target probability model are determined.
[0076] Each target high-frequency pixel is encoded by using the corresponding target probability table, and one sub-image block corresponds to generate one high-frequency code stream segment.
[0077] 3. Probability table updating.
[0078] In the encoding process, each probability table maintained by each probability model is continuously updated by an exponential weighted moving average algorithm (EWMA).
[0079] The update formula can be expressed as new probability = a x current frequency + (1-a) x historical frequency, and a can be 0.05.
[0080] 4. High-frequency code stream merging.
[0081] The high-frequency code stream segments generated by each sub-image block are merged in the order of the positions of the sub-image blocks, and finally a high-frequency code stream is formed.
[0082] In some optional embodiments, in step S130, the adaptive Huffman entropy coding technology is used to generate a low-frequency code stream for each sub-image block of the low-frequency subband, including: encoding each low-frequency pixel in one sub-image block of the low-frequency subband according to a dynamic Huffman table to generate a low-frequency code stream segment; wherein the difference coding of the dynamic Huffman table is embedded in the head of the low-frequency code stream segment; in the encoding process, the dynamic Huffman table is updated when the statistical window threshold is reached; each low-frequency code stream segment generated by each sub-image block is merged in the order of the positions of the sub-image blocks to form a low-frequency code stream; the updating process of the dynamic Huffman table includes: using the AVX-512 instruction set to parallelly count the coefficient value frequency of each low-frequency pixel in all sub-image blocks in the current statistical window; according to the coefficient value frequency, using a sliding window exponential decay algorithm to incrementally update the coefficient value frequency distribution; based on the updated coefficient value frequency distribution, using a Canonical Huffman algorithm to update the dynamic Huffman table; and performing difference coding processing on the updated dynamic Huffman table.
[0083] The process of using adaptive Huffman entropy coding for each sub-image block of the low-frequency subband is as follows:
[0084] 1. Dynamic code table generation.
[0085] A statistical window threshold is set, which is 1 second or 1024 sub-image blocks. The coefficient value frequency of each low-frequency pixel in all sub-image blocks in the current statistical window is counted in parallel every 1 second or every 1024 sub-image blocks by using the AVX-512 instruction set (such as _mm512_conflict_epi32) of the CPU.
[0086] The coefficient value frequency distribution is incrementally updated by using a sliding window exponential decay algorithm, and the data weight in the old statistical window decays over time during the incremental update.
[0087] The latest dynamic Huffman table is generated by using a Canonical Huffman algorithm.
[0088] 2. Encoding is synchronized with the code table.
[0089] Each low-frequency pixel in the sub-image block is encoded according to the dynamic Huffman table to generate a low-frequency code stream segment, and one sub-image block corresponds to one low-frequency code stream segment.
[0090] The difference coding of the dynamic Huffman table (flag bit, symbol quantity, symbol list, code length list, canonical code table, etc.) is embedded in the header of the low-frequency code stream segment to reduce the code table storage overhead, and a CRC32 check code can be added to ensure transmission reliability.
[0091] 3. Low-frequency code stream merging.
[0092] The low-frequency code stream segments generated by each sub-image block are merged in the order of the positions of the sub-image blocks, and finally the low-frequency code stream is formed.
[0093] In some optional embodiments, in step S130, the Range-ANS entropy coding technology is used to generate a high-frequency code stream for each sub-image block of the high-frequency sub-band, the adaptive Huffman entropy coding technology is used to generate a low-frequency code stream for each sub-image block of the low-frequency sub-band, and the high-frequency code stream and the low-frequency code stream are merged into the encoding code stream of the to-be-encoded image, including: the encoding tasks of each sub-image block of the high-frequency sub-band are processed in parallel by a plurality of threads of a GPU, and the probability table is stored in a shared memory; the encoding tasks of the low-frequency sub-band are processed by a CPU; and the merging tasks of the encoding code stream are processed by the CPU
[0094] For the encoding tasks of the high-frequency sub-band, the GPU is used for parallel optimization. That is, each GPU thread processes a sub-image block of the high-frequency sub-band. The probability table is cached in the shared memory to reduce the global memory access delay. The zero-copy memory technology is used to reduce the data migration overhead between the GPU and the CPU.
[0095] The encoding task of the low-frequency subband and the global bitstream organization (i.e., the merging task of the encoded bitstream) are processed by the CPU. The high-frequency bitstream and the low-frequency bitstream are merged by the CPU, and the frame header information (such as the block parameter, the code table index, etc.) is added, so as to form the final encoded bitstream.
[0096] Based on the method proposed in the application, the 4K video encoding speed can reach 180fps on the NVIDIA A100 platform, which is about 40% higher than HTJ2K; the high-frequency subband BD-rate is reduced by about 7%, the low-frequency subband BD-rate is reduced by about 4%, and the compression efficiency is improved; by means of dynamic block and Range-ANS entropy encoding technology, adaptive Huffman entropy encoding technology, the HTJ2K core technology monopoly is effectively avoided.
[0097] Figure 5 A flowchart of an image encoding method based on dynamic block proposed by another embodiment of the application is shown. Referring to Figure 5 , the method comprises steps S501-S506:
[0098] In step S501, an image to be encoded is obtained, and the image to be encoded is processed in the frequency domain to determine the high-frequency subband and the low-frequency subband of the image to be encoded. Go to step S502.
[0099] In step S502, the image regions corresponding to the high-frequency subband and the low-frequency subband are respectively dynamically blocked into a plurality of sub-image blocks of different sizes. Go to step S503.
[0100] In step S503, it is judged whether a sub-image block belongs to the high-frequency subband or the low-frequency subband. If it belongs to the high-frequency subband, go to step S504; if it belongs to the low-frequency subband, go to step S505.
[0101] In step S504, the Range-ANS entropy encoding technology is used to generate a high-frequency bitstream segment for the sub-image block, and the high-frequency bitstream segments generated by each sub-image block are merged in the order of the position of the sub-image block to form a high-frequency bitstream. Go to step S506.
[0102] In step S505, the adaptive Huffman entropy encoding technology is used to generate a low-frequency bitstream segment for the sub-image block, and the low-frequency bitstream segments generated by each sub-image block are merged in the order of the position of the sub-image block to form a low-frequency bitstream. Go to step S506.
[0103] In step S506, the high-frequency bitstream and the low-frequency bitstream are merged into the encoded bitstream of the image to be encoded.
[0104] Based on the same inventive concept, Figure 6 A structure diagram of an image encoding device based on dynamic block proposed by one embodiment of the application is shown. Referring to Figure 6 , the device 600 comprises:
[0105] The transformation unit 610 is configured to obtain an image to be encoded, perform frequency domain processing on the image to be encoded, and determine a high frequency subband and a low frequency subband of the image to be encoded.
[0106] The blocking unit 620 is configured to dynamically block image regions corresponding to the high frequency subband and the low frequency subband into a plurality of sub-image blocks of different sizes, respectively.
[0107] The encoding unit 630 is configured to generate a high frequency code stream by using a Range-ANS entropy coding technology on each sub-image block of the high frequency subband, generate a low frequency code stream by using an adaptive Hauffman entropy coding technology on each sub-image block of the low frequency subband, and combine the high frequency code stream and the low frequency code stream into an encoding code stream of the image to be encoded.
[0108] In some optional embodiments, the transformation unit 610 is specifically configured to obtain the image to be encoded, perform frequency domain processing on the image to be encoded by using a CDF 9 / 7 wavelet transform or a LeGall 5 / 3 wavelet transform, and determine the high frequency subband and the low frequency subband of the image to be encoded according to a predefined division rule.
[0109] In some optional embodiments, the blocking unit 620 is specifically configured to divide image regions corresponding to the high frequency subband and the low frequency subband into a plurality of basic regions, respectively, calculate a gradient mean value of each basic region, determine an overall gradient distribution of the image to be encoded according to gradient mean values of all the basic regions, determine a plurality of gradient ranges with different complexities according to the overall gradient distribution of the image, divide each basic region into a sub-region of a corresponding size based on a gradient range to which the basic region belongs, wherein the higher the complexity of the gradient range to which the basic region belongs, the smaller the size of the sub-region to which the basic region is divided, and determine the plurality of sub-image blocks according to a distribution of the plurality of sub-regions.
[0110] In some optional embodiments, the blocking unit 620 is specifically configured to perform parallel processing on a blocking task of each basic region by using a plurality of threads of a GPU, and store a blocking result of dividing the image to be encoded into the plurality of sub-image blocks in a shared memory.
[0111] In some optional embodiments, the encoding unit 630 is specifically configured to: determine a set of significant points in a 3x3 neighborhood for each target high-frequency pixel in one sub-image block of the high-frequency sub-band, wherein a significant point is a neighborhood point with a coefficient value greater than 10% of the maximum coefficient value; determine a target context index value according to a binary result of each set of significant points; determine a target probability model according to the target context index value; and encode each target high-frequency pixel in the sub-image block according to a probability table maintained by the target probability model to generate a high-frequency code stream segment; wherein in the encoding process, each probability table maintained by each target probability model is continuously updated by an exponentially weighted moving average algorithm; and the high-frequency code stream segments generated by each sub-image block are combined in the order of the positions of the sub-image blocks to form a high-frequency code stream.
[0112] In some optional embodiments, the encoding unit 630 is specifically configured to: encode each low-frequency pixel in one sub-image block of the low-frequency sub-band according to a dynamic Huffman table to generate a low-frequency code stream segment; wherein the difference coding of the dynamic Huffman table is embedded in the header of the low-frequency code stream segment; the dynamic Huffman table is updated when a statistical window threshold is reached in the encoding process; each low-frequency code stream segment generated by each sub-image block is combined in the order of the positions of the sub-image blocks to form a low-frequency code stream; and the updating process of the dynamic Huffman table includes: using an AVX-512 instruction set to parallelize the statistics of the coefficient value frequencies of each low-frequency pixel in all sub-image blocks in the current statistical window; using a sliding window exponential decay algorithm to incrementally update the coefficient value frequency distribution according to the coefficient value frequencies; using a Canonical Huffman algorithm to update the dynamic Huffman table based on the updated coefficient value frequency distribution; and performing difference coding processing on the updated dynamic Huffman table.
[0113] In some optional embodiments, the encoding unit 630 is specifically configured to: use multiple threads of a GPU to parallelize the encoding tasks of each sub-image block of the high-frequency sub-band, and store the probability tables in a shared memory; use a CPU to process the encoding tasks of the low-frequency sub-band; and use the CPU to process the merging tasks of the encoded code stream.
[0114] It should be noted that the image encoding apparatus based on dynamic block division described above can implement the image encoding method based on dynamic block division described above, and thus will not be described again.
[0115] Figure 7 FIG. 1 shows a structural schematic diagram of an electronic device according to an embodiment of the present application. Figure 7As shown, the internal structure of the electronic device can include a processor, a memory, a network interface and a database connected through a system bus. The processor of the electronic device is configured to provide computing and control capabilities. The memory of the electronic device includes a non-volatile and / or volatile storage medium, an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The network interface of the electronic device is configured to communicate with the outside through network connection. The computer program is executed by the processor to implement the functions or steps of the aforementioned dynamic block-based image encoding method.
[0116] In one embodiment, an electronic device is provided, which includes a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the following steps when executing the computer program:
[0117] An image to be encoded is obtained, and frequency domain processing is performed on the image to be encoded to determine a high frequency subband and a low frequency subband of the image to be encoded.
[0118] The image regions corresponding to the high frequency subband and the low frequency subband are respectively dynamically divided into a plurality of sub-image blocks of different sizes.
[0119] Range-ANS entropy coding technology is used to generate a high frequency code stream for each sub-image block of the high frequency subband, and adaptive Huffman entropy coding technology is used to generate a low frequency code stream for each sub-image block of the low frequency subband, and the high frequency code stream and the low frequency code stream are combined into an encoding code stream of the image to be encoded.
[0120] In one embodiment, a computer readable storage medium is also provided, which stores a computer program, and the computer program is executed by the processor to implement the functions or steps of the aforementioned dynamic block-based image encoding method.
[0121] It should be noted that the functions or steps that can be achieved by the electronic device or the computer readable storage medium described above can be referred to the related description in the foregoing method embodiment, and to avoid repetition, they will not be described here.
[0122] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when executed, can include the processes of the above-mentioned embodiment methods. Any reference to memory, storage, database or other medium used in the embodiments provided by the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0123] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of functional units and modules is exemplified, and in actual application, the above-mentioned functions can be completed by different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the above-described functions.
[0124] The above-mentioned embodiments are only used to illustrate the technical solutions of the present application, but not to limit it; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
Claims
1. An image coding method based on dynamic block segmentation, characterized in that, The method includes: Acquire the image to be encoded, perform frequency domain processing on the image to be encoded, and determine the high-frequency sub-band and low-frequency sub-band of the image to be encoded; The image regions corresponding to the high-frequency sub-band and the low-frequency sub-band are dynamically divided into multiple sub-image blocks of different sizes; A high-frequency bitstream is generated for each sub-image block of the high-frequency sub-band using Range-ANS entropy coding technology, and a low-frequency bitstream is generated for each sub-image block of the low-frequency sub-band using adaptive Huffman entropy coding technology. The high-frequency bitstream and the low-frequency bitstream are then merged into the encoded bitstream of the image to be encoded.
2. The image coding method based on dynamic block segmentation according to claim 1, characterized in that, The step of acquiring the image to be encoded, performing frequency domain processing on the image to be encoded, and determining the high-frequency sub-band and low-frequency sub-band of the image to be encoded includes: Obtain the image to be encoded; The image to be encoded is processed in the frequency domain using CDF 9 / 7 wavelet transform or LeGall 5 / 3 wavelet transform; The high-frequency sub-band and the low-frequency sub-band of the image to be encoded are determined according to predefined partitioning rules.
3. The image coding method based on dynamic block segmentation according to claim 1, characterized in that, The step of dynamically dividing the image regions corresponding to the high-frequency sub-band and the low-frequency sub-band into multiple sub-image blocks of different sizes includes: The image regions corresponding to the high-frequency sub-band and the low-frequency sub-band are respectively divided into multiple basic regions; For each of the base regions, calculate the mean gradient of the base region; The overall gradient distribution of the image to be encoded is determined based on the mean gradient values of all the base regions. Based on the overall gradient distribution of the image, determine multiple gradient ranges with different complexities; Each base region is divided into sub-regions of corresponding sizes based on the gradient range to which it belongs, wherein the higher the complexity of the gradient range to which the base region belongs, the smaller the size of the sub-region to which it is divided. Multiple sub-image blocks are determined based on the distribution of the multiple sub-regions.
4. The image coding method based on dynamic block segmentation according to claim 3, characterized in that, The step of dynamically dividing the image regions corresponding to the high-frequency sub-band and the low-frequency sub-band into multiple sub-image blocks of different sizes further includes: The GPU uses multiple threads to process the block tasks of each basic region in parallel. The block division results of the image to be encoded into multiple sub-image blocks are stored in shared memory.
5. The image coding method based on dynamic block segmentation according to claim 1, characterized in that, The generation of high-frequency code streams by using Range-ANS entropy coding technology for each sub-image block of the high-frequency sub-band includes: For each target high-frequency pixel in a sub-image block of the high-frequency sub-band, a set of salient points in a 3×3 neighborhood is determined, wherein the salient points are neighborhood points with coefficient values greater than 10% of the maximum coefficient value; The target context index value is determined based on the binary results of each set of salient points; The target probability model is determined based on each of the target context index values; High-frequency bitstream segments are generated by encoding each of the target high-frequency pixels in the sub-image block according to the probability tables maintained by each of the target probability models; wherein, during the encoding process, the probability tables maintained by each of the target probability models are continuously updated using an exponentially weighted moving average algorithm. The high-frequency code stream segments generated from each of the sub-image blocks are merged according to the positional order of the sub-image blocks to form the high-frequency code stream.
6. The image coding method based on dynamic block segmentation according to claim 1, characterized in that, The step of generating a low-frequency code stream for each sub-image block of the low-frequency sub-band using adaptive Huffman entropy coding technology includes: For each low-frequency pixel in a sub-image block of the low-frequency sub-band, a low-frequency bitstream segment is generated by encoding each low-frequency pixel in the sub-image block according to a dynamic Huffman table; wherein, the header of the low-frequency bitstream segment is embedded with the differential encoding of the dynamic Huffman table; during the encoding process, the dynamic Huffman table is updated when the statistical window threshold is reached. The low-frequency code stream segments generated from each of the sub-image blocks are merged according to the positional order of the sub-image blocks to form the low-frequency code stream; The update process of the dynamic Huffman table includes: The frequency of coefficient values of each low-frequency pixel in all sub-image blocks within the current statistical window is statistically analyzed in parallel using the AVX-512 instruction set. Based on the frequency of the coefficient values, the frequency distribution of the coefficient values is incrementally updated using a sliding window exponential decay algorithm; Based on the updated frequency distribution of the coefficient values, the dynamic Huffman table is updated using the Canonical Huffman algorithm; Differential encoding is performed on the updated dynamic Huffman table.
7. The image coding method based on dynamic block segmentation according to claim 5 or 6, characterized in that, The process of generating a high-frequency bitstream by using Range-ANS entropy coding technology for each sub-image block of the high-frequency sub-band, generating a low-frequency bitstream by using adaptive Huffman entropy coding technology for each sub-image block of the low-frequency sub-band, and merging the high-frequency bitstream and the low-frequency bitstream into the encoded bitstream of the image to be encoded includes: The encoding tasks of each sub-image block of the high-frequency sub-band are processed in parallel by multiple threads of the GPU, and the probability table is stored in shared memory. The low-frequency subband encoding task is processed by the CPU; The CPU processes the merging task of the encoded bitstream.
8. An image coding device based on dynamic block segmentation, characterized in that, The device includes: A transformation unit is used to acquire an image to be encoded, perform frequency domain processing on the image to be encoded, and determine the high-frequency sub-band and low-frequency sub-band of the image to be encoded. The segmentation unit is used to dynamically segment the image regions corresponding to the high-frequency sub-band and the low-frequency sub-band into multiple sub-image blocks of different sizes. The encoding unit is used to generate a high-frequency bitstream for each sub-image block of the high-frequency sub-band using Range-ANS entropy coding technology, generate a low-frequency bitstream for each sub-image block of the low-frequency sub-band using adaptive Huffman entropy coding technology, and merge the high-frequency bitstream and the low-frequency bitstream into an encoded bitstream of the image to be encoded.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the image coding method based on dynamic block division as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is instructed by the processor, it implements the steps of the image coding method based on dynamic block division as described in any one of claims 1 to 7.