Image one-dimensional coding method and readable storage medium

By using the reconstruction value of the pixel on the left side of the pixel to be encoded for prediction and correction, the problem that conventional image compression algorithms require cache multi-line pixel data is solved, achieving more efficient image compression and reducing the area requirement of hardware implementation.

CN119728972AActive Publication Date: 2025-03-28SHANGHAI FULLHAN MICROELECTRONICS
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411922488.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-25
Publication Date
2025-03-28
Estimated Expiration
2044-12-25

AI Technical Summary

Technical Problem

Conventional image compression algorithms require cache several rows of pixel data, resulting in a large area of ​​compression algorithms that implement hardware.

Method used

The initial predicted value is predicted by using the reconstruction value of the pixel located to the left of the pixel to be encoded and corrected by left-side gradient and context modeling, and the predicted residual value is finally quantized and encoded.

Benefits of technology

Reliance on row pixel data is reduced, area requirements for hardware implementation is reduced, and efficiency of image compression algorithm is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119728972A_ABST
    Figure CN119728972A_ABST
Patent Text Reader

Abstract

The invention relates to an image one-dimensional coding method and a readable storage medium. The method comprises the steps that a reconstruction value of a pixel located on the left side of a to-be-coded pixel is used for prediction to obtain a preliminary prediction value of the to-be-coded pixel; calculating a left gradient by using the reconstruction values of a plurality of adjacent pixel points on the left side of the to-be-coded pixel, carrying out quantization, and carrying out context modeling; correcting the preliminary predicted value based on a context modeling table item to obtain a corrected predicted value; calculating a prediction residual value by using the real pixel value of the pixel to be coded and the corrected prediction value; quantizing the predicted residual value; mapping the quantized prediction residual value to obtain a mapping residual value; estimating the bit width of the mapping residual value; coding the to-be-coded pixel based on the bit width, and updating a context modeling table item; and repeating the steps until the whole image is coded. The method solves the problem that a conventional image compression algorithm needs to cache a plurality of rows of pixel data, so that the area of a hardware implementation compression algorithm is large.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image compression, and in particular to a one-dimensional image encoding method and a readable storage medium. Background Art

[0002] Image compression is a key technology in the embedded field. A good image compression algorithm can significantly reduce the size of the compressed file while ensuring image quality. Common compression algorithms are divided into two categories. One is to compress by using the correlation of adjacent points in the spatial domain, and the other is to convert to the frequency domain and use the redundancy in the frequency domain and the insensitivity of the human eye to high-frequency information for compression. The current common compression methods, whether based on spatial prediction compression or frequency domain compression, require caching at least one line of data information, which is a considerable expense for embedded devices. Summary of the invention

[0003] The purpose of the present invention is to provide a one-dimensional image encoding method and a readable storage medium, aiming to solve the problem that conventional image compression algorithms need to cache several rows of pixel data, resulting in a large area for hardware implementation of the compression algorithm.

[0004] To achieve the above object, the present invention provides a one-dimensional image encoding method, comprising:

[0005] Using the reconstructed value of the pixel located to the left of the pixel to be encoded to predict a preliminary predicted value of the pixel to be encoded;

[0006] Calculate the left gradient using the reconstructed values ​​of a plurality of adjacent pixels located on the left side of the pixel to be encoded and perform quantization, and use the quantized left gradient to perform context modeling;

[0007] Modifying the preliminary prediction value based on the table item of the context modeling to obtain a modified prediction value;

[0008] Calculating a prediction residual value using the real pixel value of the pixel to be encoded and the corrected prediction value;

[0009] quantifying the prediction residual value;

[0010] Mapping the quantized prediction residual value to obtain a mapped residual value;

[0011] estimating a bit width of the mapped residual value;

[0012] Encoding the to-be-encoded pixel based on the bit width, and updating the table entry of the context modeling;

[0013] Repeat the above steps until the entire image is encoded.

[0014] Optionally, when the pixel to be encoded has multiple channels, the channel value of the pixel to be encoded is predicted using the reconstructed value of the pixel located on the left side of the channel corresponding to the pixel to be encoded.

[0015] Optionally, assuming that the coordinates of the pixel to be encoded are (i, j), then:

[0016] P(i,j)=R(i,j-1)

[0017] Wherein, R(i,j-1) is the reconstructed value of the pixel located to the left of the pixel to be encoded, and P(i,j) is the preliminary predicted value of the pixel to be encoded.

[0018] Optionally, the left gradient is calculated using the reconstructed values ​​of three adjacent pixels located on the left side of the pixel to be encoded.

