CN117651150A - Improved QOI image coding strategy - Google Patents

Improved QOI image coding strategy Download PDF

Info

Publication number
CN117651150A
CN117651150A CN202311692284.0A CN202311692284A CN117651150A CN 117651150 A CN117651150 A CN 117651150A CN 202311692284 A CN202311692284 A CN 202311692284A CN 117651150 A CN117651150 A CN 117651150A
Authority
CN
China
Prior art keywords
qoi
coding
encoding
pixel
strategy
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311692284.0A
Other languages
Chinese (zh)
Inventor
李辉
吴恒初
陈家耀
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
University of Electronic Science and Technology of China
Original Assignee
University of Electronic Science and Technology of China
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by University of Electronic Science and Technology of China filed Critical University of Electronic Science and Technology of China
Priority to CN202311692284.0A priority Critical patent/CN117651150A/en
Publication of CN117651150A publication Critical patent/CN117651150A/en
Pending legal-status Critical Current

Links

Landscapes

  • Compression Of Band Width Or Redundancy In Fax (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)

Abstract

The invention discloses an improved QOI image coding strategy, which is improved based on an original QOI coding strategy and aims at RGB888 image coding. The improved coding strategy comprises 7 coding modes: run-length encoding, index encoding, 4 differential encoding, and pixel value encoding. A prediction model is introduced in the differential coding mode, and a predicted value of a current coding pixel is used for replacing a previous pixel to serve as a differential object, so that the difference value is further reduced, and the coding performance is improved. The data set containing 514 images is subjected to coding test, and compared with the original QOI coding strategy, the improved QOI coding strategy has an improvement of 10.0% in compression rate.

Description

