Image compression coding method capable of adaptively eliminating redundancy
Through the adaptively eliminating redundancy image compression coding method, four grids are constructed and pixel points are given priority, which solves the problem of insufficient compression rate in the prior art, and realizes efficient image compression and saves storage space.
Patent Information
- Application Number
- CN202510209073.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-25
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2045-02-25
AI Technical Summary
Existing image or video compression technologies have shortcomings in improving compression rates, especially when dealing with emerging video classes, the color encoding library needs to be retrained, which has low compression efficiency.
The image compression and coding method that adaptively eliminates redundancy is adopted. By constructing four grids and assigning different priorities to pixel points, real values of base points are calculated, the total number of pixel points is reduced, and the compression rate is improved.
The number of pixel points in the image frame is significantly reduced, the subsequent color encoding amount is reduced, the compression rate of the image frame is improved, the storage space is saved, and the compression rate is further improved by halving the color encoding data.
Smart Images

Figure CN120050423A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image coding, and in particular to an image compression coding method for adaptively eliminating redundancy. Background Art
[0002] There is a large amount of redundant information in videos or images, such as spatial redundancy, temporal redundancy, visual redundancy and coding redundancy. These redundant information make video compression possible; it is widely used in television, video and other fields.
[0003] Existing image or video compression is usually based on color coding such as YUV and NV21. For example, video compression based on YUV coding is an efficient and widely used video data processing method. It makes full use of the characteristics of the YUV color space and the redundant information in the video signal, and realizes effective compression of video data through intra-frame and inter-frame prediction compression and entropy coding technologies. The patent with publication number CN118714330A designs WHV color coding, effectively reducing the number of colors; 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 have the following problems: 1. It is necessary to collect massive video data, but it is impossible to enumerate all videos. When new video types appear, the color coding library needs to be retrained; 2. When compressing videos or images, color coding queries need to be performed frame by frame, and there is still the problem of low compression efficiency; 3. It describes how to build a color encoding library, but does not disclose how to compress images. Summary of the invention
[0004] In view of the shortcomings of the existing methods, the present invention solves the problem that the image compression rate needs to be further improved.
[0005] The technical solution adopted by the present invention is: an image compression coding method for adaptively eliminating redundancy comprises the following steps: Step 1: Obtain image frames; Step 2: Taking a certain 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; assigning 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, calculating the base point real value of the next base point, until all pixel points are traversed to obtain a first matrix composed of the real values of all pixel points; Step 2 specifically includes: When the pixel value of the non-base point of the first priority is equal to the pixel value of the base point, the base point position is assigned the first real number; Otherwise, determine whether the pixel value of the second priority non-base point is equal to the pixel value of the base point, and if they are equal, assign the second real number to the base point position; otherwise, Determine 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, assign the third real number to the base point position; otherwise, The position of the cardinal point is assigned a fourth real number; Step 3, increase the corresponding pixel value of the fourth real number pixel point in the first matrix to obtain a second matrix; perform step 4 on the second matrix to calculate the real value of the reference point; otherwise, perform step 5; Step 4: Calculate the second matrix to obtain the real value of the reference point; Specifically include: 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 values 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; As a preferred embodiment of the present invention, 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, obtaining the maximum pixel value of the reference point and the corresponding pixel channel; As a preferred embodiment of the present invention, 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 r, g, and b channels respectively; max() is the maximum value function.
[0006] 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 changed to the maximum pixel value minus the original pixel values of the remaining channels, thereby obtaining the extended maximum pixel value of the reference point; As a preferred implementation of the present invention, extending the maximum pixel value includes: 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 )-bi ); 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 is (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.
[0007] Step 43, calculating the extended maximum pixel value of the non-reference point in the four-square grid; Step 44, setting different priorities for the non-reference points in the four-square grid, and assigning 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, calculating 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; As a preferred embodiment of the present invention, step 44 specifically includes: When the first 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 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; And the maximum channel pixel value of the reference point is stored in the first container.
[0008] Step 5, extracting pixel values at different real numbers and the fourth real number position; color coding the pixel values to obtain color coding sequence values and color coding values; performing difference calculation on the color coding sequence values and the color coding values; As a preferred implementation of the present invention, step five 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 values corresponding to the fourth real number in the third container; Step 52: construct a fourth container and a fifth container, perform color coding on the pixel point 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; As a preferred implementation of the present invention, color coding includes: YUV, NV21, WHV, HCV.
[0009] Step 53, calculate the difference between each color coding sequence value in the fourth container and the first dynamic threshold value, obtain the absolute value of the color coding sequence value and store it in the sixth container; if the difference sign of the color coding sequence value is positive, assign the eighth real number, if it is negative, assign 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, obtain the absolute value of the color code value and store it in the eighth container; if the difference sign 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; As a preferred embodiment of the present invention, 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.
[0010] Step 55, respectively 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; As a preferred implementation of the present invention, 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.
[0011] Step 56, generating a compression stream for a certain data file to be compressed of a certain frame image; As a preferred embodiment of the present invention, step 56 specifically includes: Step 561: Set up an 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, 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 When 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 is the end value of the sequence number of the initial fixed code container library, and takes zero as the start value of the sequence number of the initial fixed code container library, sorts the start value and the end value of the sequence number in ascending order, and sets the sequence number code corresponding to the sequence number; puts all the concatenated adjacent values into the tenth container; As a preferred embodiment of the present invention, adjacent value splicing 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; i is the adjacent decimal value after the i-th concatenation; Y ’ 2i-1 is the binary value in the 2i-1th compressed data file; Y ’ 2i is the binary value in the 2ith compressed data file; 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, replace it 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 a corresponding serial number code; if it exists, construct array X with the first four values in the tenth container 1 1,2,3,4 , and then judge X 1 1,2,3,4 Whether to iterate in the initial fixed code container library until all values in the tenth container are traversed 。
[0012] Beneficial effects of the present invention: 1. The pixel points in the image frame are preliminarily assigned the same pixel values in the four-square 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 encoding amount is greatly reduced, the compression rate of the image frame is improved, and the storage space is saved; 2. The color coding sequence number value and the color coding value after color coding are halved, thereby further improving the compression rate of the image frame. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 It is a flow chart of the image compression coding method of the present invention which adaptively eliminates redundancy; Figure 2 It is a schematic diagram of a four-grid image frame of the present invention; Figure 3 is a first matrix schematic diagram of the present invention; Figure 4 is a second matrix schematic diagram of the present invention; Figure 5 is a third matrix schematic diagram of the present invention; Figure 6 is a schematic diagram of the second and third containers of the present invention; Figure 7 is a schematic diagram of a fourth and fifth container of the present invention; Figure 8 It is a schematic diagram of a specific example of the fourth and fifth containers of the present invention. DETAILED DESCRIPTION
[0014] The present invention is further described below in conjunction with the accompanying drawings and embodiments. This figure is a simplified schematic diagram, which only illustrates the basic structure of the present invention in a schematic manner, and therefore it only shows the components related to the present invention.
[0015] like Figure 1 As shown, an image compression coding method for adaptively eliminating redundancy comprises the following steps: Step 1: Obtain image frames; The image frames come from images or videos, and the video is divided into a number of image frames according to the frame rate; the image frames are processed.
[0016] 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 Represents the pixel values of r, g, and b channels respectively; the first pixel is recorded as RGB 1 , the value of the first pixel is (r 1 ,g 1 ,b 1 ); Step 2: Taking a certain 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; assigning 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, calculating the base point real value of the next base point, until all pixel points are traversed to obtain a first matrix A composed of the real values of all pixel points; 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 the second, and the third priority is the lowest.
[0017] The four-square grid is based on the base point, and the three pixels adjacent to the base point are non-base points; the four-square grid is based on the base point position, and the four-square grid of the base point can be divided into four categories: upper left, upper right, lower left, and lower right.
[0018] Step 2 specifically includes: When the pixel value of the non-base point of the first priority is equal to the pixel value of the base point, the base point position is assigned a first real number I; Otherwise, determine whether the pixel value of the second priority non-base point is equal to the pixel value of the base point, and if they are equal, assign the second real number J to the base point position; otherwise, 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 the third real number K; otherwise, The base point position is assigned a fourth real number L.
[0019] Real numbers I, J, K, and L are unequal natural numbers, for example, I=1, J=2, K=3, and L=4; like Figure 2 As shown, the image frame has a resolution of 8*8, with a total of 64 pixels; 11 As the base point, the upper left four squares are RGB 2 , RGB 3 , RGB 10 , RGB 11 , in RGB 11 As the base point, the upper right four squares are RGB 3 , RGB 4 , RGB 11 , RGB 12 ; The four grids at the bottom left and bottom right are no longer enumerated; In RGB 11 Take the upper left four squares as an example, the corresponding non-base point is RGB 3 , RGB 2 , RGB 10 ; in RGB 11 Medium RGB 3 , RGB 2 , RGB 10 Set the first, second, and third priority respectively, or set the priority order to RGB 2 , RGB 3 , RGB 10 , other priority orders are no longer enumerated; In RGB 3 , RGB 2 , RGB 10 For example, due to RGB 11 With RGB 2 , RGB 3 , RGB 10 The pixel values are not equal, so RGB 11 Assign a fourth real number L; Similarly, in RGB 12 As the base point, RGB 3 , RGB 4 , RGB 11In order of priority, get RGB 12 Assign the first real number I; In this way, we randomly find the next base point among the remaining 62 pixels until all pixels are assigned corresponding real numbers, and we get Figure 3 The first matrix A is shown.
[0020] Step 3: Increase the corresponding pixel value of the pixel points marked as the fourth real number L in the first matrix A to obtain a second matrix B; like Figure 4 In the second matrix B shown, the positions of 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 points of the fourth real number L retain the corresponding pixel values.
[0021] When the constructed third matrix C is the same as the second matrix B, that is, there is no need to assign real values to the reference points through the four-square grid in step 4, and the second matrix B is directly used to perform step 5 calculation; Step 4: Take the pixel point of the fourth real number L in the second matrix B as the reference point, construct a four-square grid with the reference point as the center, and assign 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 non-reference points of different priorities; and so on, calculate the base point real value of the next reference point, until all reference points are traversed, and construct a third matrix C composed of the real values of all pixel points; The setting of the four-grid is the same as step 2, so I will not repeat it here. Figure 4 The pixel point of the fourth real number L in the second matrix; Step 4 specifically includes: Step 41, obtaining the maximum pixel value of the reference point and the corresponding pixel channel; 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 Respectively represent the pixel values of r, g, and b channels; max() is the maximum value function; That is, take the maximum value of the three channels of RGB; when max_rgb=max(r i ), r i ≥g i And r i ≥ b i , that is, the maximum pixel value of the reference point is r i , the corresponding pixel channel is r; similarly, when max_rgb=max(g i ),g i ≥r iAnd g i ≥ b i ; When max_rgb=max(b i ), b i ≥r i And b i ≥g i ; 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 changed to the maximum pixel value minus the original pixel values of the remaining channels, thereby obtaining the extended maximum pixel value of the reference point; 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 is (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 ); Step 43, calculating the extended maximum pixel value of the non-reference point in the four-square grid; Using a method similar to step 42, the extended maximum pixel value of the non-reference point is obtained; Step 44, setting different priorities for the non-reference points in the four-square grid, assigning different reference point real values according to the priorities of the non-reference points and the relationship between the extended maximum pixel values of the non-reference points and the extended maximum pixel values of the reference points; and so on, calculating the reference point real value of the next reference point, until all reference points are traversed to obtain a third matrix C composed of the real values of all pixel points; Step 44 specifically includes: When the first priority non-reference point has the same channel with the reference point in terms of maximum pixel value and the remaining two channel pixel values are also equal, the reference point is assigned the fifth real number O; and the maximum channel pixel value max_rgb of the reference point is stored in the first container CONT 1 ;otherwise, When the second priority non-reference point has the same channel with the reference point in terms of maximum pixel value and the remaining two channel pixel values are also equal, the reference point is assigned the sixth real number P; and the maximum channel pixel value max_rgb of the reference point is stored in the first container CONT 1 ;otherwise, When the third priority non-reference point has the same channel with the reference point in terms of maximum pixel value and the remaining two channel pixel values are also equal, the reference point is assigned the seventh real number Q; and the maximum channel pixel value max_rgb of the reference point is stored in the first container CONT 1 ;otherwise, The reference point is still the fourth real number L; And so on, complete the real number assignment of all reference points.
[0022] A third matrix C is constructed using a fourth real number L, a fifth real number O, a sixth real number P, and a seventh real number Q; wherein the real numbers O, P, and Q are unequal self-defined natural numbers, for example, O=5, P=6, and Q=7; by Figure 4 Medium RGB 10 As the reference point, take the upper left four squares as an example, RGB 10 The pixel value is (10,20,9), max_rgb=20, the corresponding g channel is the maximum pixel value, then the maximum pixel value RGB is expanded 1 10 is (max(g i )-r i ,max(g i ),max(g i )-b i )=(10,20,11); The first priority of non-reference points is RGB 2 (10,20,8), max_rgb=20, corresponding to the g channel as the maximum pixel value, expanding the maximum pixel value RGB 1 2 is (10,20,12); although RGB 1 10 With RGB 1 2 The g channel is the maximum pixel value, but the b channel in the remaining r and b channels is not equal; then the second priority RGB of the non-reference point 1 Make a judgment and expand the maximum pixel value RGB 1 1is (10,20,12), which also does not meet the conditions; then the third priority RGB of the non-reference point 9 Make a judgment and expand the maximum pixel value RGB 1 9 is (10,21,9), which is the same as RGB 2 The g channel is the maximum pixel value, and the remaining r and b channels are equal, then RGB 2 The position of is assigned the seventh real number Q; Figure 5 This is a schematic diagram of the third matrix C.
[0023] The total amount of colors of several frames of images in different scenes is counted, and the results in Table 1 are obtained; Table 1 Comparison between the total amount of colors in the third matrix and the total amount of original colors Scene Type File size (MB) Total amount of original color The total amount of third matrix color Reduction rate High Dynamics 23.7 8294400 345907 95.82% High overall color 23.7 8294400 839939 89.87% Highly complex scenes 23.7 8294400 4689442 43.46% High Particles 23.7 8294400 952792 88.51% High transition color 23.7 8294400 309996 96.26% High character detail 23.7 8294400 700782 91.55% Table 1 is a statistical comparison of colors in six different scenes. In a 23.7M file of several image frames, the third matrix colors are compared with the original colors. 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 image frames, and saves storage space.
[0024] Step 5, extracting pixel values at different real numbers and the fourth real number position; color coding the pixel values to obtain color coding sequence values and color coding values; performing difference calculation on the color coding sequence values and the color coding values; Step 5 specifically includes: Step 51: Build the second container CONT 2 and the third container CONT 3 , 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 corresponding to the pixel point in the third matrix C into the second container CONT 2 , store the pixel value corresponding to the fourth real number L in the third container CONT 3 ; The pixel values of the pixels at non-fourth real number positions are separated by separators, and the separator can be " / " or other separators; When the third matrix C is the second matrix B, the corresponding positions of the pixels in the third matrix C are the first real number I, the second real number J, the third real number K, and the fourth real number L.
[0025] Second container CONT 2 and the third container CONT 3 are all one-dimensional linear containers; Figure 6 This is an example for the second container and the third container.
[0026] Step 52: Build the fourth container CONT 4 And the fifth container CONT 5 , for the third container CONT 3 The fourth real number position pixel point in the color coding is color-coded; the color coding sequence value is stored in the fourth container CONT 4 , the corresponding color code value is stored in the fifth container CONT 5 middle; Color encoding can use YUV, NV21 encoding library; it can also use WHV, HCV encoding library; Taking the WHV encoding library as an example, RGB i WHV encoding number value C of pixel value d and the corresponding color coding value W d H d V d ; Where d is the serial number of the WHV encoding 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 the adopted color coding library, and other color coding libraries are also applicable to the present invention; Figure 7 The fourth container and the schematic diagram of the fourth container are shown in FIG. 1 ; the subscript n is the maximum serial number of the WHV coding library.
[0027] like Figure 8 As shown, Figure 6 The image pixel coordinates of the fourth real number L in the image are encoded by WHV color, and the corresponding Figure 7 The values in the fourth and fifth containers of Figure 6 The WHV code number value corresponding to the pixel value (10,20,8) is 100, and the corresponding color code value is (3,3,4); Step 53: Place the fourth container CONT 4 The difference between each color coding sequence value and the first dynamic threshold is calculated to obtain the absolute value of the color coding sequence value and store it in the sixth container CONT 6 ; The difference of the color coding sequence value is assigned the eighth real number Z if it is positive, and the ninth real number X if it is negative, and stored in the seventh container CONT 7 ; Step 54: Place the fifth container CONT 5 The difference between each color coding value and the second dynamic threshold is calculated, and the absolute value of the color coding value is obtained and stored in the eighth container CONT 8 ; The difference of the color coding value is assigned the eighth real number Z if it is positive, and the ninth real number X if it is negative, and stored in the ninth container CONT 9 ; Among them, the range of the first dynamic threshold a 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; Among them, the range of the second dynamic threshold b is: The number of color coding values / 2 <= the number of absolute values of color coding values < the number of color coding values; For example: the color coding serial number values are 100, 200, 400, 500, and the number of color coding serial number values is 4; when the first dynamic threshold a=300, the difference between the color coding serial number value and the first dynamic threshold is -200, -100, 100, 200, and the absolute value is 200, 100, 100, 200, and the number of corresponding absolute values of the color coding serial number values is 2, namely 100 and 200; for example, the first dynamic threshold can also be 150, and the number of corresponding absolute values of the color coding serial number values is 3, namely 50, 250, 350; the optimal value is 2; that is, the color coding serial number value is halved, effectively reducing the number range of the color coding serial number value.
[0028] Similarly, the value of the second dynamic threshold is obtained.
[0029] Step 55: Place the first container CONT 1 、Sixth container CONT 6 、Seventh container CONT 7 、Eighth container CONT 8 、Ninth container CONT 9 and the real numbers of the third matrix C generate compressed data files respectively; That is, 6 data files to be compressed are generated; if the third matrix C is equal to the second matrix B, there is no first container.
[0030] Step 56, generating a compression stream for a certain data file to be compressed of a certain frame image; Step 56 specifically includes: Step 561: Set up an initial fixed code container library and obtain a data file Y to be compressed. ’ The maximum value of Y ’ max , when the maximum value Y ’ max When it is greater than 4, the maximum value 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 in ascending order, and the sequence number code corresponding to the sequence 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 ’ maxWhen it is between 1 and 4, execute step 562; 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}; 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.
[0031] Step 562: concatenate adjacent values of a value in a certain 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, 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 concatenated adjacent values are placed in the tenth container CONT 10 middle; When the value in the data file to be compressed is an odd number, one digit is added at the end and filled with the value 0; 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 is [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.
[0032] Adjacent value concatenation includes: When the maximum value Y ’ max When Y is 1, i =(Y ’ 2i-1 <<1)|Y ’ 2i ; When the maximum value Y ’ max When Y is 2 or 3, i =(Y ’ 2i-1 <<2)|Y ’ 2i ; When the maximum value 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; i is the adjacent decimal value after the i-th concatenation; Y ’ 2i-1 is the binary value in the 2i-1th compressed data file; Y ’ 2i is the binary value in the 2ith compressed data file; 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 adjacent value Y after the first splicing 1 Yes ’ 1 With Y ’ 2 Perform adjacent value concatenation operation; Y ’ 1 =1,Y ’ 2 =1, get Y 1 =0100|0001=5; similarly, Y 2 =(1000|0011)=11; and so on, all the adjacent values after splicing are (5, 11, 6, 15, 10, 13, 11, 9, 11), which is the tenth container; among them, Y max =15, 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, 11:11, 12:12, 13:13, 14:14, 15:15}; 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 means the initial fixed code container library The sequence number is 0, and the corresponding sequence number code is 0; in step 561 and step 562, the sequence number code in the initial fixed code container library may not be the same as the sequence number, and a combination of different numerical values and / or characters may be used; 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}.
[0033] 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, replace it with X 1 1,2Assign 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 a corresponding serial number code; if it exists, construct array X with the first four values in the tenth container 1 1,2,3,4 , and 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.
[0034] For example, the value in the tenth container is [5, 11, 6, 5, 11, 12], and 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), and (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 determine X 2 2,3 is (11,6), and (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 determine X 3 3,4is (6,5), which does not exist in the initial fixed code container library. Then 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 determine X 4 5,6 is (5,11), exists in the initial fixed code container library, then judge X 4 5,6,7 is (5,11,12), which does not exist in the initial fixed code container library, then 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}.
[0035] 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.
[0036] The compression ratios of several frames of images in different scenes are statistically analyzed, and the results are obtained in Table 2; Table 2 Comparison of compression rates of the method of the present invention and the zip method for different scenarios Scene Type File size (MB) Compression rate of image files by zip method (%) Image file compression rate of the method of the present invention (%) High Dynamics 23.7 21.56 20.37 High overall color 23.7 83.60 68.64 Highly complex scenes 23.7 49.86 39.89 High Particles 23.7 19.18 18.42 High transition color 23.7 1.74 1.36 High character detail 23.7 11.53 10.37 It can be seen from Table 2 that the compression rate of the scene with high overall color and high complexity is significantly improved by the method of the present invention, and other scenes are also improved to a certain extent.
[0037] Based on the above ideal embodiments of the present invention, the relevant staff can make various changes and modifications without departing from the technical concept of the present invention through the above description. The technical scope of the present invention is not limited to the contents of the specification, and its technical scope must be determined according to the scope of the claims.
Claims
1. An image compression coding method for adaptively eliminating redundancy, characterized in that: The following steps are involved: Step 1: Obtain image frames; Step 2: Taking a certain 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; assigning 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, calculating the base point real value of the next base point, until all pixel points are traversed to obtain a first matrix composed of the real values of all pixel points; When the pixel value of the non-base point of the first priority is equal to the pixel value of the base point, the base point position is assigned the 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 the first 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 first real number; otherwise, The position of the cardinal point is assigned a fourth real number; Step 3: Increase the pixel point of the fourth real number in the first matrix by the corresponding pixel value to obtain a second matrix; When calculating the real value of the reference point of 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 different real numbers and the fourth real number position pixel values; 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 for adaptively eliminating redundancy 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 to construct a third matrix composed of the real values of all pixel points.
3. The image compression coding method for adaptively eliminating redundancy according to claim 2, characterized in that: 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, obtaining 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 changed to 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, calculating the extended maximum pixel value of the non-reference point 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 for adaptively eliminating redundancy according to claim 3, characterized in that: 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 r, g, and b channels respectively; max() is the maximum value function.
5. The image compression coding method for adaptively eliminating redundancy 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 is (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 for adaptively eliminating redundancy according to claim 3, characterized in that: Step 44 specifically includes: When the first 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 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; And the maximum channel pixel value of the reference point is stored in the first container.
7. The image compression coding method for adaptively eliminating redundancy according to claim 1, characterized in that: 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 values corresponding to the fourth real number in the third container; Step 52: construct a fourth container and a fifth container, perform color coding on the pixel point 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 coding sequence value in the fourth container and the first dynamic threshold value, obtain the absolute value of the color coding sequence value and store it in the sixth container; if the difference sign of the color coding sequence value is positive, assign the eighth real number, if it is negative, assign 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, obtain the absolute value of the color code value and store it in the eighth container; if the difference sign 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, respectively 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; 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 for adaptively eliminating redundancy 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 for adaptively eliminating redundancy according to claim 7, characterized in that: 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 for adaptively eliminating redundancy according to claim 7, characterized in that: Color encoding includes: YUV, NV21, WHV, HCV.
11. The image compression coding method for adaptively eliminating redundancy according to claim 7, characterized in that: Step 56 specifically includes: Step 561: Set up an 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, 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 When 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 is the end value of the sequence number of the initial fixed code container library, and takes zero as the start value of the sequence number of the initial fixed code container library, sorts the start value and the end value of the sequence number in ascending order, and sets the sequence number code corresponding to the sequence number; puts all the concatenated adjacent values into 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, replace it 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 a corresponding serial number code; if it exists, construct array X with the first four values in the tenth container 1 1,2,3,4 , and 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 for adaptively eliminating redundancy 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; i is the adjacent decimal value after the i-th concatenation; 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
Coding and decoding device, coding and decoding method and program
CN101543036A
Method for rectifying missing pixels and image sensor
CN103475828A
Out-chip buffer compression method for superhigh-definition processing system
CN105472389A
Video frame pixel block compression method and device
CN105763877A
Method and device for coding character blocks in image
CN106888380A