[0019] Optionally, if the number of adjacent pixels located on the left side of the pixel to be encoded is less than 3, the missing pixels are padded with a reconstruction value of 0 for calculation.

[0020] Optionally, when the left gradient is calculated and quantized using the reconstructed values ​​of multiple adjacent pixels located on the left side of the pixel to be encoded, the quantization thresholds are defined as T1, T2, T3 and NEAR, and the calculation formula is as follows:

[0021] D1=R(i,j-1)-R(i,j-2)

[0022] D2=R(i,j-3)-R(i,j-2)

[0023]

[0024] In the formula, the value of m is 1 or 2.

[0025] Optionally, when performing the context modeling, symmetric contexts are merged based on the symmetry of the contexts, and the formula is as follows:

[0026]

[0027] Qm=Qm*SIGN,m=1,2

[0028] Q=(Q1*9+Q2)

[0029] Where SIGN is used to determine whether the context symbol has been changed so that it can be accurately reconstructed during decoding.

[0030] Optionally, encode using the Golomb encoding algorithm.

[0031] Optionally, the one-dimensional image encoding method further includes:

[0032] The quantized prediction residual value is dequantized and calculated with the modified prediction value to obtain the reconstructed value of the pixel to be encoded.

[0033] Based on the same technical concept, the present invention also provides a readable storage medium on which a computer program is stored. When the computer program is executed, the one-dimensional image encoding method as described above can be implemented.

[0034] In a one-dimensional image encoding method and a readable storage medium provided by the present invention, the current pixel value is predicted only by using the reconstructed value of the pixel to the left of the same row of the pixel to be encoded, which can solve the problem that the conventional image compression algorithm needs to cache several rows of pixel data, resulting in a large area for hardware implementation of the compression algorithm. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Those skilled in the art will appreciate that the accompanying drawings are provided for a better understanding of the present invention and do not constitute any limitation on the scope of the present invention.

[0036] Figure 1 The present invention provides a flowchart of a one-dimensional image encoding method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0037] In order to make the purpose, advantages and features of the present invention clearer, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the accompanying drawings are in a very simplified form and use non-precise proportions, which are only used to conveniently and clearly assist in explaining the purpose of the embodiments of the present invention. In order to make the purpose, features and advantages of the present invention more obvious and easy to understand, please refer to the accompanying drawings. It should be noted that the structure, proportion, size, etc. illustrated in the drawings of this specification are only used to match the content disclosed in the specification for people familiar with this technology to understand and read, and are not used to limit the limiting conditions for the implementation of the present invention. Any modification of the structure, change in the proportional relationship or adjustment of the size, under the same or similar conditions as the effects that can be produced by the present invention and the purposes that can be achieved, should still fall within the scope of the technical content disclosed by the present invention.

[0038] As used in the present invention, the singular forms "a", "an", and "the" include plural referents unless the context clearly indicates otherwise. As used in the present invention, the term "or" is generally used in a sense that includes "and / or", unless the context clearly indicates otherwise. As used in the present invention, the term "several" is generally used in a sense that includes "at least one", unless the context clearly indicates otherwise. As used in the present invention, the term "at least two" is generally used in a sense that includes "two or more", unless the context clearly indicates otherwise.

[0039] Please refer to Figure 1 The embodiment of the present invention provides a one-dimensional image encoding method, comprising the following steps:

[0040] S1. Predicting a preliminary predicted value of the pixel to be encoded by using a reconstructed value of a pixel located to the left of the pixel to be encoded;

[0041] S2, using the reconstructed values ​​of a plurality of adjacent pixels located on the left side of the pixel to be encoded to calculate the left gradient and quantize it, and using the quantized left gradient to perform context modeling;

[0042] S3, based on the table item of the context modeling, correcting the preliminary prediction value to obtain a corrected prediction value;

[0043] S4, calculating a prediction residual value using the real pixel value of the pixel to be encoded and the corrected prediction value;

[0044] S5, quantifying the prediction residual value;

[0045] S6, mapping the quantized prediction residual value to obtain a mapped residual value;

[0046] S7, estimating the bit width of the mapping residual value;

[0047] S8. Encode based on the bit width and update the table entry of the context modeling;

[0048] S9. Repeat the above steps until the entire image is encoded.

[0049] The one-dimensional image encoding method provided in this embodiment predicts the current pixel value by only using the reconstructed value of the pixel to the left of the same row of the pixel to be encoded, which can solve the problem that the conventional image compression algorithm needs to cache several rows of pixel data, resulting in a large area for hardware implementation of the compression algorithm.