Improved QOI image coding strategy
Technical Field
The invention relates to the technical field of lossless coding of images, in particular to an improved QOI image coding strategy.
Background
Image coding is a key technology in the field of digital image processing, and aims to reduce storage and transmission costs of images by removing redundant information in the images and reducing data volume on the premise of ensuring the image quality as much as possible.
Image coding can be classified into lossless coding and lossy coding according to whether original data is lost after decoding, and an improved QOI image coding strategy related to the present invention belongs to lossless coding, and in the past decades, a number of image lossless coding algorithms such as JPEG-LS, PNG, etc. have been developed. The core of these mainstream lossless Coding algorithms is entropy Coding, such as Golomb Coding (Golomb Coding) in JPEG-LS, huffman Coding (Huffman Coding) in PNG. 2022, QOI (Quite OK Image), a simple but compression rate comparable PNG algorithm was proposed, QOI coding strategy fused the characteristics of run-length coding, dictionary coding and differential coding, with the characteristics of fast encoding and decoding speed and byte alignment of encoded data.
The invention improves the original QOI coding strategy and further improves the coding performance.
Disclosure of Invention
The invention improves the original QOI coding strategy, and the improvement mainly comprises adding 2 coding modes and introducing a prediction model. The modified QOI image coding strategy contains a total of 7 coding modes, one pixel at a time, with each of QOI _run, qoi_index, qoi_diff1, QOI _diff2, QOI _luma, qoi_diff3, and QOI _rgb being prioritized.
QOI _run is similar to RUN-length coding, which codes the number of repetitions of a pixel.
QOI _INDEX has the property of dictionary coding, coding the INDEX address of a pixel.
QOI _diff1, QOI _diff2, QOI _luma and QOI _diff3 belong to differential encoding, which encodes the difference between the current pixel and the current pixel prediction value, and these 4 differential encodings are applicable to different difference ranges, the higher the priority, the smaller the range of difference that can be encoded, and the fewer bytes the encoding consumes.
QOI-RGB direct-coded pixel values are only used if none of the previous 6 coding modes are compatible. The QOI RGB coding scheme will have the effect of anti-compression.
The prediction model is from JPEG-LS algorithm, the predicted value of the current pixel is calculated by the size relation of the adjacent 3 pixels, and the difference value can be reduced by using the prediction model, so that the coding performance is improved.
Drawings
FIG. 1 is a QOI _RUN encoding format in an original QOI encoding strategy;
FIG. 2 is a QOI _INDEX encoding format in the original QOI encoding strategy;
FIG. 3 is a QOI _DIFF encoding format in the original QOI encoding strategy;
fig. 4 is a QOI _luma encoding format in the original QOI encoding strategy;
FIG. 5 is a QOI _RGB encoding format in the original QOI encoding strategy;
FIG. 6 is a QOI _RUN encoding format in a modified QOI encoding strategy;
FIG. 7 is a QOI _INDEX encoding format in a modified QOI encoding strategy;
FIG. 8 is a QOI _DIFF2 encoding format in a modified QOI encoding strategy;
FIG. 9 is a QOI _DIFF3 encoding format in a modified QOI encoding strategy;
FIG. 10 is a JPEG-LS predictive model in accordance with the present invention;
FIG. 11 is an example image developed pixel arrangement showing only the first 6 pixels;
FIG. 12 is a graph illustrating predicted values for each pixel in an example image, showing predicted values for only the first 6 pixels;
fig. 13 is a code stream of an example image encoded using a modified QOI encoding strategy.
Detailed Description
To further clarify the technical solution and advantages of the present invention, a more detailed description of the invention will be rendered by reference to the appended drawings and a simple image coding example.
The image coding strategy provided by the invention is improved on the basis of the original QOI coding strategy, and the original QOI coding strategy is as follows:
for images in the RGB888 format, the images are encoded row by row in a left to right, top to bottom order. When the first pixel is coded, the { r:0, g:0, b:0} is used as the last pixel value, and when all the pixels of one image are coded, the coding of the whole image is finished.
There are 5 ways of pixel coding, QOI _run, qoi_index, qoi_diff, qoi_luma and QOI _rgb in order of priority from high to low. When a pixel is encoded, different encoding modes are tried in sequence according to the priority of the encoding modes, and if a certain encoding mode can encode the pixel, a corresponding encoding word block is output, so that the encoding of the pixel is completed; if the pixel cannot be encoded, the next encoding mode is attempted until the encoding of the pixel is completed. The following describes the 5 coding modes one by one according to coding priority:
QOI _RUN: as shown in fig. 1, an 8-bit binary number is composed of a two-bit identifier 11 and a 6-bit run length (run). The run length is used to encode the number of consecutive repetitions of the last pixel minus 1, and the maximum value of the run length is specified to be 62, i.e. the 6-bit binary number 111110, representing 63 consecutive repetitions, such that the maximum value of the run length is specified so as not to collide with the identifier of the QOI _rgb encoding scheme, avoiding decoding errors.
QOI _INDEX: as shown in fig. 2, an 8-bit binary number, which is composed of a two-bit identifier 00 and a 6-bit index address, is required to construct an index table of depth 64 for storing the encoded pixel values (initial values are all 0) when QOI is encoded. For each encoded pixel, calculating an index address (index_pos) by the formula (1-1), and storing the pixel value of the pixel into the position corresponding to the index address in the index table; as encoding proceeds, the pixel values stored in the index table are updated continuously. The update rule is as follows: accessing an INDEX table according to the INDEX address obtained by calculating the current coding pixel, and outputting a QOI _INDEX coding word block if the INDEX value is equal to the current coding pixel; otherwise, the current pixel is not accordant with the QOI _INDEX coding mode, the current pixel value is stored into an INDEX table according to an INDEX address, the INDEX table is updated, and then subsequent differential coding (QOI _DIFF) is tried.
index_pos=(r×3+g×5+b×7)%32 (1-1)
QOI _diff: as shown in FIG. 3, an 8-bit binary number is composed of two-bit identifiers 01 and pixel differences of 3 channels, vr, vg and vb are respectively the differences of the current coded pixel and the last pixel of 3 channels (red, green, blue), and are respectively represented by 2-bit binary complements, wherein the coded differences range is-2 < vr, vg and vb < 1.
QOI _luma: as shown in fig. 4, a 2-byte, 16-bit binary number, consisting of a two-bit identifier 10 and a 3-channel difference, can represent a larger range of variation than in the QOI _diff coding, QOI _luma coding, and a quadratic difference is used, where vr_g=vr-vg, vb_g=vb-vg, with corresponding ranges of difference of-8 r_g, vr_b 7, and-32 g 31.
QOI _RGB: as shown in fig. 5, a 4 byte, 32 bit binary number, consisting of an 8 bit identifier 11111111 and pixel values of 3 channels, encodes RGB pixel values directly when none of the previous 4 encoding modes are coincident, which would have the effect of anti-compression.
Considering the back compression effect brought by QOI _RGB coding mode, two new differential coding modes, QOI _DIFF2 and QOI _DIFF3, are added in the improved QOI image coding strategy provided by the invention, so as to adapt to a larger difference range, reduce the occurrence probability of QOI _RGB coding as much as possible, and improve the coding performance.
The core of the QOI coding strategy is to code the difference value, except for the QOI _run and QOI _index coding modes. The improved QOI image coding strategy provided by the invention introduces a prediction model, and replaces the last pixel with the predicted value of the current coding pixel as a differential object, so that the difference value can be effectively reduced, and the coding performance is further improved.
The improved coding modes are in total 7, namely QOI _RUN, QOI_INDEX, QOI_DIFF1, QOI _DIFF2, QOI _LUMA, QOI_DIFF3 and QOI _RGB according to coding priority.
QOI _RUN: as shown in fig. 6, the identifier becomes 111 and the run length (run) becomes 5 bits compared to the original QOI encoding strategy, which corresponds to a maximum run length of 30, i.e., a 5 bit binary number 11110.
QOI _INDEX: as shown in fig. 7, the identifier becomes 000 and the index address becomes 5 bits compared to the original QOI encoding strategy, which means that the depth of the index table is reduced by half, becomes 32, and other characteristics remain unchanged.
QOI _diff1: as in QOI encoding strategy QOI _diff.
QOI _diff2: as shown in FIG. 8, a 2 byte, 16 bit binary number, consisting of a 3 bit identifier 001 and a 3 channel difference, is encoded with a difference range of-8 v r, vb 7 and-16 v g 15.
QOI _luma: as in QOI encoding strategy QOI _luma.
QOI _diff3: as shown in FIG. 9, a 3 byte, 24 bit binary number, is composed of a 3 bit identifier 110 and a 3 channel difference value, the encoded difference value ranges from-64 to vr, vg, vb to 63.
QOI _RGB: as in QOI encoding strategy QOI _rgb.
The predicted value of the current coding pixel is calculated by adopting a predicted model in JPEG-LS, the predicted model is shown in fig. 10, the predicted value of the X position is determined according to the values of surrounding pixels, when the pixel A, B, C does not exist, namely X is positioned at the upper left corner of the image, at the moment, the first pixel of the image is being coded, and the predicted value X is {0, 0}; when the pixel B, C is not present, X is located in the first line of the image, and the predicted value X is the value of the pixel A; when A, C is absent, X is in the first column of the image and the predicted value X is the value of pixel B. For the general case, if C is equal to or greater than the maximum value in A, B, the predicted value X takes the minimum value in A, B; if C is smaller than or equal to the minimum value in A, B, the predicted value X takes the maximum value in A, B; if neither of the first two conditions is met, the predicted value X is equal to A+B-C.
Taking the example of encoding a 3 x 3 size image, all pixels are spread out in a row in left to right, top to bottom order, as shown in fig. 11, with only the first 6 pixels shown in fig. 11.
The predicted value calculated using the prediction model according to the position of the pixel is shown in fig. 12.
Each pixel is coded in turn according to the modified QOI coding strategy: it is apparent that it is not equal to the previous pixel { r:0, g:0, b:0}, so QOI _run coding is not suitable; then, accessing an INDEX table according to the INDEX address calculated by the formula (1-1), and finding that the INDEX values { r:0, g:0, b:0} are not equal to the current pixel, and explaining that the INDEX values are not consistent with the QOI _INDEX coding mode; next, it is examined whether the differential encoding is met, the first pixel should have a prediction value { r:0, g:0, b:0} according to the prediction rule. The calculated difference is not within the QOI _diff1 representation range, but corresponds to QOI _diff2 coding, so encoding according to QOI _diff2 coding results in 0010110000110110.
Next, the 2 nd pixel is also determined step by step according to the above procedure, and the 01011100 is obtained by encoding in accordance with QOI _diff1 encoding mode.
Then, the 3 rd pixel is verified by calculation, and none of the previous 6 coding modes accords, so that only QOI _rgb coding modes, namely direct coding of RGB pixel values, need 4 bytes, namely: 11111111010011111000011111011101.
since the 4 th and 5 th pixels are equal to the previous pixel, 11100001 is obtained by encoding in QOI _run encoding mode.
For the 6 th pixel, obviously not equal to the previous pixel, then the INDEX address is calculated to be 13, and the INDEX value obtained by using the address to access the INDEX table is { r:4, g:11, b:6}, which is equal to the current pixel, so QOI _INDEX is output, namely: 00001101. the resulting code stream is shown in fig. 13.
Referring to an image test set of an original QOI coding strategy, removing ARGB images unsuitable for the algorithm, wherein the total number of RGB images participating in the test is 514, and the RGB images comprise various types of textures, game screenshot, scenery, figures, animals and the like, and the final test result is as follows: the average compression rate was 0.389 using the original QOI coding strategy and 0.350 using the improved QOI coding strategy proposed by the present invention.
As can be seen from comparison, the compression ratio of the improved QOI algorithm is improved by 10.0% compared with the original QOI.

