An adaptive redundancy-eliminating image compression encoding method
Through an adaptive image compression coding method that eliminates redundancy, and utilizing a priority assignment system and difference calculation within a four-square grid, the problems of low compression efficiency and frequent updates of the color coding library in the existing technology are solved, achieving efficient image compression and storage space saving.
Patent Information
- Application Number
- CN202510209073.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-25
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2045-02-25
AI Technical Summary
Existing image compression technology has problems such as low compression efficiency, the need for frame-by-frame color coding query and frequent updates of the color coding library, and is unable to adapt to the emergence of new video types.
An adaptive image compression coding method with redundancy elimination is adopted. By constructing a different priority assignment system within a four-square grid, the real value of the pixel point is calculated, and the difference between the color coding sequence number and value is calculated to generate a compressed data file.
Significantly reduce the total number of pixels in the image frame, halve the amount of color coding, improve the compression rate of the image frame, and save storage space.
Smart Images

Figure CN120050423B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image coding, in particular to an image compression coding method for adaptive redundancy elimination. BACKGROUND
[0002] There is a large amount of redundant information in videos or images, such as spatial redundancy, temporal redundancy, visual redundancy, and coding redundancy, which provides the possibility for video compression, and is widely used in the fields of television and video.
[0003] Existing image or video compression is usually based on YUV, NV21, etc. color coding, such as video compression based on YUV coding, which is a highly efficient and widely used video data processing method; by taking full advantage of the characteristics of YUV color space and the redundant information in video signals, through intra-frame and inter-frame prediction compression and entropy coding, etc., effective compression of video data is realized.
[0004] The patent with publication number CN118714330A designs WHV color coding, which effectively reduces the number of colors.
[0005] The patent with publication number CN119299711A designs HCV color coding, which is an improvement on WHV color coding. Although these two methods can effectively reduce the number of colors, they still have the following problems:
[0006] 1. A large amount of video data needs to be collected, but it is impossible to exhaust all videos. When a new video type appears, the color coding library needs to be retrained.
[0007] 2. Color coding query is required for each frame during video or image compression, which still has the problem of low compression efficiency.
[0008] 3. How to build a color coding library is described, but how to compress images is not disclosed. SUMMARY
[0009] In view of the deficiencies of the existing methods, the present application solves the problem of further improving the image compression rate.
[0010] The technical solution adopted by the present application is: an image compression coding method for adaptive redundancy elimination includes the following steps:
[0011] Step 1, obtaining an image frame;
[0012] Step two, taking a pixel point in the image frame as a base point, constructing a four-square grid with the base point as the center, setting different priorities for non-base points in the four-square grid; according to the priority of the non-base point, the relationship between the pixel value of the non-base point and the pixel value of the base point, assigning different base point real values; in this way, the base point real value of the next base point is calculated, and the process is repeated until all pixel points are traversed, obtaining a first matrix composed of real values of all pixel points;
[0013] Step two specifically includes:
[0014] When the pixel value of the first priority non-base point is equal to the pixel value of the base point, the base point position is assigned a first real number;
[0015] Otherwise, it is judged whether the pixel value of the second priority non-base point is equal to the pixel value of the base point, and the base point position is assigned a second real number when equal; otherwise,
[0016] It is judged whether the pixel value of the third priority non-base point is equal to the pixel value of the base point, and the base point position is assigned a third real number when equal; otherwise,
[0017] The base point position is assigned a fourth real number;
[0018] Step three, adding the corresponding pixel value to the pixel point of the fourth real number in the first matrix to obtain a second matrix; performing step four on the second matrix for base point real value calculation; otherwise, step five is performed;
[0019] Step four, calculating the base point real value of the second matrix;
[0020] Specifically includes:
[0021] Taking the pixel point of the fourth real number in the second matrix as a reference point, constructing a four-square grid with the reference point as the center, and assigning different reference point real values according to the relationship between the maximum pixel value of the fourth real number and the maximum pixel value of the non-reference point of different priorities; in this way, the base point real value of the next reference point is calculated, and the process is repeated until all reference points are traversed, constructing a third matrix composed of real values of all pixel points;
[0022] As a preferred embodiment of the present application, assigning different reference point real values according to the relationship between the maximum pixel value of the fourth real number and the maximum pixel value of the non-reference point of different priorities includes:
[0023] Step 41, obtaining the maximum pixel value of the reference point and the corresponding pixel channel;
[0024] As a preferred embodiment of the present application, the formula of the maximum pixel value is:
[0025] max_rgb=max(r i ,g i ,b i );
[0026] Among them, r i ,g i ,b i Represents the pixel values of r, g, and b channels respectively; max() is the maximum value function.
[0027] Step 42: The maximum pixel value of the reference point and the corresponding pixel channel remain unchanged, and the pixel values of the remaining pixel channels of the reference point are converted into the maximum pixel value minus the original pixel values of the remaining channels, thereby obtaining the extended maximum pixel value of the reference point.
[0028] As a preferred embodiment of the present invention, extending the maximum pixel value includes:
[0029] When the reference point RGB i When the maximum pixel value is the pixel value of the r channel, the maximum pixel value RGB is expanded 1 i is (max(r i ),max(r i )-g i ,max(r i )-b i );
[0030] When the maximum pixel value in the reference point RGB is the pixel value of the g channel, the maximum pixel value RGB is expanded 1 i (max(g i )-r i ,max(g i ),max(g i )-b i );
[0031] When the maximum pixel value in the reference point RGB is the pixel value of the b channel, the maximum pixel value RGB is expanded 1 i is (max(b i )-r i ,max(b i )-r i ,max(b i )-b i );
[0032] Among them, r i ,g i ,b i Represents the pixel values of r, g, and b channels respectively.
[0033] Step 43: Calculate the maximum extended pixel value of non-reference points in the four-square grid;
[0034] Step 44, setting different priorities for non-reference points in the four-square grid, and assigning different reference point real values according to the priorities of the non-reference points and the relationship between the extended maximum pixel value of the non-reference points and the extended maximum pixel value of the reference points; and iteratively calculating the reference point real value of the next reference point until all reference points are traversed, to obtain a third matrix composed of real values of all pixel points;
[0035] As a preferred embodiment of the present application, step 44 specifically includes:
[0036] When the first-priority non-reference point has the same channel as the maximum pixel value of the reference point and the remaining two channel pixel values are also equal, the reference point is assigned a fifth real value; otherwise,
[0037] When the second-priority non-reference point has the same channel as the maximum pixel value of the reference point and the remaining two channel pixel values are also equal, the reference point is assigned a sixth real value; otherwise,
[0038] When the third-priority non-reference point has the same channel as the maximum pixel value of the reference point and the remaining two channel pixel values are also equal, the reference point is assigned a seventh real value; otherwise,
[0039] The reference point is still the fourth real value;
[0040] And the maximum channel pixel value of the reference point is stored in the first container.
[0041] Step five, extracting pixel values at positions of different real values and the fourth real value; color encoding the pixel values to obtain color encoding serial number values and color encoding values; and calculating the difference between the color encoding serial number values and the color encoding values;
[0042] As a preferred embodiment of the present application, step five specifically includes:
[0043] Step 51, constructing a second container and a third container, and storing the first to seventh real values or the first to fourth real values of the pixel points in the third matrix in the second container, and storing the pixel values of the pixel points at the positions of the fourth real value in the third container;
[0044] Step 52, constructing a fourth container and a fifth container, and color encoding the pixel points at the positions of the fourth real value in the third container; storing the color encoding serial number values in the fourth container and the corresponding color encoding values in the fifth container;
[0045] As a preferred embodiment of the present application, the color encoding includes YUV, NV21, WHV, and HCV.
[0046] Step 53, difference calculation is performed between each color coding serial number value in the fourth container and the first dynamic threshold value, to obtain the absolute value of the color coding serial number value and store it in the sixth container; the difference value symbol of the color coding serial number value is positive, and the eighth real number is assigned, and the ninth real number is assigned when it is negative, and it is stored in the seventh container;
[0047] Step 54, difference calculation is performed between each color coding value in the fifth container and the second dynamic threshold value, to obtain the absolute value of the color coding value and store it in the eighth container; the difference value symbol of the color coding value is positive, and the eighth real number is assigned, and the ninth real number is assigned when it is negative, and it is stored in the ninth container;
[0048] As a preferred embodiment of the present application, the range of the first dynamic threshold value is:
[0049] The number of color coding serial number values / 2<= the number of absolute values of color coding serial number values< the number of color coding serial number values;
[0050] The range of the second dynamic threshold value is:
[0051] The number of color coding values / 2<= the number of absolute values of color coding values< the number of color coding values.
[0052] Step 55, the real numbers of the first container, the sixth container, the seventh container, the eighth container, the ninth container and the third matrix are generated into compressed data files;
[0053] As a preferred embodiment of the present application, when the third matrix is equal to the second matrix in step 55, the compressed data file is the real numbers of the sixth container, the seventh container, the eighth container, the ninth container and the second matrix.
[0054] Step 56, compressed stream generation is performed on a certain to-be-compressed data file of a certain frame image;
[0055] As a preferred embodiment of the present application, step 56 specifically includes:
[0056] Step 561, an initial fixed code container library is set, and a to-be-compressed data file Y ’ is obtained ’ max When Y ’ max is greater than 4, Y ’ max is taken as the serial number end value of the initial fixed code container library, zero is taken as the serial number start value of the initial fixed code container library, the serial number start value and the serial number end value are sorted in ascending order, and the serial number corresponding to the serial number coding is set; the value in Y ’ is placed in the tenth container; otherwise, when Y ’ max is between 1 and 4, step 562 is executed;
[0057] Step 562, adjacent value splicing with a step of 2 is performed on the values in Y ’ ; the maximum value Y in all spliced adjacent values is obtained max , Y max is taken as the initial fixed code container library sequence number end value, zero is taken as the initial fixed code container library sequence number start value, the sequence number start value and the sequence number end value are sorted in ascending order, and the sequence number corresponding sequence number code is set; all spliced adjacent values are placed in the tenth container;
[0058] As a preferred embodiment of the application, adjacent value splicing includes:
[0059] When the maximum value Y ’ max is 1, Y i = (Y ’ 2i-1 <<1) | Y ’ 2i ;
[0060] When Y ’ max is 2 or 3, Y i = (Y ’ 2i-1 <<2) | Y ’ 2i ;
[0061] When Y ’ max is 4, Y i = (Y ’ 2i-1 <<4) | Y ’ 2i ;
[0062] Wherein, <<1 represents left shift one bit; <<2 represents left shift two bits; <<4 represents left shift four bits; Y i is the ith spliced adjacent decimal value; Y ’ 2i-1 is the binary value in the 2i-1th compressed data file; Y ’ 2i is the binary value in the 2i th compressed data file;
[0063] Step 563, an array X 1 1,2 is constructed with the values of the first and second positions in the tenth container; it is judged whether X 1 1,2 exists in the initial fixed code container library, if not, X 1 1,2is the serial number, the corresponding serial number code is assigned, and is placed after the last serial number in the initial fixed code container library; and the second and third values in the tenth container are used to construct array X 2 2,3 X is judged 2 2,3 in the initial fixed code container library, and iteration is continuously performed until all values in the tenth container are traversed
[0064] If X 1 1,2 exists in the initial fixed code container library, array X is constructed using the first three values in the tenth container 1 1,2,3 X is judged 1 1,2,3 in the initial fixed code container library; if X does not exist, the serial number is taken as X 1 1,2,3 is placed after the last serial number in the initial fixed code container library, and the corresponding serial number code is assigned; if X exists, array X is constructed using the first four values in the tenth container 1 1,2,3,4 X is judged 1 1,2,3,4 in the initial fixed code container library, and iteration is continuously performed until all values in the tenth container are traversed 。
[0065] Advantages of the present application:
[0066] 1. The pixel points in the image frame are preliminarily assigned the same pixel values in a four-quadrant grid, and then the maximum channel value is compared, so that the total number of pixel points in the image frame is significantly reduced, the subsequent color coding amount is greatly reduced, the compression rate of the image frame is improved, and storage space is saved.
[0067] 2. The color coding serial number value and the color coding value after color coding are halved, further improving the compression rate of the image frame. BRIEF DESCRIPTION OF DRAWINGS
[0068] Figure 1 is a flow chart of the adaptive redundancy elimination image compression coding method of the present application;
[0069] Figure 2 is a four-quadrant diagram of the image frame of the present application;
[0070] Figure 3 is a first matrix diagram of the present application;
[0071] Figure 4 is a second matrix diagram of the present application;
[0072] Figure 5 is a third matrix diagram of the present application;
[0073] Figure 6 is a second, third container schematic diagram of the present application;
[0074] Figure 7 is a fourth, fifth container schematic diagram of the present application;
[0075] Figure 8 is a schematic diagram of a specific example of the fourth, fifth container of the present application. DETAILED DESCRIPTION
[0076] The present application will be further described below in conjunction with the accompanying drawings and examples, which are simplified schematic diagrams and only schematically illustrate the basic structure of the present application, and thus only show the components related to the present application.
[0077] As shown in Figure 1 , an image compression encoding method for adaptive elimination of redundancy comprises the following steps:
[0078] Step one, obtaining an image frame;
[0079] The image frame is derived from an image or a video, and the video is divided into a plurality of image frames according to the frame rate; the image frame is processed.
[0080] RGB i is the i-th pixel point of the image frame, and the corresponding pixel value is (r i ,g i ,b i ), r i ,g i ,b i represent the pixel values of r, g, and b channels respectively; the first pixel point is denoted as RGB1, and the value of the first pixel point is (r1, g1, b1);
[0081] Step two, taking a certain pixel point in the image frame as a base point, constructing a four-square grid centered on the base point, and setting different priorities for the non-base points in the four-square grid; assigning different base point real values according to the priorities of the non-base points, the relationship between the pixel values of the non-base points and the pixel value of the base point; and similarly, calculating the base point real value of the next base point until all pixel points are traversed, obtaining a first matrix A composed of the real values of all pixel points;
[0082] The different priorities include a first priority, a second priority, and a third priority, wherein the first priority has the highest level, the second priority is next, and the third priority is the lowest.
[0083] The four-square grid is based on the base point, and the three pixel points adjacent to the base point are non-base points; the four-square grid is based on the position of the base point, and the four-square grid of the base point can be divided into left-up, right-up, left-down, and right-down.
[0084] Step two specifically comprises:
[0085] When the pixel value of the first priority non-base point is equal to the pixel value of the base point, the base point position is assigned a first real number I;
[0086] Otherwise, determine whether the pixel value of the second priority non-base point is equal to the pixel value of the base point. If they are equal, assign the second real number J to the base point position; otherwise,
[0087] When judging whether the pixel value of the third priority non-base point is equal to the pixel value of the base point, if they are equal, the base point position is assigned a third real number K; otherwise,
[0088] The base point position is assigned a fourth real number L.
[0089] The real numbers I, J, K, and L are unequal natural numbers, for example, I=1, J=2, K=3, and L=4;
[0090] like Figure 2 As shown, the image frame has a resolution of 8*8 and a total of 64 pixels; 11 As the base point, the upper left four squares are RGB2, RGB3, RGB 10 , RGB 11 , in RGB 11 As the base point, the four squares on the upper right are RGB3, RGB4, RGB 11 , RGB 12 ; The four grids on the lower left and lower right are no longer enumerated;
[0091] RGB 11 For example, the upper left four squares of the image have the corresponding non-base points of RGB3, RGB2, RGB 10 ; in RGB 11 RGB3, RGB2, RGB 10 Set the first, second, and third priority respectively, or set the priority order to RGB2, RGB3, RGB 10 , other priority orders are no longer enumerated;
[0092] RGB3, RGB2, RGB 10 For example, due to RGB 11 With RGB2, RGB3, RGB 10 The pixel values are not equal, so RGB 11 Assign the fourth real number L;
[0093] Similarly, RGB 12 As the base point, RGB3, RGB4, RGB 11 For the priority order, get RGB 12 Assign the first real number I;
[0094] Similarly, the next base point is found in any of the remaining 62 pixel points, until all pixel points are assigned with corresponding real numbers, to obtain the first matrix A as shown in the figure. Figure 3
[0095] Step three, the pixel point marked as the fourth real number L in the first matrix A is added with the corresponding pixel value to obtain the second matrix B.
[0096] As shown in the second matrix B, the positions corresponding to the first real number I, the second real number J, and the second real number K in the first matrix A remain unchanged, and the pixel point of the fourth real number L retains the corresponding pixel value. Figure 4
[0097] When the third matrix C constructed is the same as the second matrix B; that is, without assigning real values to the base points through the four-quadrant of step four, directly using the second matrix B to calculate step five;
[0098] Step four, taking the pixel point of the fourth real number L in the second matrix B as the base point, constructing a four-quadrant with the base point as the center, and assigning different base point real values according to the relationship between the maximum pixel value of the fourth real number and the maximum pixel value of the different priority non-base points; similarly, the base point real value of the next base point is calculated, until all base points are traversed, to construct the third matrix C composed of real values of all pixel points.
[0099] The setting of the four-quadrant is the same as step two and will not be repeated; the base point is Figure 4 the pixel point of the fourth real number L in the second matrix.
[0100] Step four specifically includes:
[0101] Step 41, obtaining the maximum pixel value of the base point and the corresponding pixel channel; the formula of the maximum pixel value is:
[0102] max_rgb=max(r i ,g i ,b i );
[0103] Wherein, r i ,g i ,b i represent the pixel values of r, g, and b channels respectively; max() is the maximum value function.
[0104] That is, the maximum value in the RGB three channels is taken; when max_rgb=max(r i ), r i ≥g i and r i ≥b i , that is, the maximum pixel value of the base point is r i The corresponding pixel channel is r; similarly, when max_rgb = max(g i ), g i ≥ r i and g i ≥ b i ; when max_rgb = max(b i ), b i ≥ r i and b i ≥ g i ;
[0105] Step 42, the maximum pixel value of the reference point and the corresponding pixel channel remain unchanged, and the pixel value of the remaining pixel channel of the reference point becomes the maximum pixel value minus the original pixel value of the remaining channel, to obtain the extended maximum pixel value of the reference point;
[0106] When the maximum pixel value in the reference point RGB i is the pixel value of the r channel, the extended maximum pixel value RGB 1 i is (max(r i ), max(r i )-g i , max(r i )-b i );
[0107] When the maximum pixel value in the reference point RGB is the pixel value of the g channel, the extended maximum pixel value RGB 1 i is (max(g i )-r i , max(g i ), max(g i )-b i );
[0108] When the maximum pixel value in the reference point RGB is the pixel value of the b channel, the extended maximum pixel value RGB 1 i is (max(b i )-r i , max(b i )-r i , max(b i )-b i );
[0109] Step 43, calculate the extended maximum pixel value of the non-reference point in the four-square grid;
[0110] Using the similar method of step 42, the extended maximum pixel value of the non-reference point is obtained;
[0111] Step 44, set different priorities for non-reference points in the four-square grid, and assign different reference point real values according to the priorities of the non-reference points and the relationship between the extended maximum pixel value of the non-reference point and the extended maximum pixel value of the reference point; in this way, the reference point real value of the next reference point is calculated, and this process is repeated until all reference points are traversed, and a third matrix C composed of real values of all pixel points is obtained;
[0112] Step 44 specifically includes:
[0113] When the first priority non-reference point has the same channel as the maximum pixel value of the reference point and the pixel values of the remaining two channels are also equal, the reference point is assigned a fifth real number O; and the maximum channel pixel value max_rgb of the reference point is stored in the first container CONT1; otherwise,
[0114] When the second priority non-reference point has the same channel as the maximum pixel value of the reference point and the pixel values of the remaining two channels are also equal, the reference point is assigned a sixth real number P; and the maximum channel pixel value max_rgb of the reference point is stored in the first container CONT1; otherwise,
[0115] When the third priority non-reference point has the same channel as the maximum pixel value of the reference point and the pixel values of the remaining two channels are also equal, the reference point is assigned a seventh real number Q; and the maximum channel pixel value max_rgb of the reference point is stored in the first container CONT1; otherwise,
[0116] The reference point is still the fourth real number L;
[0117] By analogy, the real value assignment of all reference points is completed.
[0118] The third matrix C is constructed with the fourth real number L, the fifth real number O, the sixth real number P, and the seventh real number Q; wherein the real numbers O, P, and Q are unequal custom natural numbers, for example, O=5, P=6, and Q=7;
[0119] The third matrix C is constructed with the fourth real number L, the fifth real number O, the sixth real number P, and the seventh real number Q; wherein the real numbers O, P, and Q are unequal custom natural numbers, for example, O=5, P=6, and Q=7; Figure 4 The RGB 10 is the reference point, and the pixel value of RGB 10 is (10, 20, 9), max_rgb=20, and the corresponding g channel is the maximum pixel value, so the extended maximum pixel value RGB 1 10 is (max(g i )-r i , max(g i ), max(g i )-b i )=(10, 20, 11);
[0120] The first priority of non-reference points is RGB2(10,20,8), max_rgb=20, corresponding to the maximum pixel value of the g channel, and the maximum pixel value RGB is expanded 1 2 is (10,20,12); although RGB 1 10 with RGB 1 2 are both the g channel is the maximum pixel value, but the b channel in the remaining r and b channels are not equal; then judge the second priority RGB1 of the non-reference point and expand the maximum pixel value RGB 1 1 is (10, 20, 12), which also does not meet the conditions; then judge the third priority RGB9 of the non-reference point and expand the maximum pixel value RGB 1 9 is (10, 21, 9), and the g channel is the maximum pixel value for both RGB2 and the remaining r and b channels are equal, so the position of RGB2 is assigned the seventh real number Q; Figure 5 This is a schematic diagram of the third matrix C.
[0121] The total amount of colors of several frames of images in different scenes is statistically analyzed, and the results in Table 1 are obtained;
[0122] Table 1 Comparison of the total amount of colors in the third matrix and the total amount of original colors
[0123] Scene type File size (MB) Total amount of original color Total amount of third matrix color Reduction rate High dynamic 23.7 8294400 345907 95.82% High overall color 23.7 8294400 839939 89.87% High complex scene 23.7 8294400 4689442 43.46% High grain 23.7 8294400 952792 88.51% High transition color 23.7 8294400 309996 96.26% High character detail 23.7 8294400 700782 91.55%
[0124] Table 1 is a statistical comparison of colors in six different scenes. In the 23.7M file of several image frames, the third matrix color is compared with the original color. It can be seen that the total color reduction rate exceeds 95% under high dynamic scenes and high transition color conditions. Even in highly complex scenes, the total color reduction rate is close to 50%, which greatly reduces the subsequent color encoding amount, improves the compression rate of the image frame, and saves storage space.
[0125] Step 5: extract pixel values at different real numbers and the fourth real number position; perform color coding on the pixel values to obtain a color coding sequence number value and a color coding value; perform difference calculation on the color coding sequence number value and the color coding value;
[0126] Step 5 specifically includes:
[0127] Step 51: Construct a second container CONT2 and a third container CONT3. Store the first real number I, the second real number J, the third real number K, the fourth real number L, the fifth real number O, the sixth real number P, and the seventh real number Q at the corresponding positions of the pixel points in the third matrix C into the second container CONT2. Store the pixel value at the corresponding position of the pixel point with the fourth real number L into the third container CONT3. The pixel values of the pixel points at positions other than the fourth real number are separated by a delimiter, which can be " / " or other delimiters.
[0128] When the third matrix C is the second matrix B, the pixel point corresponding position in the third matrix C is the first real number I, the second real number J, the third real number K and the fourth real number L.
[0129] The second container CONT2 and the third container CONT3 are both one-dimensional linear containers; for example Figure 6 The second container and the third container are shown.
[0130] Step 52, constructing the fourth container CONT4 and the fifth container CONT5, color coding the pixel point at the fourth real number position in the third container CONT3; storing the color coding serial number value into the fourth container CONT4, and the corresponding color coding value into the fifth container CONT5;
[0131] The color coding can use YUV, NV21 coding library; or WHV, HCV coding library;
[0132] Taking the WHV coding library as an example, RGB i The WHV coding serial number value C of the pixel value d And the corresponding color coding value W d H d V d ; wherein d is the serial number of the WHV coding library, W d H d V d is the pixel coordinate of the WHV coding library; the color coding position and the corresponding color coding value are determined by using the color coding library, and other color coding libraries are also applicable to the present application; for example Figure 7 The fourth container and the fourth container are shown; the subscript n is the maximum value of the serial number of the WHV coding library.
[0133] As shown in Figure 8 , the image pixel coordinate of the fourth real number L in Figure 6 is WHV color coded to obtain the values in the fourth container and the fifth container corresponding to Figure 7 , Figure 6 The pixel value (10, 20, 8) in corresponds to the WHV coding serial number value 100, and the corresponding color coding value is (3, 3, 4);
[0134] Step 53, difference calculation is performed on each color coding serial number value in the fourth container CONT4 and the first dynamic threshold to obtain the absolute value of the color coding serial number value, which is stored in the sixth container CONT6; the difference symbol of the color coding serial number value is positive, and the eighth real number Z is assigned, and the ninth real number X is assigned when the difference symbol is negative, which is stored in the seventh container CONT7;
[0135] Step 54, difference calculation of each color coding value in the fifth container CONT5 and the second dynamic threshold value, to obtain the absolute value of the color coding value and store it in the eighth container CONT8; the difference value of the color coding value is positive, assign the eighth real number Z, and negative, assign the ninth real number X, and store it in the ninth container CONT9;
[0136] Wherein, the range of the first dynamic threshold value a is:
[0137] The number of color coding sequence values / 2 <= the number of absolute values of color coding sequence values < the number of color coding sequence values;
[0138] Wherein, the range of the second dynamic threshold value b is:
[0139] The number of color coding values / 2 <= the number of absolute values of color coding values < the number of color coding values;
[0140] For example: the color coding sequence value is 100, 200, 400, 500, and the number of color coding sequence values is 4; when the first dynamic threshold value a = 300, the difference value of the color coding sequence value and the first dynamic threshold value is -200, -100, 100, 200, and the absolute value is 200, 100, 100, 200. The number of corresponding absolute values of color coding sequence values is 2, that is, 100 and 200. For example, the first dynamic threshold value can also be 150, and the number of corresponding absolute values of color coding sequence values is 3, that is, 50, 250, and 350. The optimal value is 2, that is, the color coding sequence value is halved, effectively reducing the range of color coding sequence value.
[0141] Similarly, the value of the second dynamic threshold value is obtained.
[0142] Step 55, generating compressed data files of the real numbers of the first container CONT1, the sixth container CONT6, the seventh container CONT7, the eighth container CONT8, the ninth container CONT9 and the third matrix C;
[0143] That is, 6 compressed data files are generated; if the third matrix C is equal to the second matrix B, there is no first container.
[0144] Step 56, generating a compressed stream for a certain compressed data file of a certain frame image;
[0145] Step 56 specifically includes:
[0146] Step 561, setting an initial fixed code container library, obtaining the maximum value Y ’ in a certain compressed data file Y ’ max When the maximum value Y ’ max is greater than 4, the maximum value Y’ max The serial number end value of the initial fixed code container library is set to zero, and the serial number start value and the serial number end value are sorted in ascending order, and the serial number code corresponding to the serial number is set; the data file to be compressed Y ’ The value in is placed into the tenth container CONT 10 Otherwise, when the maximum value Y ’ max If it is between 1 and 4, execute step 562;
[0147] For example, the data file to be compressed is Y ’ is (1, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 7, 8, 9, 10), the maximum value Y ’ max =10, then the initial fixed code container library is {0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:10}; where the value before the colon is the sequence number of the initial fixed code container library, and the value after the colon is the sequence number code of the initial fixed code container library.
[0148] Step 562: concatenate the adjacent values of the data file to be compressed with a step length of 2; obtain the maximum value Y among all the concatenated adjacent values. max , with the maximum value Y max The serial number end value of the initial fixed code container library is zero, and the serial number start value and the serial number end value are in ascending order, and the serial number code corresponding to the serial number is set; all the adjacent values after splicing are placed in the tenth container CONT 10 middle;
[0149] When the value in the data file to be compressed is an odd number, add one digit at the end and fill it with 0;
[0150] For example, if the data file to be compressed is [1, 1, 2, 3, 1, 2, 3, 3, 2, 2, 3, 1, 2, 3, 2, 1, 2], there are 17 values in total. If it is an odd number, the first container will be [1, 1, 2, 3, 1, 2, 3, 3, 2, 2, 3, 1, 2, 3, 2, 1, 2, 0]; if it is an even number, it remains unchanged.
[0151] Adjacent value concatenation includes:
[0152] When the maximum value Y ’ max When Y is 1, i =(Y ’ 2i-1 <<1)|Y ’ 2i ;
[0153] When the maximum value Y ’ max is 2 or 3, Y i = (Y ’ 2i-1 <<2) | Y ’ 2i ;
[0154] When the maximum value Y ’ max is 4, Y i = (Y ’ 2i-1 <<4) | Y ’ 2i ;
[0155] wherein, <<1 represents left shift one bit; <<2 represents left shift two bits; <<4 represents left shift four bits; Y i is the i-th spliced adjacent decimal value; Y ’ 2i-1 is the binary value in the 2i-1th compressed data file; Y ’ 2i is the binary value in the 2i-th compressed data file;
[0156] For example, the compressed data file is [1, 1, 2, 3, 1, 2, 3, 3, 2, 2, 3, 1, 2, 3, 2, 1, 2, 3], Y ’ max is 3, the first spliced adjacent value Y1 is the adjacent value splicing operation on Y ’ 1 and Y ’ 2; Y ’ 1 = 1, Y ’ 2 = 1, Y1 = 0100 | 0001 = 5 is obtained; similarly, Y2 = (1000 | 0011) = 11; in this way, all the spliced adjacent values are (5, 11, 6, 15, 10, 13, 11, 9, 11), that is, the tenth container; wherein, Y max= 15, the initial fixed code container library is {0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:10, 11:11, 12:12, 13:13, 14:14, 15:15}; wherein, the value before the colon is the serial number of the initial fixed code container library, and the value after the colon is the serial number code of the initial fixed code container library; 0:0 indicates that the serial number of the initial fixed code container library is 0, and the corresponding serial number code is 0; in steps 561 and 562, the serial number code in the initial fixed code container library can also be different from the serial number, and different numerical values and / or character combinations are adopted; for example, the initial fixed code container library is {0:a, 1:b, 3:c, 2:d, 4:e, 5:f, 6:g, 7:j, 8:h, 9:l, 10:o, 11:p, 12:q, 13:13, 14:14, 15:15}.
[0157] Step 563, constructing an array X with the values of the first and second bits in the tenth container 1 1,2 , judging whether X 1 1,2 is in the initial fixed code container library, if not, placing X 1 1,2 as the serial number after the last serial number in the initial fixed code container library, and assigning the corresponding serial number code; and then constructing an array X 2 2,3 with the values of the second and third bits in the tenth container, judging whether X 2 2,3 is in the initial fixed code container library, and continuously iterating until all values in the tenth container are traversed.
[0158] If X 1 1,2 exists in the initial fixed code container library, constructing an array X 1 1,2,3 with the values of the first three bits in the tenth container, judging whether X 1 1,2,3 is in the initial fixed code container library; if not, placing X 1 1,2,3 as the serial number after the last serial number in the initial fixed code container library, and assigning the corresponding serial number code; if exists, constructing an array X 1 1,2,3,4 with the values of the first four bits in the tenth container, and then judging whether X 1 1,2,3,4 is in the initial fixed code container library, and continuously iterating until all values in the tenth container are traversed.
[0159] For example, the value in the tenth container is [5, 11, 6, 5, 11, 12], the initial fixed code container library is {0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:10, 11:11, 12:12}, X 1 1,2 is (5, 11), (5, 11) does not exist in the initial fixed code container library, so the initial fixed code container library becomes {0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:10, 11:11, 12:12, (5, 11):13}; then judge X 2 2,3 is (11, 6), (11, 6) does not exist in the initial fixed code container library, so the initial fixed code container library becomes {0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:10, 11:11, 12:12, (5, 11):13, (11, 6):14}; then judge X 3 3,4 is (6, 5), (6, 5) does not exist in the initial fixed code container library, so the initial fixed code container library becomes {0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:10, 11:11, 12:12, (5, 11):13, (11, 6):14, (6, 5):15}; then judge X 4 5,6 is (5, 11), (5, 11) exists in the initial fixed code container library, so judge X 4 5,6,7 is (5, 11, 12), (5, 11, 12) does not exist in the initial fixed code container library, so the initial fixed code container library becomes {0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:10, 11:11, 12:12, (5, 11):13, (11, 6):14, (6, 5):15, (5, 11, 12):16}.
[0160] The generation of the initial fixed code container library of all compressed data files of all frames is completed, and the final initial fixed code container library is the compressed stream; the decompression process is the reverse process of steps one to five.
[0161] The compression rates of several frames of images under different scenes are counted, and the results of Table 2 are obtained;
[0162] Table 2 Comparison of compression rates of the method of the present application and zip method for different scenes
[0163] Scene type File size (MB) Image file compression rate (%) of zip method Image file compression rate (%) of the method of the present invention High dynamic 23.7 21.56 20.37 High overall color 23.7 83.60 68.64 High complex scene 23.7 49.86 39.89 High grain 23.7 19.18 18.42 High transition color 23.7 1.74 1.36 High character detail 23.7 11.53 10.37
[0164] As shown in Table 2, the compression rate of high overall color and high complex scene is obviously improved by using the method of the present application, and the compression rate of other scenes is also improved to some extent.
[0165] The above is the ideal embodiment according to the present application, and the above description can be changed and modified by the relevant staff without deviating from the technical idea of the present application. The technical scope of the present application is not limited to the content of the specification, and the technical scope must be determined according to the scope of claims.
Claims
1. An image compression coding method with adaptive redundancy elimination, characterized in that: The following steps are involved: Step 1: Acquire image frames; Step 2: Taking a pixel point in the image frame as a base point, construct a four-square grid with the base point as the center, and set different priorities for non-base points in the four-square grid; assign different base point real values according to the priority of the non-base point and the relationship between the pixel value of the non-base point and the pixel value of the base point; and so on, calculate the base point real value of the next base point, until all pixels are traversed, and obtain a first matrix composed of the real values of all pixels; When the pixel value of the first priority non-base point is equal to the pixel value of the base point, the base point position is assigned a first real number; When the pixel value of the second priority non-base point is equal to the pixel value of the base point, the base point position is assigned a second real number; When the pixel value of the third priority non-base point is equal to the pixel value of the base point, the base point position is assigned a third real number; otherwise, The position of the cardinal point is assigned a fourth real number; Step 3: Add the corresponding pixel value to the pixel point of the fourth real number in the first matrix to obtain a second matrix; When performing real value calculation of the reference point on the second matrix, execute step 4; Otherwise, go to step 5; Step 4: Calculate the second matrix to obtain the real value of the reference point; Step 5: extracting pixel values at different real numbers and the fourth real number position; The pixel value is color-coded to obtain a color coding sequence number value and a color coding value; and a difference calculation is performed on the color coding sequence number value and the color coding value.
2. The image compression coding method with adaptive redundancy elimination according to claim 1, characterized in that: Step four specifically includes: taking the pixel point of the fourth real number in the second matrix as the reference point, constructing a four-square grid with the reference point as the center, assigning different reference point real values according to the relationship between the maximum pixel value of the fourth real number pixel point and the maximum pixel value of non-reference points of different priorities; and so on, calculating the base point real value of the next reference point, until all reference points are traversed, and constructing a third matrix composed of the real values of all pixel points.
3. The image compression coding method with adaptive redundancy elimination according to claim 2, wherein: Assigning different reference point real values according to the relationship between the maximum pixel value of the fourth real number and the maximum pixel values of non-reference points of different priorities includes: Step 41: Obtain the maximum pixel value of the reference point and the corresponding pixel channel; Step 42: The maximum pixel value and the corresponding pixel channel of the reference point remain unchanged, and the pixel values of the remaining pixel channels of the reference point are converted into the maximum pixel value minus the original pixel values of the remaining channels, thereby obtaining the extended maximum pixel value of the reference point. Step 43: Calculate the maximum extended pixel value of non-reference points in the four-square grid; Step 44: Set different priorities for the non-reference points in the four-square grid, and assign different reference point real values according to the priority of the non-reference point and the relationship between the extended maximum pixel value of the non-reference point and the extended maximum pixel value of the reference point; and so on, calculate the reference point real value of the next reference point until all reference points are traversed to obtain a third matrix composed of the real values of all pixel points.
4. The image compression coding method with adaptive redundancy elimination according to claim 3, wherein: The formula for the maximum pixel value is: max_rgb=max(r i ,g i ,b i ); Among them, r i ,g i ,b i Represent the pixel values of the r, g, and b channels of the i-th pixel respectively; max() is the maximum value function.
5. The image compression coding method with adaptive redundancy elimination according to claim 3, characterized in that: Extended maximum pixel values include: When the reference point RGB i When the maximum pixel value is the pixel value of the r channel, the maximum pixel value RGB is expanded 1 i is (max(r i ),max(r i )-g i ,max(r i )-b i ); When the maximum pixel value in the reference point RGB is the pixel value of the g channel, the maximum pixel value RGB is expanded 1 i (max(g i )-r i ,max(g i ),max(g i )-b i ); When the maximum pixel value in the reference point RGB is the pixel value of the b channel, the maximum pixel value RGB is expanded 1 i is (max(b i )-r i ,max(b i )-r i ,max(b i )-b i ); Among them, r i ,g i ,b i Represents the pixel values of r, g, and b channels respectively.
6. The image compression coding method with adaptive redundancy elimination according to claim 3, characterized in that: Step 44 specifically includes: When the first priority non-reference point and the reference point have the same channel with the maximum pixel value and the remaining two channels have the same pixel values, the reference point is assigned the fifth real number; otherwise, When the second priority non-reference point has the same channel with the maximum pixel value of the reference point and the pixel values of the remaining two channels are also equal, the reference point is assigned the sixth real number; otherwise, When the third priority non-reference point has the same channel with the maximum pixel value of the reference point and the pixel values of the remaining two channels are also equal, the reference point is assigned the seventh real number; otherwise, The reference point is still the fourth real number; The maximum channel pixel value of the reference point is stored in the first container.
7. The image compression coding method with adaptive redundancy elimination according to claim 1, wherein: Step 5 specifically includes: Step 51: Construct a second container and a third container, store the first to seventh real numbers or the first to fourth real numbers corresponding to the pixel points in the third matrix into the second container, and store the pixel value corresponding to the fourth real number into the third container; Step 52: Construct a fourth container and a fifth container, perform color coding on the pixel at the fourth real number position in the third container; store the color coding sequence value in the fourth container, and store the corresponding color coding value in the fifth container; Step 53: Calculate the difference between each color-coded serial number value in the fourth container and the first dynamic threshold value to obtain the absolute value of the color-coded serial number value and store it in the sixth container; if the sign of the difference of the color-coded serial number value is positive, assign it to the eighth real number; if it is negative, assign it to the ninth real number and store it in the seventh container; Step 54: Calculate the difference between each color code value in the fifth container and the second dynamic threshold value to obtain the absolute value of the color code value and store it in the eighth container; if the sign of the difference of the color code value is positive, assign it to the eighth real number; if it is negative, assign it to the ninth real number and store it in the ninth container; Step 55: Generate compressed data files using the real numbers of the first container, the sixth container, the seventh container, the eighth container, the ninth container, and the third matrix respectively; Step 56: Generate a compression stream for a certain data file to be compressed of a certain frame image.
8. The image compression coding method with adaptive redundancy elimination according to claim 7, characterized in that: When the third matrix is equal to the second matrix in step 55 , the compressed data file is the real numbers of the sixth container, the seventh container, the eighth container, the ninth container, and the second matrix.
9. The image compression coding method with adaptive redundancy elimination according to claim 7, wherein: The range of the first dynamic threshold is: The number of color coding serial number values / 2=<the number of absolute values of color coding serial number values<the number of color coding serial number values; The range of the second dynamic threshold is: The number of color coding values / 2 <= the number of absolute values of color coding values < the number of color coding values.
10. The image compression coding method with adaptive redundancy elimination according to claim 7, characterized in that: Color encoding includes: YUV, NV21, WHV, HCV.
11. The image compression coding method with adaptive redundancy elimination according to claim 7, wherein: Step 56 specifically includes: Step 561: Set up the initial fixed code container library and obtain the data file Y to be compressed ’ Maximum value Y ’ max , when Y ’ max When it is greater than 4, Y ’ max The serial number end value of the initial fixed code container library is set to zero, and the serial number start value and the serial number end value are sorted in ascending order, and the serial number code corresponding to the serial number is set; Y ’ The value in is placed in the tenth container; otherwise, when Y ’ max If it is between 1 and 4, execute step 562; Step 562: Y ’ The values in are concatenated with a step length of 2; the maximum value Y among all the concatenated adjacent values is obtained. max , with Y max The sequence number end value of the initial fixed code container library is 0, and the sequence number start value and the sequence number end value are sorted in ascending order, and the sequence number code corresponding to the sequence number is set; all the concatenated adjacent values are placed in the tenth container; Step 563: Construct array X using the values of the first and second positions in the tenth container. 1 1,2 , judge X 1 1,2 Is it in the initial fixed code container library? If not, it will be replaced with X 1 1,2 Assign the corresponding serial number code to the serial number and put it after the last serial number in the initial fixed code container library; then construct the array X with the second and third values in the tenth container. 2 2,3 , judge X 2 2,3 Whether to iterate continuously in the initial fixed code container library until all values in the tenth container are traversed; If X 1 1,2 Existing in the initial fixed code container library, construct array X with the first three values in the tenth container 1 1,2,3 , judge X 1 1,2,3 Is it in the initial fixed code container library? If not, it will be replaced with X 1 1,2,3 is a serial number, placed after the last serial number in the initial fixed code container library, and assigned the corresponding serial number code; if it exists, construct the array X with the first four values in the tenth container 1 1,2,3,4 , then judge X 1 1,2,3,4 Whether to iterate continuously in the initial fixed code container library until all values in the tenth container are traversed.
12. The image compression coding method with adaptive redundancy elimination according to claim 11, characterized in that: Adjacent value concatenation includes: When the maximum value Y ’ max When Y is 1, i =(Y ’ 2i-1 <<1)|Y ’ 2i ; When Y ’ max When Y is 2 or 3, i =(Y ’ 2i-1 <<2)|Y ’ 2i ; When Y ’ max When Y is 4, i =(Y ’ 2i-1 <<4)|Y ’ 2i ; Among them, <<1 means left shift by one bit; <<2 means left shift by two bits; <<4 means left shift by four bits; Y i is the adjacent decimal value after the i-th splicing; Y ’ 2i-1 is the binary value in the 2i-1th compressed data file; Y ’ 2i It is the binary value in the 2i-th compressed data file.
Citation Information
Patent Citations
Color coding method based on vision
CN118714330A
Coding method based on color distribution
CN119299711A
Coding and decoding device, coding and decoding method and program
CN101543036A
Out-chip buffer compression method for superhigh-definition processing system
CN105472389A