[0050] First, execute S1, and use the reconstructed value of the pixel located on the left side of the pixel to be encoded to predict the preliminary predicted value of the pixel to be encoded. It should be noted that the entire image can be a single-channel image or a multi-channel image, such as an RGB three-channel image. Therefore, when using the reconstructed value of the pixel located on the left side of the pixel to be encoded to predict the value of the pixel to be encoded, if the pixel to be encoded has multiple channels, it is necessary to use the reconstructed value of the pixel located on the left side of the channel corresponding to the pixel to be encoded to predict the channel value of the pixel to be encoded. For ease of understanding, the technical concept of the present invention will be explained below using the encoding process of a single-channel image, and the encoding of a multi-channel image is the same.

[0051] Specifically, assuming that the coordinates of the pixel to be encoded are (i, j), then:

[0052] P(i,j)=R(i,j-1)

[0053] Wherein, i is the row coordinate, j is the column coordinate, R(i,j-1) is the reconstructed value of the pixel located to the left of the pixel to be encoded, and P(i,j) is the preliminary predicted value of the pixel to be encoded.

[0054] Then, S2 is executed to calculate the left gradient using the reconstructed values ​​of multiple adjacent pixels on the left side of the pixel to be encoded and quantize it, and use the quantized left gradient to perform context modeling. In this embodiment, the left gradient is calculated and quantized using the reconstructed values ​​of three adjacent pixels on the left side of the pixel to be encoded, and the quantization thresholds are defined as T1, T2, T3 and NEAR, and the calculation formula is as follows:

[0055] D1=R(i,j-1)-R(i,j-2)

[0056] D2=R(i,j-3)-R(i,j-2)

[0057]

[0058] In the formula, the value of m is 1 or 2.

[0059] In this embodiment, if the number of adjacent pixels located on the left side of the pixel to be encoded is less than 3, the missing pixels are supplemented and calculated with a reconstruction value of 0. For example, if the number of adjacent pixels located on the left side of the pixel to be encoded is one, the reconstruction values ​​of the remaining two pixels are 0 and substituted into the above formula for calculation.

[0060] In this embodiment, the quantized left gradient is used for context modeling, that is, the context index Q is calculated using Q1\Q2. Considering the symmetry of the context, the symmetric context can be merged, that is, if Q1 is a negative number, the Q1\Q2 elements are inverted, and if Q1 is 0 and Q2 is a negative number, Q2 is inverted.

[0061] Preferably, when performing the context modeling, symmetric contexts are merged based on the symmetry of the contexts, and the formula is as follows:

[0062]

[0063] Qm=Qm*SIGN,m=1,2

[0064] Q=(Q1*9+Q2)

[0065] Where SIGN is used to determine whether the context symbol has been changed so that it can be accurately reconstructed during decoding.

[0066] Then, S3 is executed to correct the preliminary prediction value based on the table item of the context modeling to obtain a corrected prediction value.

[0067] In this embodiment, before the correction is performed, the table items A\B\C\N need to be initialized first, and the initialization formula is as follows:

[0068]

[0069] B[Q]=0

[0070] C[Q]=0

[0071] N[Q]=1

[0072] In the formula, table item A[Q] represents the accumulated prediction residual values ​​after all quantization; N[Q] is a counter to record the number of such residuals; B[Q] accumulates all the corrected prediction residual values; C[Q] is the correction variable, RANGE is the range of quantized residuals, and the calculation formula is as follows:

[0073]

[0074] Where MAXVAL is the possible maximum value of the image pixel, and NEAR is a quantization parameter whose value range is greater than or equal to zero.

[0075] In this embodiment, the predicted value is corrected using C[Q] of table entry C. Assuming that the initial predicted value is P, the adaptive corrected value is P fix , the calculation formula is as follows:

[0076]

[0077] P fix =Clip(P fix ,0,MaxVal)

[0078] Then, S4 is executed, using the real pixel value Ix and the modified prediction value Px of the pixel to be encoded. fix Calculate the prediction residual value Errval, the calculation formula is as follows:

[0079] Errval=Ix-Px fix

[0080]

[0081] Then, S5 is executed to quantize the prediction residual using the preset quantization parameter NEAR. The calculation formula is as follows:

[0082]

[0083] In this embodiment, the one-dimensional image encoding method further includes:

[0084] The quantized prediction residual value is dequantized and calculated with the modified prediction value to obtain the reconstructed value of the pixel to be encoded. Specifically, the quantized residual qErrval, the quantization parameter NEAR, the modified prediction value P fix The reconstruction value R of the pixel to be encoded is calculated with the positive and negative prediction flag SIGN to prepare for the subsequent encoding of other pixels. The calculation formula is as follows:

