Image compression method, device, equipment and storage medium
By dividing the original image into multiple original compressed blocks, identifying and adjusting the pixel colors in the compressed blocks to be processed so that they all appear in the target monochrome, the problem of distortion after image compression is solved and the display effect is improved.
Patent Information
- Application Number
- CN202311196271.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-15
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2043-09-15
AI Technical Summary
After the original image data is compressed and decompressed, the display effect is poor and there is a distortion problem.
Divide the original image into multiple original compression blocks, identify the compression block to be processed, adjust the color of the pixels in it so that they all appear in the target monochrome, and compress them.
Improved display effects by adjusting pixel colors in compressed blocks to reduce post-decompression distortion issues.
Smart Images

Figure CN117156144B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image compression method, device, equipment and storage medium. Background Art
[0002] In order to reduce the storage space occupied by the image data, the data of the original image can be compressed to obtain compressed image data, and the compressed image data can be stored in the memory corresponding to the screen. When the screen is displayed, the compressed image data can be read from the memory, and the compressed image data can be decompressed, and the screen display can be driven according to the obtained decompressed image data.
[0003] However, after the original image data is compressed and then decompressed, the decompressed image data obtained has a certain degree of distortion compared to the original image data, resulting in a poor display effect. Summary of the invention
[0004] The embodiments of the present application provide an image compression method, apparatus, device and storage medium, which are helpful to improve the image distortion problem, thereby helping to improve the display effect.
[0005] In a first aspect, an embodiment of the present application provides an image compression method, comprising: dividing an original image into a plurality of original compression blocks, the original compression blocks comprising a plurality of pixels; identifying a first compression block to be processed from the plurality of original compression blocks, the first compression block to be processed comprising two monochrome pixels, and the pixels of different monochromes in the first compression block to be processed are arranged in a first direction, and the pixels of the same monochrome are arranged in a second direction, one of the first direction and the second direction being a row direction, and the other being a column direction; adjusting at least one monochrome pixel in the first compression block to be processed to obtain a first target compression block, so that the plurality of pixels in the first target compression block are all in the target monochrome; and compressing the first target compression block.
[0006] In a possible implementation of the first aspect, the method provided in the embodiment of the present application may further include:
[0007] A second compressed block to be processed is identified from a plurality of original compressed blocks, the second compressed block to be processed is adjacent to the first compressed block to be processed in a second direction, the second compressed block to be processed includes two single-color pixels and at least one mixed-color pixel, in the second direction, the two single-color pixels in the second compressed block to be processed are located between the first compressed block to be processed and the mixed-color pixels, the two single-color pixels of the pixels of the second compressed block to be processed are the same as the two single-color pixels of the pixels of the first compressed block to be processed, and the arrangement rule of the colors of the two single-color pixels in the second compressed block to be processed is the same as the arrangement rule of the colors of the two single-color pixels in the first compressed block to be processed;
[0008] Adjusting at least one monochrome pixel in the second compressed block to be processed to obtain a second target compressed block, so that a plurality of pixels other than the mixed color pixels in the second target compressed block are all in the target monochrome;
[0009] The second target compressed block is compressed.
[0010] In a possible implementation of the first aspect, the two monochromatic colors presented by the pixels of the first compressed block to be processed include a first monochromatic color and a second monochromatic color, the target monochromatic color includes the second monochromatic color, and the pixels of at least one monochromatic color in the first compressed block to be processed are adjusted to obtain a first target compressed block, including:
[0011] The color of the pixels in the first to-be-processed compressed block is replaced from the first monochrome color to the second monochrome color to obtain a first target compressed block.
[0012] In a possible implementation of the first aspect, replacing the color of pixels in the first compressed block to be processed from a first monochrome color to a second monochrome color includes:
[0013] The grayscale value of the first monochrome pixel in the first compressed block to be processed is adjusted to be the same as the grayscale value of the second monochrome pixel in the first compressed block to be processed.
[0014] In a possible implementation of the first aspect, the sensitivity of the human eye to the second monochrome is lower than the sensitivity of the human eye to the first monochrome.
[0015] In a possible implementation manner of the first aspect, the first single color is red, and the second single color is blue; or, the first single color is green, and the second single color is red; or, the first single color is green, and the second single color is blue.
[0016] In a possible implementation of the first aspect, the original compressed block includes i×j pixels, where i represents the number of pixel rows and j represents the number of pixel columns;
[0017] When the first direction is the row direction, i≥2, j=2;
[0018] When the first direction is the column direction, i=2, j≥2;
[0019] Preferably, i=2, j=2.
[0020] Based on the same inventive concept, in a second aspect, an embodiment of the present application provides an image compression device, the device comprising:
[0021] A compression block division module, used for dividing the original image into a plurality of original compression blocks, where the original compression blocks include a plurality of pixels;
[0022] an identification module, configured to identify a first compressed block to be processed from a plurality of original compressed blocks, wherein the first compressed block to be processed includes two monochrome pixels, and pixels of different monochromes in the first compressed block to be processed are adjacent in a first direction, and pixels of the same monochrome are adjacent in a second direction, and one of the first direction and the second direction is a row direction, and the other is a column direction;
[0023] An adjustment module, configured to adjust at least one monochrome pixel in the first compressed block to be processed to obtain a first target compressed block, so that a plurality of pixels in the first target compressed block are all in the target monochrome;
[0024] The compression module is used to compress the first target compression block.
[0025] Based on the same inventive concept, in a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory storing computer program instructions, wherein when the processor executes the computer program instructions, the image compression method as described in any one of the embodiments in the first aspect is implemented.
[0026] Based on the same inventive concept, in a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the image compression method as described in any one of the embodiments in the first aspect is implemented.
[0027] According to the image compression method, apparatus, device and storage medium provided by the embodiments of the present application, a first compressed block to be processed is identified from multiple original compressed blocks, the first compressed block to be processed includes pixels at the junction of two monochromes, and the colors of the pixels in the first compressed block to be processed are adjusted to obtain a first target compressed block, so that multiple pixels in the first target compressed block are all in the target monochrome. In this way, multiple pixels in the first target compressed block are in the same monochrome, which can improve the decompression distortion problem caused by the presence of pixels at the junction of two monochromes in the same compressed block, thereby helping to improve the display effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Other features, objects and advantages of the present application will become more apparent by reading the following detailed description of non-limiting embodiments with reference to the accompanying drawings, in which the same or similar reference numerals represent the same or similar features and the accompanying drawings are not drawn to scale.
[0029] Figure 1 A schematic diagram showing a color boundary in a compressed block provided by an embodiment of the present application;
[0030] Figure 2 A schematic diagram showing a flow chart of an image compression method provided by an embodiment of the present application;
[0031] Figure 3A schematic diagram showing a division of compression blocks in the image compression method provided in an embodiment of the present application;
[0032] Figure 4 Another schematic diagram showing the division of compression blocks in the image compression method provided in an embodiment of the present application;
[0033] Figure 5 A schematic diagram of color adjustment in the image compression method provided in an embodiment of the present application is shown;
[0034] Figure 6 Another schematic diagram showing a flow chart of an image compression method provided in an embodiment of the present application;
[0035] Figure 7 Another color adjustment schematic diagram in the image compression method provided in an embodiment of the present application is shown;
[0036] Figure 8 A schematic diagram showing the structure of an image compression device provided in an embodiment of the present application is shown;
[0037] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0038] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only configured to explain the present application and are not configured to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is only to provide a better understanding of the present application by illustrating the examples of the present application.
[0039] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0040] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0041] It is obvious to those skilled in the art that various modifications and changes can be made in the present application without departing from the spirit or scope of the present application. Therefore, the present application is intended to cover modifications and changes of the present application that fall within the scope of the corresponding claims (technical solutions for protection) and their equivalents. It should be noted that the implementation methods provided in the embodiments of the present application can be combined with each other without contradiction.
[0042] Before describing the technical solutions provided by the embodiments of the present application, in order to facilitate the understanding of the embodiments of the present application, the present application first specifically describes the problems existing in the related art:
[0043] As described in the background art, the data of the original image may be compressed and then decompressed, and the screen display may be driven according to the obtained decompressed image data.
[0044] The compression may be performed according to a certain size of compression block (block), for example, a block may include multiple pixels in multiple rows and columns. The inventors have found that when the data within the block is very different, especially when there is a single-color boundary within the same block, data distortion may occur after compression and decompression. In this article, "boundary" may be understood as adjacent.
[0045] like Figure 1 As shown, take a block including 4 pixels in 2 rows and 2 columns as an example. Figure 1 Six blocks are shown, namely block1 to block6, where block1 includes four pixels with horizontal coordinates 124 and 125 and vertical coordinates 198 and 199, and the others are similar and will not be described in detail. A pixel may include a red sub-pixel, a green sub-pixel and a blue sub-pixel. Figure 1 The pixel corresponding to a coordinate point in the image includes three values, the first value represents the grayscale value of the red sub-pixel of the pixel, the second value represents the grayscale value of the green sub-pixel of the pixel, and the third value represents the grayscale value of the blue sub-pixel of the pixel. Take the pixel corresponding to the coordinate point with abscissa 124 and ordinate 198 in the original image as an example, the data of the pixel is 0-204-0, the first "0" represents the grayscale value of the red sub-pixel is 0, "204" represents the grayscale value of the green sub-pixel is 204, and the second "0" represents the grayscale value of the blue sub-pixel is 0. The pixel corresponding to the coordinate point with abscissa 124 and ordinate 198 is green.
[0046] It can be understood that the pixels in block1 to block3 are all green, the pixels with a ordinate of 200 in block4 to block6 are all green, and the pixels with a ordinate of 201 in block4 to block6 are all red.
[0047] By comparing the decompressed image with the original image, it can be seen that if the colors of multiple pixels in the same block are the same, the gradient characteristics of the original image can be maintained after decompression. If the multiple pixels in the same block include multiple colors, the grayscale value of the green sub-pixel after decompression is higher due to the different characteristics of pixels of different colors, resulting in a convex and bright color block feeling when displayed. For example, the grayscale value of the green sub-pixel corresponding to the horizontal coordinate 124 and the vertical coordinate 199 in the original image is 204, and the grayscale value of the green sub-pixel corresponding to the horizontal coordinate 124 and the vertical coordinate 199 in the decompressed image is 243; while the grayscale value of the green sub-pixel corresponding to the horizontal coordinate 124 and the vertical coordinate 200 in the original image is 204, and the grayscale value of the green sub-pixel corresponding to the horizontal coordinate 124 and the vertical coordinate 200 in the decompressed image is 255.
[0048] In addition, if multiple pixels in the same block include multiple colors, the smaller grayscale in the original image will slowly fade, and the distortion will lead to larger gradient values, which will cause visual jaggedness. For example, the value corresponding to the horizontal coordinate 127 and the vertical coordinate 200 in the original image is 0-201-0, while the value corresponding to the horizontal coordinate 127 and the vertical coordinate 200 in the decompressed image becomes 8-248-8, which increases the value that should be 0 to 8.
[0049] That is to say, if there are pixels at the junction of two monochrome colors in the same block, the decompressed image will be distorted, resulting in poor display effects, such as convex highlights or visual jaggedness.
[0050] In order to solve the above problems, embodiments of the present application provide a display panel and a display device. Various embodiments of the display panel and the display device will be described below in conjunction with the accompanying drawings.
[0051] The present application embodiment provides an image compression method. Figure 2 As shown, the image compression method provided in the embodiment of the present application may include S10 to S40.
[0052] S10, dividing the original image into a plurality of original compressed blocks, where the original compressed blocks include a plurality of pixels;
[0053] S20, identifying a first compressed block to be processed from a plurality of original compressed blocks, the first compressed block to be processed comprising two monochrome pixels, and the pixels of different monochromes in the first compressed block to be processed are arranged in a first direction, and the pixels of the same monochrome are arranged in a second direction, and one of the first direction and the second direction is a row direction, and the other is a column direction;
[0054] S30, adjusting at least one monochrome pixel in the first compressed block to be processed to obtain a first target compressed block, so that a plurality of pixels in the first target compressed block are all in the target monochrome;
[0055] S40: compress the first target compression block.
[0056] The specific implementation of the above steps will be described in detail below.
[0057] According to the image compression method provided in the embodiment of the present application, a first compressed block to be processed is identified from multiple original compressed blocks, the first compressed block to be processed includes pixels at the junction of two monochrome colors, and the colors of the pixels in the first compressed block to be processed are adjusted to obtain a first target compressed block, so that multiple pixels in the first target compressed block are all in the target monochrome. In this way, multiple pixels in the first target compressed block are in the same monochrome, which can improve the decompression distortion problem caused by the presence of pixels at the junction of two monochrome colors in the same compressed block, thereby helping to improve the display effect.
[0058] The specific implementation methods of the above steps are introduced below.
[0059] First, let me introduce the S10.
[0060] like Figure 3 or Figure 4 As shown, the original image can be divided into a plurality of original compressed blocks Block arranged in a matrix. The size of each original compressed block Block can be the same. The original compressed block Block can include ixj pixels, i represents the number of pixel rows, and j represents the number of pixel columns. When the first direction is the row direction, i≥2, j=2; when the first direction is the column direction, i=2, j≥2.
[0061] Figure 3 Take i=2, j=2 as an example, Figure 3 In the case where the first direction is the column direction, i=2 and j=3 are exemplified.
[0062] Optionally, i=2, j=2. That is, the minimum unit of the number of pixels included in the original compressed block 101 is 2×2, so that the boundary of the pixel colors in each original compressed block 101 can be determined more finely, which is conducive to more finely identifying the first compressed block to be processed and the second compressed block to be processed in the subsequent step.
[0063] Of course, the number of rows and columns of pixels included in the original compressed block 101 may be changed in various ways.
[0064] It is understandable that the original compressed block includes grayscale data of multiple pixels. Taking the original compressed block 101 including 2×2 pixels as an example, when the pixel includes a red sub-pixel, a green sub-pixel and a blue sub-pixel, the original compressed block includes grayscale data of 2×2 red sub-pixels, grayscale data of 2×2 green sub-pixels and grayscale data of 2×2 blue sub-pixels.
[0065] Next, let me introduce S20.
[0066] A pixel may include multiple monochrome sub-pixels. If only one monochrome sub-pixel in the pixel has a non-zero grayscale value and the grayscale values of the other monochrome sub-pixels are 0, the pixel may be considered as a monochrome pixel.
[0067] The pixel includes a red sub-pixel, a green sub-pixel, and a blue sub-pixel. For example, if the grayscale value of the red sub-pixel in the pixel is non-0, and the grayscale values of the green sub-pixel and the blue sub-pixel are 0, the pixel can be considered to be a red pixel. Alternatively, if the grayscale value of the green sub-pixel in the pixel is non-0, and the grayscale values of the red sub-pixel and the blue sub-pixel are 0, the pixel can be considered to be a green pixel. Alternatively, if the grayscale value of the blue sub-pixel in the pixel is non-0, and the grayscale values of the red sub-pixel and the green sub-pixel are 0, the pixel can be considered to be a blue pixel.
[0068] If the grayscale values of two or more single-color sub-pixels in a pixel are non-zero, the pixel can be considered as a mixed-color pixel.
[0069] S20 may specifically include: identifying a first to-be-processed compressed block from a plurality of original compressed blocks according to colors of a plurality of pixels in the original compressed block.
[0070] like Figure 5 As shown, the first compression block to be processed is marked as 102, and the first compression block to be processed 102 includes two monochrome pixels, and the pixels of different monochromes in the first compression block to be processed 102 are arranged in a first direction, and the pixels of the same monochrome are arranged in a second direction, and one of the first direction and the second direction is a row direction, and the other is a column direction.
[0071] Figure 5 The first compressed block to be processed 102 includes a red pixel R and a green pixel G, and the red pixel R and the green pixel G in the first compressed block to be processed 102 are arranged in the first direction, and the two red pixels R in the first compressed block to be processed 102 are arranged in the second direction, and the two green pixels G in the first compressed block to be processed 102 are arranged in the second direction. It can be understood that Figure 5The red pixel R and the green pixel G of the first compressed block 102 to be processed intersect in the first direction, that is, the red pixel R and the green pixel G of the first compressed block 102 to be processed are adjacent in the first direction.
[0072] When the pixel includes a red sub-pixel, a green sub-pixel and a blue sub-pixel, the monochrome colors that the pixel may present include red, green and blue. For example, the original compressed block includes 2×2 pixels, and the boundary conditions of two monochrome pixels in the first compressed block to be processed may include a total of 12 types as shown in Tables 1 and 2.
[0073] Table 1
[0074]
[0075] Table 2
[0076]
[0077]
[0078] Next, let’s introduce S30.
[0079] The first to-be-processed compressed block includes two monochrome pixels, and the color of at least one monochrome pixel may be adjusted so that all pixels in the obtained first target compressed block are of the same monochrome.
[0080] It is understandable that adjusting the color of a pixel may specifically include: adjusting the grayscale value of the pixel.
[0081] For example, if a pixel is red, it can be understood that the grayscale value of the red sub-pixel in the pixel is non-0, and the grayscale values of the blue sub-pixel and the green sub-pixel are 0. For example, if the target single color is green, the grayscale value of the red sub-pixel in the pixel can be adjusted from non-0 to 0, and the grayscale value of the green sub-pixel in the pixel can be adjusted from 0 to non-0, and the grayscale value of the blue sub-pixel in the pixel can remain unchanged.
[0082] like Figure 5 As shown, the first compressed block to be processed 102 includes red pixels R and green pixels G intersecting in a first direction. In the first direction, the pixels in the original compressed blocks on one side of the first compressed block to be processed 102 are all red, and the pixels in the original compressed blocks on the other side of the first compressed block to be processed 102 are all green.
[0083] In some optional embodiments, the two monochrome colors presented by the pixels of the first compressed block to be processed include a first monochrome and a second monochrome. In S30, the pixels of at least one monochrome in the first compressed block to be processed are adjusted to obtain the first target compressed block, which may include: replacing the color presented by the pixels in the first compressed block to be processed from the first monochrome to the second monochrome to obtain the first target compressed block.
[0084] By replacing the color of the pixels in the first compressed block to be processed from the first monochrome to the second monochrome, when the pixels of the two original compressed blocks on both sides of the first compressed block to be processed in the first direction are respectively the first monochrome and the second monochrome, the monochrome of the pixels in the obtained first target compressed block can be the same as the color of one of the adjacent original compressed blocks in the first direction, thereby avoiding the addition of a new monochrome, thereby avoiding the visual abruptness caused by the introduction of other colors.
[0085] In order to more clearly understand the adjustment of the color of the pixels in the first compressed block to be processed, as shown in FIG. Figure 5 As shown, the first compressed block 102 to be processed includes red pixels R and green pixels G. For example, green is the first monochrome and red is the second monochrome. The green pixels G in the first compressed block 102 to be processed can be adjusted from green to red, thereby obtaining a first target compressed block 103. The colors of the pixels in the first target compressed block 103 are all red, and the colors of the pixels in the first target compressed block 103 are the same as the colors of the pixels in an original compressed block 101 on the upper side of the first target compressed block 103.
[0086] As described above, when the grayscale value of only one sub-pixel of a color in a pixel is non-0, the pixel is monochrome. Sub-pixels can display multiple grayscale values other than 0, that is, for the same monochrome pixel, it can include multiple grayscale values, and different grayscale values will also have different brightness of the pixel.
[0087] In some embodiments, replacing the color of the pixels in the first to-be-processed compressed block from the first monochrome color to the second monochrome color may include: adjusting the grayscale value of the first monochrome pixel in the first to-be-processed compressed block to be the same as the grayscale value of the second monochrome pixel in the first to-be-processed compressed block. In this way, the colors of the multiple pixels in the first target compressed block obtained after the adjustment are not only the same, but also the grayscale values are the same.
[0088] By adjusting the grayscale value of the first monochrome pixel in the first to-be-processed compressed block to be the same as the grayscale value of the second monochrome pixel in the first to-be-processed compressed block, the colors of the pixels in the first target compressed block obtained after adjustment can not only be the same, but the brightness of the pixels can also be the same. In this way, the difference in pixel brightness in the same compressed block can be improved, further improving the display effect.
[0089] For example, Figure 5The grayscale values of the two green pixels in the first compressed block 102 to be processed are 0-204-0, and the grayscale values of the two red pixels in the first compressed block 102 to be processed are 204-0-0. The grayscale values of the two green pixels can be modified from 0-204-0 to 204-0-0, so that the four pixels in the first target compressed block 103 are all red, and the grayscale values of the four pixels are all 204-0-0.
[0090] Of course, adjusting the grayscale value of the first monochrome pixel in the first to-be-processed compressed block to be the same as the grayscale value of the second monochrome pixel is only an example, and the grayscale value of the first monochrome pixel in the first to-be-processed compressed block may also be adjusted to be different from the grayscale value of the second monochrome pixel. For example, the grayscale value of the first monochrome pixel in the first to-be-processed compressed block may be adjusted to be greater than or less than the grayscale value of the second monochrome pixel.
[0091] Since human eyes have different sensitivities to different colors, in the above embodiment, replacing the color of the pixels in the first compressed block to be processed from the first monochrome color to the second monochrome color actually changes the original colors of some pixels.
[0092] In some optional embodiments, in the above embodiments: the color of the pixels in the first compressed block to be processed is replaced from the first monochrome to the second monochrome, to obtain the first target compressed block, and the sensitivity of the human eye to the second monochrome may be lower than the sensitivity of the human eye to the first monochrome. In this way, the first monochrome to which the human eye is more sensitive in the first compressed block to be processed can be replaced with the second monochrome to which the human eye is less sensitive, so that even if the original color of some pixels is changed, the changed color is not too sensitive to the human eye, thereby providing a display effect from the perspective of human eye vision.
[0093] The inventors have found that the sensitivity of the human eye to red, green and blue is B<R<G, so the priority of color replacement may be B>R>G.
[0094] In some embodiments, the first single color may be red and the second single color may be blue; or the first single color may be green and the second single color may be red; or the first single color may be green and the second single color may be blue.
[0095] That is, when there is a junction between red and blue pixels in the same compressed block, the red pixels in the compressed block can be replaced with blue pixels because the human eye is less sensitive to blue than to red. When there is a junction between red and green pixels in the same compressed block, the green pixels in the compressed block can be replaced with red pixels because the human eye is less sensitive to red than to green. When there is a junction between green and blue pixels in the same compressed block, the green pixels in the compressed block can be replaced with blue pixels because the human eye is less sensitive to blue than to green.
[0096] Next, let’s introduce S40.
[0097] The present application does not limit the specific compression method of the first target compressed block. For example, the first target compressed block can be compressed in a lossy compression manner to reduce the storage space occupied by the compressed data. Of course, it can also be compressed in other existing compression methods.
[0098] It is understandable that, for the original compressed block that is not identified as the first compressed block to be processed and the second compressed block to be processed described in the subsequent steps, no color adjustment process may be performed, and the original compressed block may be directly compressed.
[0099] In some optional embodiments, such as Figure 6 As shown, the method provided in the embodiment of the present application may further include S50 to S70.
[0100] S50, identifying a second compressed block to be processed from a plurality of original compressed blocks, the second compressed block to be processed being adjacent to the first compressed block to be processed in a second direction, the second compressed block to be processed comprising two single-color pixels and at least one mixed-color pixel, in the second direction, the two single-color pixels in the second compressed block to be processed are located between the first compressed block to be processed and the mixed-color pixels, the two single-color pixels of the pixels of the second compressed block to be processed are the same as the two single-color pixels of the pixels of the first compressed block to be processed, and the arrangement rule of the colors of the two single-color pixels in the second compressed block to be processed is the same as the arrangement rule of the colors of the two single-color pixels in the first compressed block to be processed;
[0101] S60, adjusting at least one monochrome pixel in the second compressed block to be processed to obtain a second target compressed block, so that a plurality of pixels other than the mixed color pixels in the second target compressed block are all in the target monochrome;
[0102] S70: compress the second target compression block.
[0103] The arrangement rule of the two monochrome pixels in the second compressed block to be processed in S50 is the same as the arrangement rule of the two monochrome pixels in the first compressed block to be processed, that is, the pixels of different monochromes in the second compressed block to be processed are arranged in the first direction, and the pixels of the same monochrome are arranged in the second direction, one of the first direction and the second direction is the row direction, and the other is the column direction.
[0104] Exemplarily, pixels of the same single color in the first compressed block to be processed and the second compressed block to be processed are adjacent in the second direction.
[0105] In order to better understand this embodiment, Figure 7 As shown, image a is a partial image area in the original image, the first compressed block to be processed is marked as 102 , the second compressed block to be processed is marked as 104 , and the original compressed block is marked as 101 .
[0106] The first compressed block 102 to be processed includes a blue pixel B and a green pixel G. The blue pixel B and the green pixel G in the first compressed block 102 to be processed are arranged in the first direction, and the two blue pixels G in the first compressed block 102 to be processed are arranged in the second direction, and the two green pixels G in the first compressed block 102 to be processed are arranged in the second direction. It can be understood that Figure 7 The blue pixel B and the green pixel G of the first compressed block 102 to be processed intersect in the first direction, that is, the blue pixel B and the green pixel G of the first compressed block 102 to be processed are adjacent in the first direction.
[0107] The second compressed block 104 to be processed includes two single-color pixels and at least one mixed-color pixel W, the two single-color pixels are blue pixels B and green pixels G, the blue pixels B and green pixels G in the second compressed block 104 to be processed are arranged in the first direction, and the two blue pixels G in the second compressed block 104 to be processed are arranged in the second direction, and the two green pixels G in the second compressed block 104 to be processed are arranged in the second direction. It can be understood that Figure 7 The blue pixel B and the green pixel G of the second compressed block 104 to be processed intersect in the first direction, that is, the blue pixel B and the green pixel G of the second compressed block 104 to be processed are adjacent in the first direction.
[0108] Exemplarily, the blue pixel B in the second compressed block 104 to be processed may be adjacent to the blue pixel B in the first compressed block 102 to be processed in the second direction, and the green pixel G in the second compressed block 104 to be processed may be adjacent to the green pixel G in the first compressed block 102 to be processed in the second direction.
[0109] As described in the above embodiment, at least one monochrome pixel in the first compressed block to be processed 102 may be adjusted, for example, the blue pixel B in the first compressed block to be processed 102 may be replaced with the green pixel G, to obtain the first target compressed block 103 in the image b as shown in 7. If the color of the monochrome pixel in the second compressed block to be processed 104 is not adjusted, there will be at least one isolated blue pixel B in the second compressed block to be processed 104, which will visually appear jagged.
[0110] To avoid the above problems, in an embodiment of the present application, at least one monochrome pixel in the second compression block to be processed is adjusted to obtain a second target compression block, so that multiple pixels other than the mixed-color pixels in the second target compression block all present the same target monochrome as the first target compression block, so that there will be no isolated monochrome pixels, which can improve the visual aliasing effect.
[0111] The specific adjustment method of the second compressed block to be processed in S60 may be the same as the adjustment method of the second compressed block to be processed introduced in the above example. For example, the two monochromes presented by the pixels of the second compressed block to be processed also include the first monochrome and the second monochrome, and the target monochrome includes the second monochrome. The color presented by the pixels in the second compressed block to be processed may be replaced by the first monochrome with the second monochrome to obtain the second target compressed block. For another example, the color presented by the pixels in the second compressed block to be processed may be replaced by the first monochrome with the second monochrome to obtain the second target compressed block, which may specifically include: adjusting the grayscale value of the pixels of the first monochrome in the second compressed block to be processed to be the same as the grayscale value of the pixels of the second monochrome in the second compressed block to be processed. Among them, the characteristics of the first monochrome and the second monochrome may be as introduced in the above embodiment, and will not be repeated here one by one.
[0112] For example, at least one monochrome pixel in the second compression block 104 to be processed may be adjusted. For example, the blue pixel B in the second compression block 104 to be processed may be replaced with a green pixel G to obtain the second target compression block 105 in the image c as shown in FIG7 . In this way, there will be no isolated blue pixel B to avoid visual jaggedness.
[0113] The specific compression method for the second target compressed block may be the same as the specific compression method for the first target compressed block, for example, both may be compressed in a lossy compression manner.
[0114] In combination with the adjustment process of the first block to be processed and the second block to be processed, it can be understood that the embodiment of the present application essentially identifies the color boundary according to the size of the original compressed block to accurately identify the two rows of pixels or two columns of pixels at the monochrome boundary, and then replaces the color of the pixels at the monochrome boundary according to a processing block of a certain size to ensure that the compressed block with the monochrome boundary no longer has the monochrome boundary after being processed. The size of the processing block is larger than the size of the original compressed block.
[0115] For example, the original compressed block includes 2×2 pixels, and the processing block may include 2×3 pixels. The 2×3 pixels in the processing block include the 2×2 pixels in the original compressed block. The 2×3 pixels in the processing block can be marked as index1, index2, index3, index4, index5 and index6 respectively. Among them, index1, index2, index3, index4 are the 2×2 pixels in the original compressed block, index1, index2, index3, index4 can be used to identify color boundaries, index5 and index6 can be used to process pixels in odd rows or odd columns that cannot be processed according to the 2×2 size processing method, so that the adjustment of the color of the pixels will not be affected by the odd-even rows or odd-even columns. Among them, the 2×2 size processing method can be used to process the first compressed block to be processed.
[0116] Based on the same inventive concept, the embodiment of the present application also provides an image compression device. Figure 8 As shown, the image compression device 800 provided in the embodiment of the present application may include a compression block division module 801 , an identification module 802 , an adjustment module 803 and a compression module 804 .
[0117] A compression block division module 801 is used to divide the original image into a plurality of original compression blocks, where the original compression blocks include a plurality of pixels;
[0118] The identification module 802 is used to identify a first compressed block to be processed from a plurality of original compressed blocks, wherein the first compressed block to be processed includes two monochrome pixels, and pixels of different monochromes in the first compressed block to be processed are adjacent in a first direction, and pixels of the same monochrome are adjacent in a second direction, and one of the first direction and the second direction is a row direction, and the other is a column direction;
[0119] An adjustment module 803 is used to adjust at least one monochrome pixel in the first compressed block to be processed to obtain a first target compressed block, so that multiple pixels in the first target compressed block are all in the target monochrome;
[0120] The compression module 804 is configured to compress the first target compression block.
[0121] According to the image compression device provided by the embodiment of the present application, a first compression block to be processed is identified from multiple original compression blocks, the first compression block to be processed includes pixels at the junction of two monochrome colors, and the colors of the pixels in the first compression block to be processed are adjusted to obtain a first target compression block, so that multiple pixels in the first target compression block are all in the target monochrome. In this way, multiple pixels in the first target compression block are in the same monochrome, which can improve the decompression distortion problem caused by the presence of pixels at the junction of two monochrome colors in the same compression block, thereby helping to improve the display effect.
[0122] In some optional embodiments, the identification module 802 is further used to: identify a second compressed block to be processed from the multiple original compressed blocks, the second compressed block to be processed is adjacent to the first compressed block to be processed in the second direction, the second compressed block to be processed includes two monochrome pixels and at least one mixed color pixel, in the second direction, the two monochrome pixels in the second compressed block to be processed are located between the first compressed block to be processed and the mixed color pixels, the two monochrome colors of the pixels of the second compressed block to be processed are the same as the two monochrome colors of the pixels of the first compressed block to be processed, and the arrangement rule of the colors of the two monochrome pixels in the second compressed block to be processed is the same as the arrangement rule of the colors of the two monochrome pixels in the first compressed block to be processed;
[0123] The adjustment module 803 is further used to: adjust at least one monochrome pixel in the second compressed block to be processed to obtain a second target compressed block, so that multiple pixels other than the mixed color pixels in the second target compressed block are all in the target monochrome;
[0124] The compression module 804 is further configured to compress the second target compression block.
[0125] In some optional embodiments, the two monochromatic colors of the pixels of the first compressed block to be processed include a first monochromatic color and a second monochromatic color, the target monochromatic color includes the second monochromatic color, and the adjustment module 803 may be specifically configured to:
[0126] The color of the pixels in the first to-be-processed compressed block is replaced from the first monochrome color to the second monochrome color to obtain a first target compressed block.
[0127] In some optional embodiments, the adjustment module 803 may be specifically used to:
[0128] The grayscale value of the first monochrome pixel in the first compressed block to be processed is adjusted to be the same as the grayscale value of the second monochrome pixel in the first compressed block to be processed.
[0129] In some optional embodiments, the sensitivity of the human eye to the second monochrome is lower than the sensitivity of the human eye to the first monochrome.
[0130] In some optional embodiments, the first single color is red and the second single color is blue; or, the first single color is green and the second single color is red; or, the first single color is green and the second single color is blue.
[0131] In some optional embodiments, the original compressed block includes i×j pixels, where i represents the number of pixel rows and j represents the number of pixel columns;
[0132] When the first direction is the row direction, i≥2, j=2;
[0133] When the first direction is the column direction, i=2, j≥2;
[0134] Preferably, i=2, j=2.
[0135] It should be noted that the image compression method provided in the embodiment of the present application can be executed by an image compression device or a control module in the image compression device for executing the image compression method. In the embodiment of the present application, the image compression device provided in the embodiment of the present application is described by taking the image compression method executed by the image compression device as an example.
[0136] The image compression device in the embodiment of the present application can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc. The non-mobile electronic device can be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0137] The image compression device provided in the embodiment of the present application can achieve Figure 2 To avoid repetition, the various processes in the illustrated embodiment of the image compression method will not be described again.
[0138] Fig. 9 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application is shown.
[0139] The electronic device may include a processor 901 and a memory 902 storing computer program instructions.
[0140] Specifically, the processor 901 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present invention.
[0141] The memory 902 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 902 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 902 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 902 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 902 is a non-volatile solid-state memory. In a specific embodiment, the memory 902 includes a read-only memory (ROM). In appropriate cases, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically rewritable ROM (EAROM) or a flash memory or a combination of two or more of these. Exemplarily, the memory may include a non-volatile transient memory.
[0142] The processor 901 implements any one of the image compression methods in the above embodiments by reading and executing computer program instructions stored in the memory 902 .
[0143] In one example, the electronic device may further include a communication interface 903 and a bus 910. Fig. 9 As shown, the processor 901, the memory 902, and the communication interface 903 are connected via a bus 910 and communicate with each other.
[0144] The communication interface 903 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiment of the present invention.
[0145] Bus 910 includes hardware, software or both, and the parts of electronic equipment are coupled to each other. For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front side bus (FSB), hypertransport (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 910 may include one or more buses. Although the embodiment of the present invention describes and shows a specific bus, the present invention considers any suitable bus or interconnection.
[0146] The electronic device can execute the image compression method in the embodiment of the present application, thereby realizing the combination Figure 2 and Figure 8 The invention describes an image compression method and an image compression device.
[0147] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the image compression method in the above embodiment can be implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. Among them, the above-mentioned computer-readable storage medium may include a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc., which is not limited here.
[0148] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application-specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Computer-readable medium" can include any medium capable of storing or transmitting information. Examples of computer-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.
[0149] According to an embodiment of the present application, the computer-readable storage medium may be a non-transitory computer-readable storage medium.
[0150] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.
[0151] The above reference is according to the method of the embodiment of the present application, the flow chart of the device (system) and the computer program product and / or the block diagram described various aspects of the present application.It should be understood that each square box in the flow chart and / or the block diagram and the combination of each square box in the flow chart and / or the block diagram can be realized by computer program instructions.These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the realization of the function / action specified in one or more square boxes of the flow chart and / or the block diagram.Such a processor can be but is not limited to a general-purpose processor, a special-purpose processor, a special application processor or a field programmable logic circuit.It can also be understood that each square box in the block diagram and / or the flow chart and the combination of the square boxes in the block diagram and / or the flow chart can also be realized by the dedicated hardware that performs the specified function or action, or can be realized by the combination of dedicated hardware and computer instructions.
[0152] According to the embodiments described above in the present application, these embodiments do not describe all the details in detail, nor do they limit the present application to the specific embodiments described. Obviously, many modifications and changes can be made based on the above description. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present application, so that those skilled in the art can make good use of the present application and the modifications based on the present application. The present application is limited only by the claims and their full scope and equivalents.
Claims
1. An image compression method, characterized in that: include: Dividing the original image into a plurality of original compressed blocks, each of which includes a plurality of pixels; Identifying a first compressed block to be processed from the plurality of original compressed blocks, the first compressed block to be processed comprising two monochrome pixels, and the pixels of different monochromes in the first compressed block to be processed are arranged in a first direction, and the pixels of the same monochrome are arranged in a second direction, and one of the first direction and the second direction is a row direction, and the other is a column direction; Adjusting at least one monochrome pixel in the first to-be-processed compressed block to obtain a first target compressed block, so that a plurality of pixels in the first target compressed block are all in a target monochrome; compressing the first target compressed block; The method further comprises: A second compressed block to be processed is identified from the plurality of original compressed blocks, the second compressed block to be processed is adjacent to the first compressed block to be processed in the second direction, the second compressed block to be processed includes two single-color pixels and at least one mixed-color pixel, in the second direction, the two single-color pixels in the second compressed block to be processed are located between the first compressed block to be processed and the mixed-color pixels, the two single-color pixels of the pixels of the second compressed block to be processed are the same as the two single-color pixels of the pixels of the first compressed block to be processed, and the arrangement rule of the colors of the two single-color pixels in the second compressed block to be processed is the same as the arrangement rule of the colors of the two single-color pixels in the first compressed block to be processed; Adjusting at least one monochrome pixel in the second to-be-processed compressed block to obtain a second target compressed block, so that a plurality of pixels other than the mixed-color pixels in the second target compressed block are all in the target monochrome; The second target compressed block is compressed.
2. The method according to claim 1, characterized in that The two monochromatic colors presented by the pixels of the first compressed block to be processed include a first monochromatic color and a second monochromatic color, the target monochromatic color includes the second monochromatic color, and the adjusting of at least one monochromatic color pixel in the first compressed block to be processed to obtain a first target compressed block includes: The color of the pixels in the first to-be-processed compressed block is replaced from the first monochrome color to the second monochrome color to obtain a first target compressed block.
3. The method according to claim 2, characterized in that The step of replacing the color of the pixels in the first compressed block to be processed from the first monochrome color to the second monochrome color comprises: The grayscale value of the first monochrome pixel in the first compressed block to be processed is adjusted to be the same as the grayscale value of the second monochrome pixel in the first compressed block to be processed.
4. The method according to claim 2, characterized in that: The sensitivity of the human eye to the second monochromatic color is lower than the sensitivity of the human eye to the first monochromatic color.
5. The method according to claim 2, characterized in that: The first single color is red, and the second single color is blue; or, the first single color is green, and the second single color is red; or, the first single color is green, and the second single color is blue.
6. The method according to claim 1, characterized in that The original compressed block includes i×j pixels, i represents the number of pixel rows, and j represents the number of pixel columns; When the first direction is a row direction, i≥2, j=2; When the first direction is the column direction, i=2, j≥2.
7. An image compression device, characterized in that: include: A compression block division module, used for dividing the original image into a plurality of original compression blocks, wherein the original compression blocks include a plurality of pixels; an identification module, configured to identify a first compressed block to be processed from the plurality of original compressed blocks, wherein the first compressed block to be processed includes two monochrome pixels, and pixels of different monochromes in the first compressed block to be processed are adjacent in a first direction, and pixels of the same monochrome are adjacent in a second direction, and one of the first direction and the second direction is a row direction, and the other is a column direction; an adjustment module, configured to adjust at least one monochrome pixel in the first compressed block to be processed to obtain a first target compressed block, so that a plurality of pixels in the first target compressed block are all in a target monochrome; A compression module, used for compressing the first target compression block; The identification module is further used to identify a second compressed block to be processed from the multiple original compressed blocks, the second compressed block to be processed is adjacent to the first compressed block to be processed in the second direction, the second compressed block to be processed includes two single-color pixels and at least one mixed-color pixel, in the second direction, the two single-color pixels in the second compressed block to be processed are located between the first compressed block to be processed and the mixed-color pixels, the two single-color pixels of the pixels of the second compressed block to be processed are the same as the two single-color pixels of the pixels of the first compressed block to be processed, and the arrangement rule of the colors of the two single-color pixels in the second compressed block to be processed is the same as the arrangement rule of the colors of the two single-color pixels in the first compressed block to be processed; The adjustment module is further used to adjust at least one monochrome pixel in the second compressed block to be processed to obtain a second target compressed block, so that a plurality of pixels other than the mixed color pixels in the second target compressed block are all in the target monochrome; The compression module is further used to compress the second target compression block.
8. An electronic device, characterized in that: include: A processor and a memory storing computer program instructions, wherein the processor implements the image compression method according to any one of claims 1 to 6 when executing the computer program instructions.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the image compression method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Electronic tag display image processing method and device and computer equipment
CN114119784A
Image compression method, device and equipment and computer readable storage medium
CN114374847A
Digital image data coding method
CN1904943A