CN117596402A - Algorithm for lossy compression of image - Google Patents
Algorithm for lossy compression of image Download PDFInfo
- Publication number
- CN117596402A CN117596402A CN202311667818.4A CN202311667818A CN117596402A CN 117596402 A CN117596402 A CN 117596402A CN 202311667818 A CN202311667818 A CN 202311667818A CN 117596402 A CN117596402 A CN 117596402A
- Authority
- CN
- China
- Prior art keywords
- color
- pixel
- palette
- pixels
- algorithm
- 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
Links
- 230000006835 compression Effects 0.000 title claims abstract description 33
- 238000007906 compression Methods 0.000 title claims abstract description 33
- 239000003086 colorant Substances 0.000 claims description 25
- 238000000034 method Methods 0.000 abstract description 12
- 238000012545 processing Methods 0.000 abstract description 11
- 238000013139 quantization Methods 0.000 abstract description 10
- 238000005516 engineering process Methods 0.000 abstract description 6
- 230000005540 biological transmission Effects 0.000 description 4
- 238000011161 development Methods 0.000 description 2
- 238000004364 calculation method Methods 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000007796 conventional method Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000007726 management method Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000009877 rendering Methods 0.000 description 1
- 230000007704 transition Effects 0.000 description 1
Abstract
The invention discloses an algorithm for lossy compression of images, relates to an image compression technology, and provides a scheme aiming at the problems that the prior art is limited by the size of a palette and the like. The method comprises the following steps: s1, dividing an image into a plurality of continuous pixel areas, wherein each pixel area comprises 2 x 2 pixels and each pixel area corresponds to a palette; s2, determining a mode of a corresponding palette according to pixel color difference values in the pixel areas; s3, coding marks are respectively carried out according to the modes of the palettes, and compression is completed. The color quantization method has the advantages that the problems that the traditional palette algorithm needs to perform color quantization processing, the quantization step length, the quantization color quantity and other factors need to be considered, the color details of some original images can be lost in the quantization process and the like are avoided, and the image quality can be influenced by the size of the palette. The algorithm of the invention has simple realization and high compression precision, does not need the operation, and only needs to carry out block processing on the data block.
Description
Technical Field
The present invention relates to image compression technology, and more particularly, to an algorithm for lossy compression of images.
Background
The development of image compression technology is tightly coupled with the history of digital image processing and storage. With the development of digital technology, particularly in the fields of computers and network communications, efficient management and transmission of large amounts of image data is becoming an important issue. Image compression techniques have therefore evolved with the aim of reducing the memory space and transmission bandwidth they occupy while maintaining image quality. The technology is important to optimize data storage, reduce network bandwidth requirements, improve image processing efficiency and the like. And the fields of multimedia application, satellite image transmission, network video streaming and graphic rendering play a key role.
Lossy compression techniques achieve higher compression rates by allowing some degree of information loss, making them more efficient in processing large image and video files. This technique is particularly important in applications in online video streaming, high resolution image storage and mobile devices. The main advantage of lossy compression compared to lossless compression is that it can provide a higher compression rate, which is particularly important for large data transmission and storage. For example, network video and online image libraries largely employ lossy compression techniques.
With the popularity of high-speed internet access, emerging video applications such as remote desktop sharing, virtual desktop infrastructure, wireless display, etc. place higher demands on the compression efficiency of screen content. However, conventional intra-and inter-video coding tools are designed primarily for natural content. Screen content has significantly different features than natural content, such as sharp edges, less noise or no noise, which makes conventional coding tools appear inadequate. Unlike the conventional method, which mainly removes the intra-prediction and inter-prediction of redundancy between different coding units, the palette coding aims at redundancy of repeated pixel values/modes within the coding unit [1].
The palette algorithm is a specific compression method that reduces the data size by reducing the number of colors used in an image, which is particularly effective for images with fewer colors and is therefore well suited for processing screen content. Palette algorithms are widely used in Web images (e.g., GIF format) and in some types of user interface designs. Its main advantage is to provide a good balance between reducing the file size and maintaining sufficient image quality, especially in images with infrequent color changes.
Document [2] emphasizes the importance of palettes in encoding screen content, especially for computer-generated content that often use limited color sets, palettes can efficiently directly encode these color sets.
Modern palette algorithms typically use color quantization techniques, which means that they select a certain number of representative colors from the original image to construct a palette, in which process similar color values need to be mapped to the same palette index, when processing large or complex images, building a suitable palette has additional resource overhead, and furthermore all colors may not accurately map all colors in the image when the palette is too small, especially in color transitions and shadow areas.
[1]L.Guo,W.Pu,F.Zou,J.Sole,M.Karczewicz and R.Joshi,"Color palette for screen content coding,"2014IEEE International Conference on Image Processing(ICIP),Paris,France,2014,pp.5556-5560,doi:10.1109/ICIP.2014.7026124.
[2]Xu X,Liu S.Overview of screen content coding in recently developed video coding standards[J].IEEE Transactions on Circuits and Systems for Video Technology,2021,32(2):839-852.
Disclosure of Invention
The present invention aims to provide an algorithm for lossy compression of images, which solves the above-mentioned problems of the prior art.
The algorithm for lossy compression of images in the invention comprises the following steps:
s1, dividing an image into a plurality of continuous pixel areas, wherein each pixel area comprises 2 x 2 pixels and each pixel area corresponds to a palette;
s2, determining a mode of a corresponding palette according to pixel color difference values in the pixel areas;
s3, coding marks are respectively carried out according to the modes of the palettes, and compression is completed.
In the step S2, each pixel calculates color differences with three other pixels one by one, and makes pattern classification according to the relationship between the color differences and the threshold value:
when the color difference value of the two pairs of pixels is smaller than the threshold value, setting the palette corresponding to the current pixel area into a two-color mode, calculating a color average value for the two pixels with the color difference value smaller than the threshold value to replace the original pixel color, and obtaining two average replaced colors;
when the color difference value of only one pair of pixels is smaller than the threshold value, setting a palette corresponding to the current pixel area to be in a three-color mode, calculating a color average value for two pixels with the color difference value smaller than the threshold value to replace the color of the original pixel, and obtaining an average replaced color and retaining two primary colors;
when the color difference value between all the pixels is larger than the threshold value, setting the palette corresponding to the current pixel area into a four-color mode, and reserving the primary colors of the four pixels;
when the color difference between all pixels is less than the threshold, the encoding is skipped and the current color is replaced by the average of four pixel colors.
In said step S3, the mode of the corresponding palette is marked with a 3bit coded value.
When the palette mode is a two-color mode, adding a 1-bit flag to the 3-bit coded value indicates a pixel distribution state in which the color difference is smaller than a threshold value.
The algorithm for lossy compression of the image has the advantages that the problems that the traditional palette algorithm needs to carry out color quantization processing, needs to consider factors such as quantization step length, quantization color quantity and the like, and color details of some original images can be lost in the quantization process are avoided. The algorithm of the invention is simple to realize, does not need the operation, and only needs to carry out block division processing on the data block. In addition, the invention solves the problem that the palette index can not accurately map all colors in the image due to the too small palette in the traditional method, and the coding efficiency and compression quality of the algorithm of the invention can not be influenced by factors such as the size of the image or the size of the palette. 2 x 2 pixels are used as the minimum processing unit, so that the compression precision is high, and the image quality is ensured.
Drawings
Fig. 1 is a flow chart of an algorithm for lossy compression of images according to the present invention.
Fig. 2 is a coding schematic of an algorithm for lossy compression of images according to the present invention.
Detailed Description
An algorithm for lossy compression of images described in the present invention is exemplified by ARGB format data. As shown in fig. 1, the image is first divided into a plurality of consecutive pixel areas, each of which is further divided into 2 x 2 small blocks, each corresponding to a pixel. And then, establishing an independent corresponding palette for each pixel area, operating all pixels in each pixel area one by one, and replacing colors in certain pixels by using specified colors according to the palette mode so as to realize lossy compression.
When one pixel area is processed, each pixel calculates color difference value with the other three pixels one by one. As shown in fig. 2, four pixels correspond to pixel a, pixel B, pixel C, and pixel D, respectively, and 6 difference results appear after one-to-one calculation: diffAB, diffAC, diffAD, diffBC, diffBD and DiffCD, where DiffAB represents the color difference between pixel a and pixel B, and so on.
Pattern classification is made according to the relationship between the color difference and the threshold value:
(1) And when the color difference value of the two pairs of pixels is smaller than the threshold value, setting the palette corresponding to the current pixel area as a two-color mode. For example, diffAB is less than the threshold and DiffCD is less than the threshold. The color average of pixel a and pixel B is calculated instead of the primary colors of pixel a and pixel B. And calculating the average value of the colors of the pixel C and the pixel D to replace the primary colors of the pixel C and the pixel D.
(2) When the color difference value of only one pair of pixels is smaller than the threshold value, the palette corresponding to the current pixel region is set to a three-color mode. For example, diffAB is less than the threshold. The color average of pixel a and pixel B is calculated instead of the primary colors of pixel a and pixel B. While pixel C and pixel D remain the original colors, respectively.
(3) When the color difference value between all the pixels is larger than the threshold value, setting the palette corresponding to the current pixel area as a four-color mode, and reserving the primary colors of the four pixels.
(4) When the color difference between all pixels is smaller than the threshold value, the encoding is skipped, and the average value of the four pixel colors is used for replacing the colors of the four pixels at the same time.
The mode of the corresponding palette may be marked with a 3bit coded value Sel [2:0], where the four color mode occupies one value (101), the three color mode occupies six values (000, 001, 010, 011, 101, 110, 111), and the two color mode occupies one value (100). However, there are two color distribution states for the two-color mode: the pixel pairs with similar colors are distributed up and down, or left and right. Therefore, when the mode is a two-color mode, a flag of 1bit is added to a 3-bit coding value to represent a pixel distribution state that the color difference is smaller than a threshold value.
It will be apparent to those skilled in the art from this disclosure that various other changes and modifications can be made which are within the scope of the invention as defined in the appended claims.
Claims (4)
1. An algorithm for lossy compression of an image, comprising the steps of:
s1, dividing an image into a plurality of continuous pixel areas, wherein each pixel area comprises 2 x 2 pixels and each pixel area corresponds to a palette;
s2, determining a mode of a corresponding palette according to pixel color difference values in the pixel areas;
s3, coding marks are respectively carried out according to the modes of the palettes, and compression is completed.
2. An algorithm for lossy compression of an image according to claim 1, wherein in step S2, each pixel calculates color differences one by one with the other three pixels, and pattern classification is made according to the color differences versus threshold value:
when the color difference value of the two pairs of pixels is smaller than the threshold value, setting the palette corresponding to the current pixel area into a two-color mode, calculating a color average value for the two pixels with the color difference value smaller than the threshold value to replace the original pixel color, and obtaining two average replaced colors;
when the color difference value of only one pair of pixels is smaller than the threshold value, setting a palette corresponding to the current pixel area to be in a three-color mode, calculating a color average value for two pixels with the color difference value smaller than the threshold value to replace the color of the original pixel, and obtaining an average replaced color and retaining two primary colors;
when the color difference value between all the pixels is larger than the threshold value, setting the palette corresponding to the current pixel area into a four-color mode, and reserving the primary colors of the four pixels;
when the color difference between all pixels is less than the threshold, the encoding is skipped and the current color is replaced by the average of four pixel colors.
3. An algorithm for lossy compression of images according to claim 2, characterized in that in said step S3, the mode of the corresponding palette is marked with a 3bit coded value.
4. An algorithm for lossy compression of an image according to claim 3, wherein when the palette mode is a two-color mode, adding a 1bit flag to the 3bit coded value indicates a pixel distribution state where the color difference is less than a threshold.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311667818.4A CN117596402A (en) | 2023-12-06 | 2023-12-06 | Algorithm for lossy compression of image |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311667818.4A CN117596402A (en) | 2023-12-06 | 2023-12-06 | Algorithm for lossy compression of image |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117596402A true CN117596402A (en) | 2024-02-23 |
Family
ID=89919931
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311667818.4A Pending CN117596402A (en) | 2023-12-06 | 2023-12-06 | Algorithm for lossy compression of image |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117596402A (en) |
-
2023
- 2023-12-06 CN CN202311667818.4A patent/CN117596402A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111133476B (en) | System, apparatus and method for compression and decompression of a point cloud comprising a plurality of points | |
US11785215B2 (en) | Encoding method, decoding method, encoding/decoding system, encoder, and decoder | |
CN1332300C (en) | Remote display processing method based on server end/client end structure | |
CN113542740B (en) | Image transmission method and device | |
CN111971967A (en) | Method and apparatus for encoding/decoding a point cloud representing a 3D object | |
KR20060047631A (en) | Adaptive compression of multi-level images | |
CN103167289B (en) | The coding of image, coding/decoding method and coding, decoding device | |
CN101014129B (en) | Video data compression method | |
CN100425066C (en) | Image compression method | |
CN111131828A (en) | Image compression method and device | |
CN103313055B (en) | A kind of chroma intra prediction method based on segmentation and video code and decode method | |
CN115474044B (en) | Bayer domain image lossy compression method | |
CN109819254B (en) | Lossy image compression transmission method and system | |
CN117596402A (en) | Algorithm for lossy compression of image | |
JP4215269B2 (en) | Region-based scalable image coding | |
CN113365080B (en) | Encoding and decoding method, device and storage medium for string coding technology | |
CN113301339A (en) | Data encoding and decoding method and device | |
CN112532990A (en) | String length parameter coding and decoding methods and devices | |
CN1295652C (en) | Image information coding method | |
CN105578191B (en) | Index map primary colours selection method based on histogram sliding window | |
CN110689590B (en) | Compression coding method and device for map and mobile terminal equipment | |
Yang et al. | A fast and efficient codec for multimedia applications in wireless thin-client computing | |
CN110505486B (en) | Coding and decoding method for mapping high-probability motion vector | |
CN117221547B (en) | CTU-level downsampling-based 8K video coding method and device | |
CN108429910B (en) | Image compression method |
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 |