A Coding Method Based on Color Distribution
Through the adaptive encoding method based on color distribution, the problems of low image compression efficiency and limited storage space in the prior art are solved, and more efficient image compression and shortened compression time are achieved.
Patent Information
- Application Number
- CN202411793596.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2044-12-09
AI Technical Summary
The existing visual-based color encoding method has problems such as long compression time, low compression efficiency and limited video compression space when compressing images.
An adaptive encoding method based on color distribution is adopted. By obtaining the pixel values of the video to be compressed, sorting and reconstructing according to the frequency of pixel values, the container sequence number and spatial coordinates are calculated to reduce the size of the encoding library and the number of pixel values, thereby improving compression efficiency and reducing storage space requirements.
It achieves more efficient image compression, shortens compression time, reduces storage space requirements, and improves the efficiency of video compression.
Smart Images

Figure CN119299711B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image coding, and in particular to a coding method based on color distribution. Background Art
[0002] The image color coding library is a collection of algorithms and tools for image compression and decompression. The color coding library has a positive impact on image compression; by providing diverse, efficient and compatible compression algorithms and tools, it optimizes the storage and transmission efficiency of images; and enables video and image data to be more effectively utilized and managed in the information age.
[0003] A patent for a color coding method based on vision with publication number CN118714330A performs pixel distribution statistics on massive images, performs statistical analysis based on the probability of occurrence of pixel values, obtains a library of 640,000 commonly used colors, and uses commonly used colors to construct a color coding library. However, this method has the following shortcomings:
[0004] 1. Although the size of the color coding library is significantly reduced compared to the existing library, it is still large. Using this color coding library for image compression still has the problems of long compression time and low compression efficiency;
[0005] 2. When the probability of a certain pixel appearing in a certain video shot is relatively small, if the color coding library is used for encoding and then compressed, there is a problem of limited video compression space. Summary of the invention
[0006] In view of the shortcomings of the existing methods, the present invention only performs adaptive encoding on the video to be compressed to obtain the pixel distribution characteristics in the video to be compressed, which can reduce the size of the encoding library and the number of pixel values, thereby further reducing the compression rate and saving storage space; and improve the compression efficiency and shorten the compression time.
[0007] The technical solution adopted by the present invention is: a coding method based on color distribution comprises the following steps:
[0008] Step 1: Obtain pixel values of all pixel points of several frames of images in a certain lens;
[0009] Step 2: Sort pixel values in descending order according to their frequency of occurrence to obtain pixel numbers;
[0010] Step 3: Calculate the container number according to the pixel number and construct the spatial coordinates of the pixel value corresponding to the pixel number in the HCV container;
[0011] The formula for calculating the spatial coordinates of the container number and the pixel value corresponding to the pixel number in the HCV container is:
[0012] j=└(i-1) / (H t *Ct *V t )┘;
[0013] h i =└((i-1)-(j*H t *C t *V t )) / (C t *V t )┘;
[0014] c i =└(i-1-(j*H t *C t *V t )-(h i *C t *V t )) / V t ┘;
[0015] v i =└i-1-(j*H t *C t *V t )-(h i *C t *V t )-(c i *V t )┘;
[0016] Where └┘ means rounding down; i is the pixel number of the pixel value; j is the container number; H t is the H component value of the HCV container, C t is the C component value of the HCV container, V t is the V component value of the HCV container; h i ,c i ,v i is the spatial coordinate in the HCV container.
[0017] As a preferred embodiment of the present invention, the second formula for calculating the spatial coordinates of the container number and the pixel value corresponding to the pixel number in the HCV container is:
[0018] count_avg=└(all_color / D)+1┘;
[0019] j=└(i-1) / count_avg┘;
[0020] h i =└(i-1-count_avg*j) / (C t *V t )┘;
[0021] c i=└(i-1-count_avg*j–h i *C t *V t ) / V t ┘;
[0022] v i =└i-1-count_avg*j–h i *C t *V t –c i *V t ┘;
[0023] Where D is the number of custom spatial containers; all_color is the total number of pixel values; i is the pixel number of the pixel value; j is the container number; H t is the H component value of the HCV container, C t is the C component value of the HCV container, V t is the V component value of the HCV container; h i ,c i ,v i is the spatial coordinate in the HCV container; └┘ means rounding down.
[0024] As a preferred embodiment of the present invention, the third formula for calculating the spatial coordinates of the container number and the pixel value corresponding to the pixel number in the HCV container is:
[0025] count_avg=└(all_color / D)+1┘;
[0026] m=┌count_avg 1 / 3 ┐;
[0027] j = └i / count_avg┘;
[0028] h i =└count_avg / m 2 ┘;
[0029] c i =└(count_avg–h i *m 2 ) / m┘;
[0030] v i =└count_avg–h i *m 2 –c i *m┘;
[0031] Among them, ┌┐ is rounded up; all_color is the total number of pixel values; m represents the average value of the total class of pixel values corresponding to the H, C, and V component values; i is the pixel number of the pixel value; j represents the container number; H t is the H component value of the HCV container, C t is the C component value of the HCV container, V t is the V component value of the HCV container; h i ,c i ,v i is the spatial coordinate in the HCV container; └┘ means rounding down.
[0032] As a preferred implementation of the present invention, step three also includes: calculating the container number according to the pixel number of the pixel difference and constructing the spatial coordinates of the pixel value corresponding to the pixel number in the HCV container.
[0033] As a preferred implementation manner of the present invention, obtaining the pixel sequence number of the pixel difference includes:
[0034] Step 31, obtaining a frame image, dividing the frame image into four regions on average; performing flipping processing on the four region images;
[0035] Step 32: perform difference calculation on the pixels in the flipped image frame to obtain the pixel difference and the corresponding sign bit and difference flag bit.
[0036] As a preferred embodiment of the present invention, the pixel difference and the corresponding sign bit and difference flag bit include: frame-by-frame difference, and the frame-by-frame difference steps are as follows:
[0037] Step 321: taking a certain pixel point in a certain frame as an initial reference pixel point, randomly selecting a pixel point from non-initial reference pixel points as a first iteration pixel point, performing difference calculation between the first iteration pixel point and the initial reference pixel point, and obtaining a difference absolute value of the first iteration pixel point, a sign bit of the first iteration pixel point, and a difference flag bit of the first iteration pixel point;
[0038] Step 322: randomly select a pixel point from non-initial reference pixel points and non-first iteration pixel points as a second iteration pixel point, perform difference calculation between the second iteration pixel point and the first reference pixel point, and obtain a difference absolute value of the second iteration pixel point, a sign bit of the second iteration pixel point, and a difference flag bit of the second iteration pixel point; wherein the first reference pixel point is any one of the initial reference pixel point and the first iteration pixel point;
[0039] Step 323: randomly select a pixel point from non-initial reference pixel points and non-first and second iteration pixel points as a third iteration pixel point, perform difference calculation between the third iteration pixel point and the second reference pixel point, and obtain a difference absolute value of the third iteration pixel point, a sign bit of the third iteration pixel point, and a difference flag bit of the third iteration pixel point, wherein the second reference pixel point is any one of the initial reference pixel point and the first and second iteration pixel points;
[0040] Step 324, and so on, select the M-1th iteration pixel point and the M-2th reference pixel point, and calculate the difference absolute value, sign bit and difference mark bit of the M-1th iteration pixel point; wherein M is the total number of pixels in a certain frame;
[0041] Step 325: sort the frequencies of occurrence of the absolute values of the difference values in descending order to obtain the pixel numbers of the pixel differences.
[0042] As a preferred implementation manner of the present invention, it also includes: Step 326, calculating the absolute value of the difference of several images in the lens, and summing the absolute value of the difference of several images and then sorting them in descending order of frequency to obtain the pixel number of the pixel difference of the lens.
[0043] As a preferred implementation manner of the present invention, the acquisition of the pixel sequence number of the pixel difference value further includes: four-grid.
[0044] As a preferred embodiment of the present invention, the difference of the four-grid includes: step 33, dividing the pixel points in the flipped image frame into four grids, performing difference calculation on the four-grid pixel frame, and obtaining the pixel difference and the corresponding sign bit and difference mark bit.
[0045] As a preferred embodiment of the present invention, step 33 specifically includes:
[0046] Step 331, dividing the image frame into a number of four-square grids according to 2x2 pixel points;
[0047] Step 332: Taking a pixel point in the first quartet as a global reference pixel point, performing difference between the non-global reference pixel points in the first quartet and the global reference pixel points, respectively, to obtain the absolute value and sign bit of the difference corresponding to the non-global reference pixel points;
[0048] Step 333: Taking a certain pixel point in the second quartet as a local reference pixel point, performing a difference between the local reference pixel point in the second quartet and the global reference pixel point, performing a difference between the non-local reference pixel point in the second quartet and the local reference pixel point in the second quartet, and obtaining the absolute value and sign bit of the difference corresponding to all the pixels;
[0049] Step 334: find the corresponding position of the local reference pixel point in the third quadrilateral based on the position of the local reference pixel point in the second quadrilateral, perform difference between the local reference pixel point in the third quadrilateral and the local reference pixel point in the second quadrilateral, perform difference between the non-local reference pixel point in the third quadrilateral and the local reference pixel point in the third quadrilateral, and obtain the absolute value and sign bit of the difference of all the pixels in the third quadrilateral;
[0050] Step 335, repeating step 334 until the absolute value and sign bit of the difference of all pixels in the last four-square grid are obtained;
[0051] Step 336: Sort the frequency of occurrence of the absolute value of the difference in descending order to obtain the pixel number of the pixel difference 。
[0052] Beneficial effects of the present invention:
[0053] 1. Only the number of pixel values of the lens to be processed is statistically analyzed, and the unused pixel values in the lens are not included in the statistics;
[0054] 2. Reorder the pixel values that appear and mark the spatial coordinates to make the pixel values more compact and the pixel value range smaller;
[0055] 3. The pixel values that appear more frequently under the lens are positioned closer to the front in space, so that the coordinates replaced by them are more concentrated and the repetition is higher. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 is a flow chart of the encoding method based on color distribution of the present invention;
[0057] Figure 2 It is a schematic diagram of the HCV container;
[0058] Figure 3 is a frame image;
[0059] Figure 4 (a) is the first area of the image, Figure 4 (b) is the second area of the image, Figure 4 (c) is the third area of the image, Figure 4 (d) is the fourth area of the image;
[0060] Figure 5 It is a schematic diagram of frame-by-frame difference;
[0061] Figure 6 This is a schematic diagram of the difference between the four squares;
[0062] Figure 7 It is a schematic diagram of the Jiugong grid;
[0063] Figure 8 It is a schematic diagram of a row frame;
[0064] Fig. 9 It is a schematic diagram of column frames. DETAILED DESCRIPTION
[0065] 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.
[0066] like Figure 1 As shown, a color distribution-based encoding method includes the following steps:
[0067] Step 1: Obtain pixel values of all pixel points of several frames of images in a certain lens;
[0068] For example: if the shot is 5 seconds and the frame rate is 60 frames / s, there are 300 frames in the shot;
[0069] Step 2: Sort pixel values in descending order according to their frequency of occurrence to obtain pixel numbers;
[0070] Construct the image frequency array I[(RGB1,1,P1);...(RGB i ,i,P i );...;(RGB N ,N,P N )];
[0071] Among them, RGB i represents the pixel value of pixel number i; P i Indicates the frequency of occurrence of the pixel value with pixel number i, 1<=i<=N; N is the pixel number corresponding to the minimum frequency of occurrence of the pixel value.
[0072] For example, there are 9000 pixel values in 300 frames of images in descending order; the pixel value (10,10,2) appears 11,000 times, which is the most frequent pixel value; then the pixel number i corresponding to (10,10,2) is 1, P N = 11,000; the pixel value (1,10,2) appears 100 times, which is the least frequent pixel value. Then (1,10,2) corresponds to pixel number i=9000, P N =100, N=9000.
[0073] Step 3: Calculate the container number according to the pixel number of the pixel value and construct the spatial coordinates of the pixel value corresponding to the pixel number in the HCV container;
[0074] The calculation of the spatial coordinates of the container number and the pixel value corresponding to the pixel number in the HCV container includes formula 1:
[0075] j=└(i-1) / (Ht *C t *V t )┘;
[0076] h i =└((i-1)-(j*H t *C t *V t )) / (C t *V t )┘;
[0077] c i =└(i-1-(j*H t *C t *V t )-(h i *C t *V t )) / V t ┘;
[0078] v i =└i-1-(j*H t *C t *V t )-(h i *C t *V t )-(c i *V t )┘;
[0079] Where └┘ means rounding down; i is the pixel number of the pixel value; j is the container number; H t is the H component value of the HCV container, C t is the C component value of the HCV container, V t is the V component value of the HCV container, H t 、V t , C t is a custom parameter; h i ,c i ,v i is the spatial coordinate in the HCV container.
[0080] like Figure 2 As shown, the HCV container is a regular cube structure, (0,0,0) is the origin coordinate of the HCV container, and (h i ,c i ,v i ) put in d j Medium, d j Indicates the HCV container with container number j.
[0081] For example, there are 9000 pixel values in 300 frames of images in descending order, I[(10,10,8;1;11000);(10,1,8;2;10100);.....;(1,10,2;9000;100)]; let H t =V t =C t =20, then the pixel value (10,10,8) corresponds to j=└(1-1) / 20^3┘=0, h1=└((1-1)-(0*20^3)) / (20^2)┘=0, c1=└(1-1-(0*20^3)-(0*20^2) / 20)┘=0, v1=└(1-1-(0*20^3)-(0*20^2)-(0*20)┘=0; that is, the pixel value (10,10,8) corresponds to the container number j 0, and the corresponding spatial coordinate in the HCV container is (0,0,0); like The pixel value (1,10,2) corresponds to j=└(9000-1) / 20^3┘=1, h1=└((9000-1)-(1*20^3)) / 20^2┘=2, c1=└(9000-1-(1*20^3)-(2*20^2)) / 20┘=9, v1=└9000-1-(1*20^3)-(2*20^2)-(9*20)=19; that is, the container number j corresponding to the pixel value (1,10,2) is 1, and the corresponding spatial coordinates in the HCV container are (2,9,19).
[0082] The color library disclosed in the patent of a vision-based color encoding method with publication number CN118714330A consists of 16777216 color IDs, and commonly used pixel values are concentrated in the core library. There are 8 spatial containers in total, and the size of each spatial container is 128*128*128; when the pixel values encountered in the video or image are not commonly used, this method will cause spatial redundancy and uncertainty; while the present invention only needs to count the pixel values used in the lens, and concentrate the commonly used pixel values of the lens into the containers with the top ranking, and the spatial redundancy is greatly reduced; for example: a certain lens only uses 9000 pixel values, and only needs to construct 2 spatial containers, and the pixel values only need to be filled into a space of 20*20*20; that is, the pixel values in the lens only need to derive the container numbers and spatial coordinates of two HCV containers, which greatly reduces spatial redundancy and increases the concentration of pixel values.
[0083] The calculation of the spatial coordinates of the container number and the pixel value corresponding to the pixel number in the HCV container also includes Formula 2:
[0084] count_avg=└(all_color / D)+1┘;
[0085] j=└(i-1) / count_avg┘;
[0086] h i =└(i-1-count_avg*j) / (C t *V t )┘;
[0087] c i =└(i-1-count_avg*j–h i *C t *V t ) / V t ┘;
[0088] v i =└i-1-count_avg*j–h i *C t *V t –c i *V t ┘;
[0089] Among them, D is the number of custom spatial containers, and all_color is the total number of pixel values.
[0090] Formula 2 is a variation of Formula 1. Formula 1 fills the pixel values into the HCV container in sequence when the space size is known, fills container number 0 with container number 1, and then fills container number 1 until all the pixel values are filled. Formula 2 is based on the known number of space containers D and space size H. t 、V t , C t In this case, all pixel values are filled into all HCV containers on average.
[0091] The calculation of the spatial coordinates of the container number and the pixel value corresponding to the pixel number in the HCV container also includes formula three:
[0092] count_avg=└(all_color / D)+1┘;
[0093] m=┌count_avg 1 / 3 ┐;
[0094] j = └i / count_avg┘;
[0095] h i =└count_avg / m 2 ┘;
[0096] c i =└(count_avg–h i *m 2 ) / m┘;
[0097] v i =└count_avg–hi *m 2 –c i *m┘;
[0098] Among them, ┌┐ is rounded up; count_avg is the average value of the total pixel value category, which is the total number of pixel values after deduplication; m represents the average value of the total pixel value category corresponding to the H, C, and V component values, that is, the dynamically obtained H t 、V t , C t value.
[0099] In formula 1 and formula 2, the number of space containers D and the space size H are included. t 、V t , C t It is determined according to the total category range of pixel values; for example, according to the total category range of pixel values (0-16384], let D = 4, H t =C t =V t =16; Range(16384,32000], let D=4, H t =C t =V t =20; the total number of pixel values of a certain lens is 16400, and the selected interval is (16384,32000], corresponding to D=4, H t =C t =V t =20; According to formula 1, the pixel value of this lens only fills the HCV containers with container numbers 0 and 1, and the space of container number 2 only occupies a small part, and the container with container number 3 is not used, which will cause space waste; if formula 2 is used, the pixel values are concentrated, and each container space has redundancy; and formula 3 selects the number of HCV containers according to the total category of pixel values; for example, in formula 3, D=4, and the value of m of this lens is 17, then the dynamic H t 、V t , C t The value is 17*17*17, which can make full use of all space and reduce space redundancy.
[0100] For example, the pixel value (1, 10, 2) is calculated using the formula: pixel number i = 9000, D = 2, H t =C t =V t = 20, corresponding to the spatial coordinates j = 1, (h i ,c i ,v i )=(2,9,19); using formula 2, the spatial coordinates in the HCV container are j=1, (h i ,c i ,vi )=(11,4,18); According to formula 3, we get H t =C t =V t = 17, corresponding to the spatial coordinates j = 1, (h i ,c i ,v i )=(15,9,13).
[0101] Step three also includes: calculating the container number according to the pixel number of the pixel difference value and constructing the spatial coordinates of the pixel value corresponding to the pixel number in the HCV container;
[0102] Since the total number of pixel values of an image or video to be processed is 256, i.e. 0-255; there are a total of 16777216 pixel values, the pixel values are too dispersed; but the absolute value of the difference between the R value, G value, B value and the intermediate value is only 128, the sign bit can be used to reduce the pixel value by at least half, thereby reducing the total number of pixel values.
[0103] The acquisition of the pixel sequence number of the pixel difference includes:
[0104] Step 31, obtaining a frame image, dividing the frame image into four regions on average; performing flipping processing on the four region images;
[0105] The flipping processing of the four area images includes: the first area is not processed, the second area is flipped along the y-axis, the third area is flipped along the x-axis, and the fourth area is flipped along the x- and y-axes; the four area flipping method can also adopt other settings, such as custom settings for the flipped area, and custom settings for the flipping method.
[0106] like Figure 3 For a frame image, Figure 4 (a) is the first area keeping the original image, and the number 1 represents the first area; Figure 4 (b) is the effect diagram after the second area is flipped, and the number 2 represents the second area; Figure 4 (c) is the effect diagram after the third area is flipped, and the number 3 represents the third area; Figure 4 (d) is the effect diagram after the fourth area is flipped, and the number 4 represents the fourth area.
[0107] Statistics of the pixel values within the frames of a large number of images show that the closer to the center of the frame, the brighter the frame is, and the brightness is darker at the four corners relative to the center; the positions of the dark and bright parts are unified by flipping the frame, that is, the dark part of each area is placed in the same position, and the bright part is placed in the same position to facilitate difference processing, so that the sign bit corresponding to the difference in pixel values is more regular and the pixel values of the pixel points are more concentrated.
[0108] Step 32, performing difference calculation on the pixels in the flipped image frame to obtain the pixel difference and the corresponding sign bit and difference mark bit;
[0109] The pixel difference and the corresponding sign bit and difference flag bit include: frame-by-frame difference, the frame-by-frame difference steps are as follows:
[0110] Step 321: taking a certain pixel point in a certain frame as an initial reference pixel point, randomly selecting a pixel point from non-initial reference pixel points as a first iteration pixel point, performing difference calculation between the first iteration pixel point and the initial reference pixel point, and obtaining a difference absolute value of the first iteration pixel point, a sign bit of the first iteration pixel point, and a difference flag bit of the first iteration pixel point;
[0111] The pixel value of the initial reference pixel point, the sign bit of the initial reference pixel point, and the difference mark bit of the initial reference pixel point are stored in the difference array; the absolute value of the difference of the first iteration pixel point, the sign bit of the first iteration pixel point, and the difference mark bit of the first iteration pixel point are stored in the difference array;
[0112] like Figure 5 The image size of a frame is 8x8, with the second pixel as the initial reference pixel, and the pixel value is (10,20,8); o in the sign bit indicates that the pixel difference is positive, set to 1; p indicates that the pixel difference is negative, set to 2; q indicates that the pixel values are the same, set to 3; the default sign bit of the initial reference pixel is ooo=111, that is, ooo indicates that the R value, G value, and B value of the initial reference pixel are all positive; the difference mark bit of the initial reference pixel is the pixel position 2, that is, the second pixel; the corresponding difference array is [(10,20,8),111,2];
[0113] In the frame, randomly select the first iteration pixel point except the second pixel point. For example, assume that the fifth pixel point is the selected first iteration pixel point, and the pixel value is (4, 23, 8); then the absolute value of the difference of the first iteration pixel point is (6, 3, 0); the sign bit of the first iteration pixel point is poq = 213; the difference flag bit of the first iteration pixel point is 2, 2 indicates that the second pixel point is the reference pixel point of the first iteration pixel point; then the corresponding difference array is [(10, 20, 8), 111, 1; (6, 3, 0), 213, 2]; the sign bit can also be recorded in other ways For example, when one or more of the R value, G value, and B value of a pixel point are the same, the corresponding sign bit is recorded as positive; for example, the initial reference point is (10,20,8) and the first iteration pixel point is (4,23,8), then the absolute value of the difference is (6,3,0) and the sign bit is (2,1,1); for example, if the first iteration pixel point is the same as the reference point, both are (10,10,8), then the absolute value of the difference is (0,0,0), and the sign bit is (1,1,1) or the sign bit is directly recorded as (3), and the absolute value of the difference is (0); or the absolute value of the difference is not recorded, and the sign bit is (3).
[0114] Step 322: randomly select a pixel point from non-initial reference pixel points and non-first iteration pixel points as a second iteration pixel point, perform difference calculation between the second iteration pixel point and the first reference pixel point, and obtain a difference absolute value of the second iteration pixel point, a sign bit of the second iteration pixel point, and a difference flag bit of the second iteration pixel point; wherein the first reference pixel point is any one of the initial reference pixel point and the first iteration pixel point;
[0115] The difference absolute values, sign bits, and difference flag bits corresponding to the initial reference pixel point, the first iteration pixel point, and the second iteration pixel point are stored in a difference array.
[0116] like Figure 5 As shown, in the frame, except for the 2nd and 5th pixels, the second iteration pixel point is randomly selected, and the 10th pixel point is set as the selected second iteration pixel point, and the pixel value is (8,1,7); any one of the 2nd and 5th pixel points is selected as the first reference pixel point, for example, the 5th pixel point is selected as the first reference pixel point; then the absolute value of the difference of the second iteration pixel point is (4,22,1); the sign bit of the second iteration pixel point is 122; the difference mark bit of the second iteration pixel point is 5; then the corresponding difference array is [(10,20,8),111,1;(6,3,0),213,2;(4,22,1),122,5];
[0117] Alternatively, the second pixel is selected as the first reference pixel; the absolute value of the difference of the second iteration pixel is (2,19,1); the sign bit of the second iteration pixel is 222; the difference flag bit of the second iteration pixel is 2; the corresponding difference array is [(10,20,8),111,1;(6,3,0),213,2;(2,19,1),222,2].
[0118] Step 323: randomly select a pixel point from non-initial reference pixel points and non-first and second iteration pixel points as the third iteration pixel point, perform difference calculation between the third iteration pixel point and the second reference pixel point, obtain the difference absolute value of the third iteration pixel point, the sign bit of the third iteration pixel point and the difference flag bit of the third iteration pixel point, wherein the second reference pixel point is the initial reference pixel point and any one of the first and second iteration pixel points; store the difference absolute value, sign bit and difference flag bit corresponding to the initial reference pixel point, the first iteration pixel point, the second iteration pixel point and the third iteration pixel point in the difference array.
[0119] Step 324, and so on, select the M-1th iteration pixel point and the M-2th reference pixel point, and calculate the difference absolute value, sign bit and difference mark bit of the M-1th iteration pixel point, and store them in the difference array; where M is the total number of pixels in a frame.
[0120] Step 325: sort the frequencies of occurrence of the absolute values of the difference values in descending order to obtain the pixel numbers of the pixel differences.
[0121] For example: there are 1000 pixel values of the absolute difference in descending order; suppose the frequency of occurrence of the pixel value (2,19,1) in the absolute difference is 900 and ranked first, the frequency of occurrence of (2,10,1) is 899 and ranked second, and the frequency of occurrence of (2,1,1) is 10 and ranked 1000, which is the lowest; then the pixel number of (2,19,1) is 1, the pixel number of (2,10,1) is 2, and the pixel number of (2,1,1) is 1000.
[0122] The method further includes step 326, calculating the absolute value of the difference of a plurality of images in the lens, summing up the absolute value of the difference of the plurality of images and sorting them in descending order according to the frequency, so as to obtain the pixel sequence number of the pixel difference of the lens.
[0123] Since different orders of magnitude of absolute difference values will be obtained when different iteration paths are selected during the calculation of absolute difference values of pixel values, different HCV containers will eventually be obtained by selecting appropriate iteration paths of pixel points, and the design of the HCV container will ultimately affect the compression effect.
[0124] According to the iteration path, the acquisition of the pixel sequence number of the pixel difference also includes: four square grids.
[0125] The four-grid difference comprises: step 33, dividing the pixel points in the flipped image frame into four grids, performing difference calculation on the four-grid pixel frame, and obtaining the pixel difference and the corresponding sign bit and difference mark bit;
[0126] Step 33 specifically includes:
[0127] Step 331, dividing the image frame into a number of four-square grids according to 2x2 pixel points;
[0128] like Figure 6 The frame pixels shown are 8x8, which are divided into 16 quadrilaterals. The quadrilaterals are used as the basic unit for calculation. The order of the quadrilaterals is from left to right: the first quadrilateral in the first row, the second quadrilateral in the second row, the quadrilateral in the ath row, the last quadrilateral in the previous row, and the first quadrilateral in the current row.
[0129] Step 332: Taking a pixel point in the first quartet as a global reference pixel point, performing difference calculations between the non-global reference pixel points in the first quartet and the global reference pixel points, respectively, to obtain the absolute value and sign bit of the difference corresponding to the non-global reference pixel points;
[0130] Figure 6 The first row of each quartet is positions 1 and 2 respectively; the second row is positions 3 and 4 respectively; for example, if the pixel at position 2 in the first quartet is taken as the global reference pixel, the pixel value is (10,20,8), the pixel value retained by the global reference pixel is (10,20,8), the sign bit is 111, and the difference mark bit is 2; the non-global reference pixel, that is, the pixel values of positions 1, 3, and 4 in the first quartet are (10,20,8), (10,20,7), and (10,20,9) respectively, then the corresponding difference absolute values and sign bits are [(0,0,1);333], [(0,0,1);332], and [(0,0,1);331] respectively.
[0131] Step 333: Taking a certain pixel point in the second quartet as a local reference pixel point, performing difference calculation between the local reference pixel point in the second quartet and the global reference pixel point, performing difference calculation between the non-local reference pixel point in the second quartet and the local reference pixel point in the second quartet, and obtaining the absolute value and sign bit of the difference corresponding to all the pixels;
[0132] For example, Figure 6Take the pixel at position 1 in the second quartet as the local reference pixel, and the pixel value is (4,23,8). The absolute value and sign of the difference of the local reference pixel in the second quartet are [(6,3,0);213]. Let the pixel values of positions 2, 3, and 4 of the non-local reference pixel in the second quartet be (4,22,8), (4,21,8), and (5,21,8), respectively. The absolute value and sign of the difference of the non-local reference pixel in the second quartet are [(0,1,0);323], [(0,2,0);323], and [(1,2,0);123].
[0133] Step 334: find the corresponding position of the local reference pixel point in the third quadrilateral based on the position of the local reference pixel point in the second quadrilateral, perform difference calculation between the local reference pixel point in the third quadrilateral and the local reference pixel point in the second quadrilateral, perform difference calculation between the non-local reference pixel point in the third quadrilateral and the local reference pixel point in the third quadrilateral, and obtain the absolute value and sign bit of the difference of all the pixels in the third quadrilateral;
[0134] Figure 6 The position of the local reference pixel in the second quartet is 1, and the pixel value is (4,23,8); then the position of the corresponding local reference pixel in the third quartet is also 1, that is, the pixel value is (4,23,7), so the absolute value and sign bit of the difference of the local reference pixel in the third quartet are [(0,0,1);332]; the pixel values of pixel positions 2, 3, and 4 in the third quartet are (4,20,7), (4,23,6), and (5,23,7), respectively, and the corresponding absolute value and sign bit of the difference are [(0,3,0);323], [(0,0,1);332], and [(1,0,0);133], respectively.
[0135] Step 335, continuously repeating step 334 until the absolute value and sign bit of the difference of all pixels in the last four-square grid are calculated;
[0136] Step 336: sort the frequencies of occurrence of the absolute values of the difference values in descending order to obtain the pixel numbers of the pixel differences.
[0137] The pixel difference also includes: Nine-square grid; that is, the image frame is divided into several nine-square grids according to the 3x3 pixel frame; for example: the frame pixel is 1080x1080, and a total of 72900 nine-square grids are divided, and the nine-square grid is used as the basic unit for calculation; Figure 7 This is a schematic diagram of the nine-square grid.
[0138] The pixel difference also includes: line frames; that is, the image frame is divided into several line frames according to the lines of the pixel frame; for example: the frame pixel is 1080x1080, and a total of 1080 line frames are divided, and the calculation is performed with the line frame as the basic unit; Figure 8This is a schematic diagram of a row frame.
[0139] The pixel difference also includes: column frames; that is, the image frame is divided into a number of column frames according to the rows of the pixel frame; for example: the frame pixel is 1080x1080, and a total of 1080 column frames are divided, and the calculation is performed with the column frame as the basic unit; Fig. 9 A schematic diagram of a column frame.
[0140] The pixel difference also includes: diagonal frames; that is, the image frame is divided into a number of diagonal frames according to the rows of the pixel frame; for example: the frame pixel is 1080x1080, and a total of 1080 diagonal frames are divided, and the calculation is performed with the diagonal frame as the basic unit.
[0141] Table 1 Comparison of the total number of pixel numbers based on pixel values and pixel difference values in different scenes
[0142] Scene Type File size (GB) Shot duration(s) The total number of pixel numbers of pixel values The total number of pixel numbers of pixel difference Reduction rate High character detail 1.4 2 247485 26527 10.72% Highly complex scenes 1.4 2 183807 70751 38.49% High overall color 1.4 2 400695 105762 26.39% High over color 1.4 2 384757 165257 42.95% High Particles 1.4 2 54949 26456 48.15% High Dynamics 1.4 2 107012 32195 30.09%
[0143] Table 1 compares the total number of pixel numbers of pixel values and pixel difference values corresponding to 6 shots of the same duration and different scenes; among them, the pixel number of the pixel difference value adopts the difference of the four-grid pixel frame. By comparing with the total number of pixel numbers of the pixel value, it can be seen that the total number of pixel values of the four-grid method is significantly reduced, which reduces the number of pixels with different pixel values in the image and increases the number of pixels with the same pixel value, so that irrelevant pixels are associated, reducing the amount of data, and facilitating the subsequent compression of the image within or between frames.
[0144] 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. A color distribution-based encoding method, characterized in that: The following steps are involved: Step 1: Obtain pixel values of all pixel points of several frames of images in a certain lens; Step 2: Sort pixel values in descending order according to their frequency of occurrence to obtain pixel numbers; Step 3: Calculate the container number according to the pixel number and construct the spatial coordinates of the pixel value corresponding to the pixel number in the HCV container; The formula for calculating the container number and constructing the spatial coordinates of the pixel value corresponding to the pixel number in the HCV container is: j=└(i-1) / (H t *C t *V t )┘; h i =└((i-1)-(j*H t *C t *V t )) / (C t *V t )┘; c i =└(i-1-(j*H t *C t *V t )-(h i *C t *V t )) / V t ┘; v i =└i-1-(j*H t *C t *V t )-(h i *C t *V t )-(c i *V t )┘; Where └┘ means rounding down; i is the pixel number of the pixel value; j is the container number; H t is the H component value of the HCV container, C t is the C component value of the HCV container, V t is the V component value of the HCV container; h i ,c i ,v i is the spatial coordinate in the HCV container.
2. The color distribution-based encoding method according to claim 1, characterized in that: The second formula for calculating the container number and constructing the spatial coordinates of the pixel value corresponding to the pixel number in the HCV container is: count_avg=└(all_color / D)+1┘; j=└(i-1) / count_avg┘; h i =└(i-1-count_avg*j) / (C t *V t )┘; c i =└(i-1-count_avg*j–h i *C t *V t ) / V t ┘; v i =└i-1-count_avg*j–h i *C t *V t –c i *V t ┘; Where D is the number of custom spatial containers; all_color is the total number of pixel values; i is the pixel number of the pixel value; j is the container number; H t is the H component value of the HCV container, C t is the C component value of the HCV container, V t is the V component value of the HCV container; h i ,c i ,v i is the spatial coordinate in the HCV container; └┘ means rounding down.
3. The color distribution-based encoding method according to claim 1, characterized in that: Formula 3 for calculating the container number and constructing the spatial coordinates of the pixel value corresponding to the pixel number in the HCV container is: count_avg=└(all_color / D)+1┘; m=┌count_avg 1 / 3 ┐; j = └i / count_avg┘; h i =└count_avg / m 2 ┘; c i =└(count_avg–h i *m 2 ) / m┘; in i =└count_avg–h i *m 2 –c i *m┘; Among them, ┌┐ is rounded up; all_color is the total number of pixel values; m represents the average value of the total class of pixel values corresponding to the H, C, and V component values; i is the pixel number of the pixel value; j represents the container number; H t is the H component value of the HCV container, C t is the C component value of the HCV container, V t is the V component value of the HCV container; h i ,c i ,v i is the spatial coordinate in the HCV container; └┘ means rounding down.
4. The color distribution-based encoding method according to claim 1, characterized in that: Step three also includes: calculating the container number according to the pixel number of the pixel difference value and constructing the spatial coordinates of the pixel value corresponding to the pixel number in the HCV container; The acquisition of the pixel sequence number of the pixel difference includes: Step 31, obtaining a frame image, dividing the frame image into four regions on average; performing flipping processing on the four region images; Step 32, performing difference calculation on the pixels in the flipped image frame to obtain the pixel difference and the corresponding sign bit and difference mark bit; Frame-by-frame difference, the steps of frame-by-frame difference are as follows: Step 321: taking a certain pixel point in a certain frame as an initial reference pixel point, randomly selecting a pixel point from non-initial reference pixel points as a first iteration pixel point, performing difference calculation between the first iteration pixel point and the initial reference pixel point, and obtaining a difference absolute value of the first iteration pixel point, a sign bit of the first iteration pixel point, and a difference flag bit of the first iteration pixel point; Step 322: randomly select a pixel point from non-initial reference pixel points and non-first iteration pixel points as a second iteration pixel point, perform difference calculation between the second iteration pixel point and the first reference pixel point, and obtain a difference absolute value of the second iteration pixel point, a sign bit of the second iteration pixel point, and a difference flag bit of the second iteration pixel point; wherein the first reference pixel point is any one of the initial reference pixel point and the first iteration pixel point; Step 323: randomly select a pixel point from non-initial reference pixel points and non-first and second iteration pixel points as a third iteration pixel point, perform difference calculation between the third iteration pixel point and the second reference pixel point, and obtain a difference absolute value of the third iteration pixel point, a sign bit of the third iteration pixel point, and a difference flag bit of the third iteration pixel point, wherein the second reference pixel point is any one of the initial reference pixel point and the first and second iteration pixel points; Step 324, and so on, select the M-1th iteration pixel point and the M-2th reference pixel point, and calculate the difference absolute value, sign bit and difference mark bit of the M-1th iteration pixel point; wherein M is the total number of pixels in a certain frame; Step 325: sort the frequencies of occurrence of the absolute values of the difference values in descending order to obtain the pixel numbers of the pixel differences.
5. The color distribution-based encoding method according to claim 4, characterized in that: The method further includes: step 326, calculating the absolute value of the difference of a plurality of images in the lens, and summing the absolute values of the difference of the plurality of images and then sorting them in descending order of frequency to obtain the pixel sequence number of the pixel difference of the lens.
6. The color distribution-based encoding method according to claim 4, characterized in that: The acquisition of the pixel number of the pixel difference value also includes: four squares; The four-grid difference comprises: step 33, dividing the pixel points in the flipped image frame into four grids, performing difference calculation on the four-grid pixel frame, and obtaining the pixel difference and the corresponding sign bit and difference mark bit; Step 33 specifically includes: Step 331, dividing the image frame into a number of four-square grids according to 2x2 pixel points; Step 332: Taking a pixel point in the first quartet as a global reference pixel point, performing difference between the non-global reference pixel points in the first quartet and the global reference pixel points, respectively, to obtain the absolute value and sign bit of the difference corresponding to the non-global reference pixel points; Step 333: Taking a certain pixel point in the second quartet as a local reference pixel point, performing a difference between the local reference pixel point in the second quartet and the global reference pixel point, performing a difference between the non-local reference pixel point in the second quartet and the local reference pixel point in the second quartet, and obtaining the absolute value and sign bit of the difference corresponding to all the pixels; Step 334: find the corresponding position of the local reference pixel point in the third quadrilateral based on the position of the local reference pixel point in the second quadrilateral, perform difference between the local reference pixel point in the third quadrilateral and the local reference pixel point in the second quadrilateral, perform difference between the non-local reference pixel point in the third quadrilateral and the local reference pixel point in the third quadrilateral, and obtain the absolute value and sign bit of the difference of all the pixels in the third quadrilateral; Step 335, repeating step 334 until the absolute value and sign bit of the difference of all pixels in the last four-square grid are obtained; Step 336: Sort the frequencies of occurrence of the absolute values of the difference values in descending order to obtain the pixel numbers of the pixel differences.
Citation Information
Patent Citations
Color coding method based on vision
CN118714330A
Method and equipment for compressing and decompressing image
CN101616320A
Image processing method, electronic equipment and storage medium
CN117412055A