Claims (4)

1. An improved QOI image coding strategy, characterized by: compared with the original QOI coding strategy, the improved content mainly comprises the introduction of a prediction model and the addition of 2 differential coding modes, wherein the prediction model is from a JPEG-LS algorithm, and the aim is to reduce the difference value in the difference value coding so as to obtain a better coding effect; the newly added 2 differential encoding modes are QOI _diff2 and QOI _diff3, and the improved QOI image encoding strategy has better compression performance compared with the original QOI encoding strategy.
2. The predictive model of claim 1, wherein: the predicted value of the pixel is calculated according to the size relation of the surrounding adjacent 3 pixels.
3. The QOI _diff2 encoding scheme of claim 1, wherein: encoding differences between the current pixels of the 3 channels and the current pixel predicted values; the encoding uses 2 bytes in total, the identifier is 001, the difference range of the g channel is [ -16,15], 5 bits are occupied, the difference range of the R, B channel is [ -8,7], 4 bits are occupied each.
4. The QOI _diff3 encoding method of claim 1, wherein: encoding differences between the current pixels of the 3 channels and the current pixel predicted values; the code uses 3 bytes in total, the identifier is 110, the difference range of R and G, B channels is [ -64,63], and each occupies 7 bits.
CN202311692284.0A 2023-12-11 2023-12-11 Improved QOI image coding strategy Pending CN117651150A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311692284.0A CN117651150A (en) 2023-12-11 2023-12-11 Improved QOI image coding strategy

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311692284.0A CN117651150A (en) 2023-12-11 2023-12-11 Improved QOI image coding strategy