[0085] R=Px fix +SIGN*qErrval*(2*NEAR+1)

[0086] R=Clip(R,0,MaxVal)

[0087] Before executing S6, it should be noted that the coding algorithm used in the present invention is the Golomb-Rice coding algorithm, so it is necessary to estimate the bit width k of the coded number (i.e., the optimal index of the Golomb coding), and the estimation method is as follows:

[0088] for(k=0;(N[Q]<<k) <A[Q];k++)

[0089] Because Golomb coding is optimal for non-negative numbers, the quantized prediction residual value must be mapped to a non-negative number MErrval in the range of [0, RANGE-1].

[0090] First, the quantized prediction residual value is normalized as follows:

[0091]

[0092] Then, the quantized prediction residual value is mapped according to NEAR\k\B[Q]\N[Q] to obtain a mapping residual value, as shown in the following formula:

[0093]

[0094] Then, the bit width k of the mapping residual value is estimated, and then the pixel to be encoded is encoded based on the bit width. The specific encoding steps are as follows:

[0095] 1) Calculate interim, interim = MErrval>>k;

[0096] 2) Determine the size of interim and (LIMIT-qbpp-1). If interim < (LIMIT-qbpp-1), jump to 3), otherwise jump to 4);

[0097] 3) Take the lowest K bits b of MErrval k, which is finally encoded as interim 0s, 1 1, and the binary representation of b k ;

[0098] 4) Take the lowest qbpp bit b of (MErrval-1) qbpp , the final encoding is LIMIT-qbpp-1 0, 1 1, and the binary representation of b qbpp .

[0099] Where qbpp is the bit width of the quantized residual, and the calculation formula is as follows:

[0100] qbpp = ceil(log2RANGE)

[0101] LIMIT is a value related to the image pixel width (bpp), and the calculation formula is as follows:

[0102] LIMIT=2*(bpp+max(8,bpp))

[0103] After the encoding is completed, the table entries A[Q] / B[Q] / C[Q] / N[Q] are finally updated.

[0104] First, use the normalized residual value to preliminarily update A[Q] and B[Q], the formula is as follows:

[0105] A[Q]=A[Q]+abs(qErrvalM)

[0106] B[Q]=B[Q]+qErrvalM*(2*NEAR+1)

[0107] Then determine whether the number of occurrences of the context N[Q] reaches RESET times, where RESET is a preset constant value. If it reaches RESET, further reduce A[Q]\B[Q]\N[Q], as shown in the following formula:

[0108]

[0109]

[0110] Then update the number of context occurrences N[Q], and add 1 to the counter. The formula is as follows:

[0111] N[Q]=N[Q]+1

[0112] Then update C[Q], the formula is as follows:

[0113]

[0114] Finally, update B[Q] and limit the value of B[Q] to [-N[Q]+1,0], the formula is as follows:

[0115]

[0116] Repeat the above steps S1-S8 until the entire image is encoded.

[0117] Based on the same inventive concept, an embodiment of the present invention further provides a readable storage medium on which a computer program is stored. When the computer program is executed, the one-dimensional image encoding method described above can be implemented.

[0118] The readable storage medium can be a tangible device that can keep and store the instructions used by the instruction execution device, such as but not limited to an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device or any suitable combination thereof. The more specific example (non-exhaustive list) of the readable storage medium includes: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a convex structure in a groove on which instructions are stored, and any suitable combination thereof. The computer program described herein can be downloaded from the readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network and / or a wireless network. The network can include copper transmission cables, optical fiber transmission, wireless transmission, routers, firewalls, switches, gateway computers and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer program from the network and forwards the computer program for storage in the readable storage medium in each computing / processing device. The computer program for performing the operation of the present invention can be a run instruction, an instruction set architecture (ISA) instruction, a machine instruction, a machine-related instruction, a microcode, a firmware instruction, a state setting data, or a source code or object code written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Smalltalk, C++, etc., and conventional procedural programming languages ​​such as "C" language or similar programming languages. The computer program can be executed completely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, using an Internet service provider to connect through the Internet). In some embodiments, by utilizing the state information of a computer program to personalize an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), the electronic circuit can execute computer-readable program instructions to implement various aspects of the present invention.

[0119] Here, various aspects of the present invention are described with reference to the flowchart and / or block diagram of the method, system and computer program product according to the embodiment of the present invention. It should be understood that each square frame of the flowchart and / or block diagram and the combination of the square frames in the flowchart and / or block diagram can be realized by a computer program. These computer programs can be provided to the processor of a general-purpose computer, a special-purpose computer or other programmable data processing device, so as to produce a machine, so that these programs, when executed by the processor of a computer or other programmable data processing device, produce a device for realizing the function / action specified in one or more square frames in the flowchart and / or block diagram. These computer programs can also be stored in a readable storage medium, and these computer programs make the computer, programmable data processing device and / or other equipment work in a specific way, so that the readable storage medium storing the computer program includes a manufactured product, which includes instructions for realizing various aspects of the function / action specified in one or more square frames in the flowchart and / or block diagram.

[0120] The computer program may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operational steps are executed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the computer program executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0121] In summary, the embodiments of the present invention provide a one-dimensional image encoding method and a readable storage medium, which predicts the current pixel value only by using the reconstructed value of the pixel to the left of the same row of the pixel to be encoded, thereby solving the problem that the conventional image compression algorithm needs to cache several rows of pixel data, resulting in a large area for hardware implementation of the compression algorithm.

[0122] The above description is only a description of the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any changes and modifications made by a person skilled in the art in the field of the present invention based on the above disclosure are within the scope of protection of the present invention. Obviously, a person skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations fall within the scope of the present invention and its equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A one-dimensional image encoding method, characterized in that: include: Using the reconstructed value of the pixel located to the left of the pixel to be encoded to predict a preliminary predicted value of the pixel to be encoded; Calculate the left gradient using the reconstructed values ​​of a plurality of adjacent pixels located on the left side of the pixel to be encoded and perform quantization, and use the quantized left gradient to perform context modeling; Modifying the preliminary prediction value based on the table item of the context modeling to obtain a modified prediction value; Calculating a prediction residual value using the real pixel value of the pixel to be encoded and the corrected prediction value; quantifying the prediction residual value; Mapping the quantized prediction residual value to obtain a mapped residual value; estimating a bit width of the mapped residual value; Encoding the to-be-encoded pixel based on the bit width, and updating the table entry of the context modeling; Repeat the above steps until the entire image is encoded.

2. The one-dimensional image encoding method according to claim 1, characterized in that: When the pixel to be encoded has multiple channels, the channel value of the pixel to be encoded is predicted using the reconstructed value of the pixel located on the left side of the channel corresponding to the pixel to be encoded.

3. The one-dimensional image encoding method according to claim 1, characterized in that: Assuming the coordinates of the pixel to be encoded are (i, j), then: P(i,j)=R(i,j-1) Wherein, R(i,j-1) is the reconstructed value of the pixel located to the left of the pixel to be encoded, and P(i,j) is the preliminary predicted value of the pixel to be encoded.

4. The one-dimensional image encoding method according to claim 3, characterized in that: The left gradient is calculated using the reconstructed values ​​of the three adjacent pixels to the left of the pixel to be encoded.

5. The one-dimensional image encoding method according to claim 4, characterized in that: If the number of adjacent pixels to the left of the pixel to be encoded is less than 3, the missing pixels are filled in with a reconstruction value of 0.

6. The one-dimensional image encoding method according to claim 4 or 5, characterized in that: When the left gradient is calculated and quantized using the reconstructed values ​​of multiple adjacent pixels located on the left side of the pixel to be encoded, the quantization thresholds are defined as T1, T2, T3 and NEAR, and the calculation formula is as follows: D1=R(i,j-1)-R(i,j-2) D2=R(i,j-3)-R(i,j-2) In the formula, the value of m is 1 or 2.

7. The one-dimensional image encoding method according to claim 6, characterized in that: When performing the context modeling, the symmetric contexts are merged based on the symmetry of the contexts, and the formula is as follows: Qm=Qm*SIGN,m=1,2 Q=(Q1*9+Q2) Where SIGN is used to determine whether the context symbol has been changed so that it can be accurately reconstructed during decoding.

8. The one-dimensional image encoding method according to claim 1, characterized in that: Encode using the Golomb coding algorithm.

9. The one-dimensional image encoding method according to claim 1, characterized in that: The one-dimensional image encoding method also includes: The quantized prediction residual value is dequantized and calculated with the modified prediction value to obtain the reconstructed value of the pixel to be encoded.

10. A readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed, the one-dimensional image encoding method according to any one of claims 1 to 9 can be implemented.

Citation Information

Patent Citations

  • Video information compression calculation method

    CN101237573A

  • Image decoding method, encoding method and device

    CN116389755A

  • Implementation method of JPEG-LS encoder based on FPGA

    CN116828196A

  • Image processing method and device, electronic equipment and storage medium

    CN119172545A

  • System and method for lossless image compression having improved sequential determination of golomb parameter

    US5764374A