Publications (1)

Publication Number Publication Date
CN117651150A true CN117651150A (en) 2024-03-05

Family

ID=90043159

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311692284.0A Pending CN117651150A (en) 2023-12-11 2023-12-11 Improved QOI image coding strategy

Country Status (1)

Country Link
CN (1) CN117651150A (en)

Similar Documents

Publication Publication Date Title
US11140401B2 (en) Coded-block-flag coding and derivation
US7751630B2 (en) Multi-mode image processing
US6639945B2 (en) Method and apparatus for implementing motion detection in video compression
CN113542740B (en) Image transmission method and device
US20220222861A1 (en) Method, device, and storage medium for data encoding/decoding
US9807402B2 (en) Method of color palette coding applicable to electronic device and electronic device using the same
CN116723337B (en) HDMI high definition data optimized transmission method and system
CN115173866A (en) Efficient storage method of applet data
JPH11161782A (en) Method and device for encoding color picture, and method and device for decoding color picture
US5151949A (en) System and method employing multiple predictor sets to compress image data having different portions
CN107105208A (en) A kind of lossless coding and coding/decoding method of Bayer images
US6584226B1 (en) Method and apparatus for implementing motion estimation in video compression
US20220005229A1 (en) Point cloud attribute encoding method and device, and point cloud attribute decoding method and devcie
KR20000057338A (en) Data efficient quantization table for a digital video signal processor
CN110191341B (en) Depth data coding method and decoding method
CN117651150A (en) Improved QOI image coding strategy
CN115474044B (en) Bayer domain image lossy compression method
CN113347424B (en) Video coding data storage method and device and readable storage medium
JPH04270564A (en) Serial picture data compression system having color information
CN112449201B (en) Decoding method, encoding method, corresponding devices, electronic equipment and storage medium
JPH11308465A (en) Encoding method for color image, encoder therefor, decoding method for color image and decoder therefor
US7031531B1 (en) Image encoding device and method therefor, image decoding apparatus and method therefor, and computer-readable recorded medium on which image encoding program and image decoding program are recorded
GB2366472A (en) Improvements relating to representations of compressed video
CN113256747B (en) Bitmap index compression method, bitmap index decompression equipment and bitmap index medium
CN116828171A (en) Lossless compression method of RGB/RGBA image

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination