High-performance compression method and system based on codebook training
Through codebook statistics and encoding technology, basic elements are extracted from image data and codebooks are generated for image compression, which solves the problem that traditional algorithms fail to make full use of image redundancy and deep learning algorithms to sacrifice time, and realizes efficient image storage and transmission.
Patent Information
- Application Number
- CN202411133483.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2044-08-19
AI Technical Summary
Traditional compression algorithms fail to make full use of the redundancy of two-dimensional image information, and deep learning-based compression algorithms sacrifice time in exchange for compression performance, making it difficult to use in practice.
The frequency information of basic elements is extracted from the image data through codebook statistics, a codebook is generated, and the image is encoded and decoded using the codebook to achieve high-performance image compression.
Reduces image storage space requirements, reduces network transmission bandwidth, and improves decoding performance and online preview performance.
Smart Images

Figure CN118660166B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a high-performance compression method based on codebook training and a system thereof. Background Art
[0002] In the digital age, the explosive growth of data has brought great challenges to storage. As a common form of information representation, images are widely used in various fields. The introduction of compression technology has made it possible to solve the storage problem. The purpose of compression is to use as few bits as possible to represent as much real data information as possible.
[0003] Traditional compression algorithms fail to fully utilize the redundancy of two-dimensional image information, while deep learning-based compression algorithms are more like sacrificing time in exchange for compression performance, making them difficult to use in practice. Summary of the invention
[0004] The present invention aims to at least improve one of the technical problems existing in the prior art. To this end, the present invention proposes a high-performance compression method and system based on codebook training.
[0005] According to the first aspect of the present invention, a high-performance compression method based on codebook training is provided, which includes:
[0006] Step S100, codebook statistics, obtaining a preset proportion of image data from the image data set to be compressed to count the frequency information of basic elements of the image, and generating a codebook based on the frequency information combined with the encoding method;
[0007] Step S200, image coding, dividing the image into regions using the basic elements in the codebook, and then coding the image in combination with the coding results of the basic elements in the codebook to obtain an image coding result;
[0008] Step S300: image decoding, decoding is performed according to the correspondence between the image encoding result and the encoding and basic elements in the codebook.
[0009] In a possible implementation manner of the first aspect, step S100 specifically includes the following content:
[0010] Step S110, define the image data set to be compressed as M , in the image dataset to be compressed M Randomly extract image sample data of proportion Q as statistics;
[0011] Step S120, preprocessing the image sample data of the extraction ratio Q to obtain difference image data of the ratio Q image;
[0012] Step S130, assuming that the image sample data type is bits, the obtained difference image data is processed according to the high bit and low The bits are evenly divided, high The bit is called profile layer K, low The first bit is called the detail layer L;
[0013] Step S140: Perform the first processing on the profile layer K to obtain the first codebook ;
[0014] Step S150: Perform the second processing on the detail layer L to obtain the second codebook ;
[0015] Step S160: Perform the third processing on the detail layer L to obtain the third codebook .
[0016] In a possible implementation manner of the first aspect, step S200 specifically includes the following content:
[0017] Step S210: Get the image data set to be compressed M Image sample data in G As input, the data type is Bit;
[0018] Step S220: image sample data G Perform preprocessing to obtain difference image data;
[0019] Step S230: the obtained difference image data is processed according to the height bit and low The bits are evenly divided, high Profile Layer K G ,Low Detail layer L G ;
[0020] Step S240: Read the first codebook , at the contour layer K G In the first codebook, The basic elements in the contour layer K are found G There are basic elements in the contour layer K. G The position coordinates in And the corresponding code;
[0021] Step S250: Read the second codebook , at the detail layer L G In the second codebook, The basic elements in
[0022] Step S260, setting the encoding flag F, wherein the size of the encoding flag F and the detail layer L G The same, initialized to 0, execute the first judgment process;
[0023] The performing of the first judgment process specifically includes:
[0024] Discovery detail layer L G If there is a basic element in the image, if the corresponding position in the flag F is 0, record the position coordinates of the basic element in the image. And the corresponding code, at the same time, all areas of the size of the basic element in the same position corresponding to the flag bit F are built-in 1;
[0025] If the corresponding position in the flag bit F is 1, step S260 is repeated until the detail layer L G There is no second codebook in The basic elements in.
[0026] Step S270: Read the third codebook , at the detail layer L G In the third codebook, The basic elements in the second judgment process are executed;
[0027] The performing of the second judgment process specifically includes:
[0028] Discovery detail layer L G If there is a basic element in the image, if the corresponding position in the flag F is 0, record the position of the basic element in the image. And the corresponding code, at the same time, all areas of the size of the basic element in the same position corresponding to the flag bit F are built-in 1;
[0029] If the corresponding position in the flag bit F is 1, step S270 is repeated until the detail layer L G There is no third codebook in The basic elements in.
[0030] Step S280, finally, the position coordinates , location coordinates , location coordinates By selecting respective encoding methods for encoding and combining them with the encoding of respective codebooks, image compression can be completed.
[0031] In a possible implementation manner of the first aspect, step S300 specifically includes the following content:
[0032] Step S310: Separate the codes of the contour layer K and the detail layer L, and decompress each layer separately, that is, obtain separate position coordinates. Encoding plus element encoding, separate position coordinates Encoding plus element encoding, separate position coordinates Encoding plus element encoding;
[0033] Step S320, decompress the position codes respectively, and the element codes corresponding to the position codes are determined according to the read codebook and filled into the corresponding positions, and finally a difference map after preprocessing is obtained;
[0034] Step S330: Perform inverse calculation based on the difference image to restore the original image.
[0035] In a possible implementation manner of the first aspect, in step S140, the first processing process specifically includes:
[0036] Step S1401, select basic elements The maximum size is , and then count the different Elements of size Quantity, the result of element convolution equal to the sum of squares is considered to be the same element;
[0037] Step S1402, the element size is reduced in sequence ( , , ,……, ), repeat step S1401 until the element size is .
[0038] Step S1403: based on all size elements The frequency statistics information of the basic element S is encoded.
[0039] Step S1404: Obtain and save the first codebook .
[0040] In a possible implementation manner of the first aspect, in step S150, the second processing process specifically includes:
[0041] Step S1501, select basic elements R The maximum size is , and then count the different Elements of size Quantity, the result of element convolution equal to the sum of squares is considered to be the same element;
[0042] Step S1502, the element size is reduced in sequence ( , , ,……, ), repeat step S1501 until the element size is ;
[0043] Step S1503: based on all size elements R Frequency statistics of basic elements R Encoding;
[0044] Step S1504: Obtain and save the second codebook .
[0045] In a possible implementation manner of the first aspect, in step S160, the third processing process specifically includes:
[0046] Step S1601, select basic elements D The maximum size is , and then count the different Elements of size quantity;
[0047] Step S1602: based on all size elements D Frequency statistics of basic elements D to encode.
[0048] Step S1603: Obtain and save the third codebook .
[0049] According to the high-performance compression method based on codebook training of the embodiment of the present invention, the basic elements in the image are counted from the partial data image through codebook statistics, and then the basic elements are encoded according to the statistical information, so that the subsequent images only need to be represented by the basic elements, thereby reducing the information redundancy in the image storage process, thereby reducing the image storage space. In addition, the encoding of the basic elements can further reduce the storage space. By encoding the image according to the codebook through image encoding, on the one hand, the image storage space can be reduced, and on the other hand, due to the existence of the codebook, data can be pre-transmitted in advance during the network transmission process, thereby reducing the bandwidth requirements for image network transmission; through the image decoding process, decoding is performed according to the encoding result and the codebook. Due to the existence of the codebook, the algorithm complexity can be reduced in the decoding process, and the decoding performance can be improved, thereby improving the performance of the online preview on the network.
[0050] A high-performance compression system based on codebook training according to an embodiment of the second aspect of the present invention comprises:
[0051] A codebook statistics module is used to obtain a preset proportion of image data from the image data set to be compressed to count the frequency information of basic elements of the image, and generate a codebook based on the frequency information combined with the encoding method;
[0052] An image encoding module, used to divide the image into regions using the basic elements in the codebook, and then encode the image in combination with the encoding results of the basic elements in the codebook to obtain an image encoding result;
[0053] The image decoding module is used to decode the image according to the corresponding relationship between the image encoding result and the encoding and basic elements in the code book.
[0054] A computer device according to an embodiment of the third aspect of the present invention includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the high-performance compression method based on codebook training as described above is implemented.
[0055] According to a computer storage medium of an embodiment of the fourth aspect of the present invention, instructions are stored in the computer storage medium, and when the instructions are executed on a computer, the computer executes the high-performance compression method based on codebook training as described above.
[0056] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0058] Figure 1 is a flow chart of a high-performance compression method based on codebook training according to an embodiment of the present invention;
[0059] Figure 2 is a simplified diagram of steps in a codebook statistics process of a high-performance compression method based on codebook training according to an embodiment of the present invention;
[0060] Figure 3 is a simplified diagram of steps in an image encoding process of a high-performance compression method based on codebook training according to an embodiment of the present invention;
[0061] Figure 4 is a simplified diagram of steps in an image decoding process of a high-performance compression method based on codebook training according to an embodiment of the present invention;
[0062] Figure 5 1 is a schematic diagram of obtaining a predicted value X according to a high-performance compression method based on codebook training according to an embodiment of the present invention. DETAILED DESCRIPTION
[0063] The embodiments of the present invention are described in detail below. The embodiments described with reference to the accompanying drawings are exemplary. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0064] It should be noted that when an element is referred to as being "fixed to" another element, it may be directly on the other element or there may be an intermediate element. When an element is considered to be "connected to" another element, it may be directly connected to the other element or there may be an intermediate element at the same time.
[0065] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present invention belongs. The terms used herein in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.
[0066] The terms "first", "second", "third", etc. in the specification and claims of the present application and the drawings are used to distinguish different objects rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a series of steps or units are included, or optionally, steps or units not listed are included, or optionally, other steps or units inherent to these processes, methods, products or devices are included.
[0067] Only the part relevant to the present application is shown in the accompanying drawings, but not all of the content. Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processing or methods depicted as flow charts. Although the flow chart describes each operation (or step) as a sequential process, many of the operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of each operation can be rearranged. When its operation is completed, the process can be terminated, but it can also have additional steps not included in the accompanying drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.
[0068] The terms "component", "module", "system", "unit", etc. used in this specification are used to represent computer-related entities, hardware, firmware, a combination of hardware and software, software, or software in execution. For example, a unit can be, but is not limited to, a process running on a processor, a processor, an object, an executable file, an execution thread, a program, and / or distributed between two or more computers. In addition, these units can be executed from various computer-readable media having various data structures stored thereon. Units can communicate through local and / or remote processes, for example, based on signals having one or more data packets (e.g., data from a second unit interacting with another unit in a local system, a distributed system, and / or a network. For example, the Internet interacts with other systems via signals).
[0069] Traditional compression algorithms fail to fully utilize the redundancy of two-dimensional information in images, and compression algorithms based on deep learning are more like sacrificing time in exchange for compression performance, which is difficult to use in practice. Complex data is composed of basic units, and image data should be no exception. Therefore, it is necessary to find the basic elements that make up the image data as much as possible to achieve detailed decomposition of the image, which has the potential to improve image decoding performance. The statistics of the basic elements of the image can be achieved through codebook training, and high-performance compression can be achieved in combination with appropriate encoding methods.
[0070] Example 1
[0071] See also Figures 1 to 4 As shown, this embodiment provides a high-performance compression method based on codebook training, which includes:
[0072] Step S100, codebook statistics, obtaining a preset proportion of image data from the image data set to be compressed to count the frequency information of basic elements of the image, and generating a codebook according to the frequency information combined with the encoding method.
[0073] Step S200, image coding, dividing the image into regions using the basic elements in the codebook, and then coding the image in combination with the coding results of the basic elements in the codebook to obtain an image coding result;
[0074] Step S300: image decoding, decoding is performed according to the correspondence between the image encoding result and the encoding and basic elements in the codebook.
[0075] In a possible implementation manner of the first aspect, step S100 specifically includes the following content:
[0076] Step S110, define the image data set to be compressed as M , in the image dataset to be compressed M Randomly extract image sample data of proportion Q as statistics;
[0077] Step S120, preprocessing the image sample data of the extraction ratio Q to obtain difference image data of the ratio Q image;
[0078] Step S130, assuming that the image sample data type is bits, the obtained difference image data is processed according to the high bit and low The bits are evenly divided, high The bit is called profile layer K, low The first bit is called the detail layer L;
[0079] Step S140: Perform the first processing on the profile layer K to obtain the first codebook ;
[0080] Step S150: Perform the second processing on the detail layer L to obtain the second codebook ;
[0081] Step S160: Perform the third processing on the detail layer L to obtain the third codebook .
[0082] In a possible implementation manner of the first aspect, step S200 specifically includes the following content:
[0083] Step S210: Get the image data set to be compressed M Image sample data in G As input, the data type is Bit;
[0084] Step S220: image sample data G Perform preprocessing to obtain difference image data;
[0085] Step S230: the obtained difference image data is processed according to the height bit and low The bits are evenly divided, high Profile Layer K G ,Low Detail layer L G ;
[0086] Step S240: Read the first codebook , at the contour layer K G In the first codebook, The basic elements in the contour layer K are found G There are basic elements in the contour layer K. G The position coordinates in And the corresponding code;
[0087] Step S250: Read the second codebook , at the detail layer L G In the second codebook, The basic elements in
[0088] Step S260, setting the encoding flag F, wherein the size of the encoding flag F and the detail layer L G The same, initialized to 0, execute the first judgment process;
[0089] The performing of the first judgment process specifically includes:
[0090] Discovery detail layer L G If there is a basic element in the image, if the corresponding position in the flag F is 0, record the position coordinates of the basic element in the image. And the corresponding code, at the same time, all areas of the size of the basic element in the same position corresponding to the flag bit F are built-in 1;
[0091] If the corresponding position in the flag bit F is 1, step S260 is repeated until the detail layer L G There is no second codebook in The basic elements in.
[0092] Step S270: Read the third codebook , at the detail layer L G In the third codebook, The basic elements in the second judgment process are executed;
[0093] The performing of the second judgment process specifically includes:
[0094] Discovery detail layer L G If there is a basic element in the image, if the corresponding position in the flag F is 0, record the position of the basic element in the image. And the corresponding code, at the same time, all areas of the size of the basic element in the same position corresponding to the flag bit F are built-in 1;
[0095] If the corresponding position in the flag bit F is 1, step S270 is repeated until the detail layer L G There is no third codebook in The basic elements in.
[0096] Step S280, finally, the position coordinates , location coordinates , location coordinates By selecting respective encoding methods for encoding and combining them with the encoding of respective codebooks, image compression can be completed.
[0097] It should be noted that the step S300 specifically includes the following contents:
[0098] Step S310: Separate the codes of the contour layer K and the detail layer L, and decompress each layer separately, that is, obtain separate position coordinates. Encoding plus element encoding, separate position coordinates Encoding plus element encoding, separate position coordinates Encoding plus element encoding;
[0099] Step S320, decompress the position codes respectively, and the element codes corresponding to the position codes are determined according to the read codebook and filled into the corresponding positions, and finally a difference map after preprocessing is obtained;
[0100] Step S330: Perform inverse calculation based on the difference image to restore the original image.
[0101] It should be noted that, in step S140, the first processing process specifically includes:
[0102] Step S1401, select basic elements The maximum size is , and then count the different Elements of size Quantity, the result of element convolution equal to the sum of squares is considered to be the same element;
[0103] Step S1402, the element size is reduced in sequence ( , , ,……, ), repeat step S1401 until the element size is .
[0104] Step S1403: based on all size elements The frequency statistics information of the basic element S is encoded.
[0105] Step S1404: Obtain and save the first codebook .
[0106] In a possible implementation manner of the first aspect, in step S150, the second processing process specifically includes:
[0107] Step S1501, select basic elements R The maximum size is , and then count the different Elements of size Quantity, the result of element convolution equal to the sum of squares is considered to be the same element;
[0108] Step S1502, the element size is reduced in sequence ( , , ,……, ), repeat step S1501 until the element size is ;
[0109] Step S1503: based on all size elements R Frequency statistics of basic elements R Encoding;
[0110] Step S1504: Obtain and save the second codebook .
[0111] It should be noted that, in step S160, the third processing process specifically includes:
[0112] Step S1601, select basic elements D The maximum size is , and then count the different Elements of size quantity;
[0113] Step S1602: based on all size elements D Frequency statistics of basic elements D to encode.
[0114] Step S1603: Obtain and save the third codebook .
[0115] According to the high-performance compression method based on codebook training of the embodiment of the present invention, the basic elements in the image are counted from the partial data image through codebook statistics, and then the basic elements are encoded according to the statistical information, so that the subsequent images only need to be represented by the basic elements, thereby reducing the information redundancy in the image storage process, thereby reducing the image storage space. In addition, the encoding of the basic elements can further reduce the storage space. By encoding the image according to the codebook through image encoding, on the one hand, the image storage space can be reduced, and on the other hand, due to the existence of the codebook, data can be pre-transmitted in advance during the network transmission process, thereby reducing the bandwidth requirements for image network transmission; through the image decoding process, decoding is performed according to the encoding result and the codebook. Due to the existence of the codebook, the algorithm complexity can be reduced in the decoding process, and the decoding performance can be improved, thereby improving the performance of the online preview on the network.
[0116] In this embodiment, a specific implementation example is provided based on the compression method in Embodiment 1, including:
[0117] Codebook statistics process ①, obtain a preset proportion of image data from the image data set to be compressed to count the frequency information of the basic elements of the image, and generate a codebook based on the frequency information combined with the encoding method, such as Figure 2 As shown;
[0118] Image encoding process ②, the image is divided into regions using the basic elements in the codebook, and then the image is encoded in combination with the encoding results of the basic elements in the codebook to obtain the image encoding result, such as Figure 3 As shown;
[0119] Image decoding process ③, decoding is performed according to the correspondence between the image encoding result and the encoding and basic elements in the codebook, such as Figure 4 shown.
[0120] Among them: the codes involved in all the above processes can be selected independently according to the specific scenarios, and the changes in the codes are also within the protection scope of the present invention.
[0121] 150 RGB medical data images are selected as the data set, and the image size is 1200*1600.
[0122] Execute codebook statistical process ① and take the first 200 images of the data set as statistical data.
[0123] Preprocessing:
[0124] The first step is to convert the RGB channel to the YUV channel;
[0125] The second step is to perform difference processing on each channel based on the prediction of adjacent pixels. The prediction method in this example is as follows:
[0126] like Figure 5 As shown, the predicted value X is:
[0127] ,
[0128] Among them, a represents the pixel value adjacent to the left of pixel X, b represents the pixel value adjacent to the upper left corner of pixel X, c represents the pixel value adjacent to the top of pixel X, and other represents the pixel value except and In the remaining cases.
[0129] Then the predicted value and the original image value are subtracted to get the difference number, and then all the difference numbers are mapped to positive numbers. For the difference number less than or equal to 0, the difference number plus the absolute value multiplied by 2 and then added by 1 is executed. For the difference number greater than or equal to 0, the difference number is directly multiplied by 2 and then added by 1:
[0130] After obtaining the predicted difference image, it is evenly divided into the upper 4 bits and the lower 4 bits. The upper 4 bits are called the contour layer K and the lower 4 bits are called the detail layer L.
[0131] Set the maximum size of the basic element S to 4*4, and use it to search in all contour layers K, count the number of times each element appears, and then reduce the size of the basic element S (3*4, 4*3, 2*4, ..., 1*1) and continue searching until the size is 1*1.
[0132] According to the frequency of occurrence of each element, Huffman coding is selected to encode each element and finally saved as the first codebook B s .
[0133] The size of the basic element R is set to 2*2, and then it is searched in all detail layers L to count the number of occurrences of each element.
[0134] According to the frequency of occurrence of each element, Huffman coding is selected to encode each element and finally saved as the second codebook B r .
[0135] The size of the basic element D is set to 1*1, and then it is searched in all detail layers L to count the number of occurrences of each element.
[0136] According to the frequency of occurrence of each element, Huffman coding is selected to encode each element and finally saved as the third codebook B d .
[0137] Execute the image decoding process ②, take 100 images after 200 images in the data set as tests, and the preprocessing process is the same as the preprocessing process of the codebook statistical process ①. Similarly, each image obtains the contour layer K and the detail layer L.
[0138] Input the first codebook B s , traverse and search the first codebook B in the contour layer K s The basic element S in the image is initialized, and the encoding map flag F of the image size is 0. For the found element, if the encoding flag F at the position is 0, the position coordinate P in the image is recorded. s And its corresponding element encoding, and set the encoding flag F to 1, otherwise skip it directly.
[0139] Input the second codebook B r , traverse and search the second codebook B in the detail layer L r The basic element R in the image is initialized, and the encoding flag bit F of the image size is 0. For the found element, if the encoding flag bit F at the position is 0, the position coordinate P in the image is recorded. rAnd its corresponding element encoding, and set the encoding flag F to 1, otherwise skip it directly.
[0140] Input the third codebook B d , traverse and search the third codebook B in the detail layer L d For the found element, if the encoding flag F at the position is 0, the position coordinate P recorded in the image is d and its corresponding element encoding, and set the encoding flag F to 1, otherwise skip it directly.
[0141] Finally, the recorded position information (position coordinates P s , position coordinates P r , position coordinates P d ) Choose to use Columbus encoding and combine it with the original element encoding to complete the encoding of the image.
[0142] The compression performance comparison of this example method and common algorithms on 50 test images is shown in Table 1.
[0143] Table 1: Comparison of compression performance between this example and common algorithms
[0144]
[0145] According to Table 1, the compression effect achieved according to the idea of the present invention is better than that of the traditional algorithm.
[0146] Execute the image decompression process ③, first separate the codes of the contour layer K and the detail layer L, and decompress them separately, that is, obtain the separate position coordinate Ps code plus element code, the separate position coordinate Pr code plus element code, and the separate position coordinate Pd code plus element code respectively. Figure 3 shown.
[0147] Then the position codes are decompressed respectively, and the corresponding element codes are determined according to the read codebook and filled into the corresponding positions. Finally, the difference map after preprocessing is obtained. All the preprocessing processes are reversible, so the original image can be restored.
[0148] Example 2
[0149] This embodiment provides a high-performance compression system based on codebook training, which includes:
[0150] The codebook statistics module is used to obtain a preset proportion of image data from the image data set to be compressed to count the frequency information of the basic elements of the image, and generate a codebook based on the frequency information combined with the encoding method, which specifically includes:
[0151] Define the image dataset to be compressed as M, in the image dataset to be compressed M Randomly extract image sample data of proportion Q as statistics;
[0152] Preprocessing the image sample data of the extraction ratio Q to obtain difference image data of the ratio Q image;
[0153] Assume that the image sample data type is bits, the obtained difference image data is processed according to the high bit and low The bits are evenly divided, high The bit is called profile layer K, low The first bit is called the detail layer L;
[0154] Perform the first processing on the contour layer K to obtain the first codebook ;
[0155] The second processing is performed on the detail layer L to obtain the second codebook ;
[0156] The third processing is performed on the detail layer L to obtain the third codebook ;
[0157] The image encoding module is used to divide the image into regions using the basic elements in the codebook, and then encode the image in combination with the encoding results of the basic elements in the codebook to obtain the image encoding result, specifically including:
[0158] Get the image dataset to be compressed M Image sample data in G As input, the data type is Bit;
[0159] For image sample data G Perform preprocessing to obtain image sample data G The difference image data;
[0160] The obtained difference image data is processed according to the high bit and low The bits are evenly divided, high Profile Layer K G ,Low Detail layer L G ;
[0161] Read the first codebook , at the contour layer K G In the first codebook, The basic elements in the contour layer K are found G There are basic elements in the contour layer K. G The position coordinates in And the corresponding code;
[0162] Read the second codebook , at the detail layer L G In the second codebook, The basic elements in
[0163] Set the encoding flag F, where the size of the encoding flag F and the detail layer L G The same, initialized to 0, execute the first judgment process;
[0164] The performing of the first judgment process specifically includes:
[0165] Discovery detail layer L G If there is a basic element in the image, if the corresponding position in the flag F is 0, record the position coordinates of the basic element in the image. And the corresponding code, at the same time, all areas of the size of the basic element in the same position corresponding to the flag bit F are built-in 1;
[0166] If the corresponding position in the flag F is 1, repeat the above steps until the detail layer L G There is no second codebook in The basic elements in
[0167] Read the third codebook , at the detail layer L G In the third codebook, The basic elements in the second judgment process are executed;
[0168] The performing of the second judgment process specifically includes:
[0169] Discovery detail layer L G If there is a basic element in the image, if the corresponding position in the flag F is 0, record the position of the basic element in the image. And the corresponding code, at the same time, all areas of the size of the basic element in the same position corresponding to the flag bit F are built-in 1;
[0170] If the corresponding position in the flag F is 1, repeat the above steps until the detail layer L G There is no third codebook in The basic elements in
[0171] Finally, the position coordinates , location coordinates , location coordinates Select each encoding method for encoding, and then combine the encoding of each codebook to complete the image compression;
[0172] The image decoding module is used to decode the image according to the corresponding relationship between the image encoding result and the encoding and basic elements in the code book.
[0173] Example 3
[0174] This embodiment provides a computer device, which includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the high-performance compression method based on codebook training as described above is implemented.
[0175] Example 4
[0176] This embodiment provides a computer storage medium, wherein the computer storage medium stores instructions, and when the instructions are executed on a computer, the computer executes the high-performance compression method based on codebook training as described above.
[0177] In the description of the present invention, it is to be understood that the terms “center”, “longitudinal”, “lateral”, “length”, “width”, “thickness”, “up”, “down”, “front”, “back”, “left”, “right”, “vertical”, “horizontal”, “top”, “bottom”, “inside”, “outside”, “clockwise”, “counterclockwise”, “axial”, “radial”, “circumferential”, etc., indicating orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation to the invention.
[0178] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example.
[0179] Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Mentioning "embodiment" in this article means that the specific features, structures or characteristics described in conjunction with the embodiment may be included in at least one embodiment of the present embodiment application. The appearance of this phrase in various positions in the specification is not necessarily the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It can be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0180] Although the embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.
Claims
1. A high-performance compression method based on codebook training, It is characterized in that include: Step S100, codebook statistics, obtains a preset proportion of image data from the image data set to be compressed to count the frequency information of basic elements of the image, and generates a codebook based on the frequency information combined with the encoding method, wherein step S100 specifically includes the following contents: Step S110, define the image data set to be compressed as M , in the image dataset to be compressed M Randomly extract image sample data of proportion Q as statistics; Step S120, preprocessing the image sample data of the extraction ratio Q to obtain difference image data of the ratio Q image; Step S130, assuming that the image sample data type is bits, the obtained difference image data is processed according to the high bit and low The bits are evenly divided, high The bit is called profile layer K, low The first bit is called the detail layer L; Step S140: Perform the first processing on the profile layer K to obtain the first codebook ; Step S150: Perform the second processing on the detail layer L to obtain the second codebook ; Step S160: Perform the third processing on the detail layer L to obtain the third codebook ; Step S200, image coding, dividing the image into regions using the basic elements in the codebook, and then coding the image in combination with the coding results of the basic elements in the codebook to obtain an image coding result, wherein the step S200 specifically includes the following contents: Step S210: Get the image data set to be compressed M Image sample data in G As input, the data type is Bit; Step S220: image sample data G Perform preprocessing to obtain image sample data G The difference image data; Step S230: the obtained difference image data is processed according to the height bit and low The bits are evenly divided, high Profile Layer K G ,Low Detail layer L G ; Step S240: Read the first codebook , at the contour layer K G In the first codebook, The basic elements in the contour layer K are found G There are basic elements in the contour layer K. G The position coordinates in And the corresponding code; Step S250: Read the second codebook , at the detail layer L G In the second codebook, The basic elements in Step S260, setting the encoding flag F, wherein the size of the encoding flag F and the detail layer L G The same, initialized to 0, execute the first judgment process; The performing of the first judgment process specifically includes: Discovery detail layer L G If there is a basic element in the image, if the corresponding position in the flag F is 0, record the position coordinates of the basic element in the image. And the corresponding code, at the same time, all areas of the size of the basic element in the same position corresponding to the flag bit F are built-in 1; If the corresponding position in the flag bit F is 1, step S260 is repeated until the detail layer L G There is no second codebook in The basic elements in Step S270, read the third codebook , at the detail layer L G In the third codebook, The basic elements in the second judgment process are executed; The performing of the second judgment process specifically includes: Discovery detail layer L G If there is a basic element in the image, if the corresponding position in the flag F is 0, record the position of the basic element in the image. And the corresponding code, at the same time, all areas of the size of the basic element in the same position corresponding to the flag bit F are built-in 1; If the corresponding position in the flag bit F is 1, step S270 is repeated until the detail layer L G There is no third codebook in The basic elements in Step S280, finally, the position coordinates , location coordinates , location coordinates Select each encoding method for encoding, and then combine the encoding of each codebook to complete the image compression; Step S300: image decoding, decoding is performed according to the correspondence between the image encoding result and the encoding and basic elements in the codebook.
2. The high performance compression method based on codebook training according to claim 1, It is characterized in that The step S300 specifically includes the following contents: Step S310: Separate the codes of the contour layer K and the detail layer L, and decompress each layer separately, that is, obtain separate position coordinates. Encoding plus element encoding, separate position coordinates Encoding plus element encoding, separate position coordinates Encoding plus element encoding; Step S320, decompress the position codes respectively, and the element codes corresponding to the position codes are determined according to the read codebook and filled into the corresponding positions, and finally a difference map after preprocessing is obtained; Step S330: Perform inverse calculation based on the difference image to restore the original image.
3. The high performance compression method based on codebook training according to claim 1, It is characterized in that In step S140, the first processing process specifically includes: Step S1401, select basic elements The maximum size is , and then count the different Elements of size Quantity, the result of element convolution equal to the sum of squares is considered to be the same element; Step S1402, the element size is reduced in sequence ( , , ,……, ), repeat step S1401 until the element size is ; Step S1403: based on all size elements The frequency statistics information of the basic element S is encoded; Step S1404: Obtain and save the first codebook .
4. The high performance compression method based on codebook training according to claim 1, It is characterized in that In step S150, the second processing process specifically includes: Step S1501, select basic elements R The maximum size is , and then count the different Elements of size Quantity, the result of element convolution equal to the sum of squares is considered to be the same element; Step S1502, the element size is reduced in sequence ( , , ,……, ), repeat step S1501 until the element size is ; Step S1503: based on all size elements R Frequency statistics of basic elements R Encoding; Step S1504: Obtain and save the second codebook .
5. The high performance compression method based on codebook training according to claim 1, It is characterized in that In step S160, the third processing process specifically includes: Step S1601, select basic elements D The maximum size is , and then count the different Elements of size quantity; Step S1602: based on all size elements D Frequency statistics of basic elements D Encoding; Step S1603: Obtain and save the third codebook .
6. A high-performance compression system based on codebook training, It is characterized in that include: The codebook statistics module is used to obtain a preset proportion of image data from the image data set to be compressed to count the frequency information of the basic elements of the image, and generate a codebook based on the frequency information combined with the encoding method, which specifically includes: Define the image dataset to be compressed as M , in the image dataset to be compressed M Randomly extract image sample data of proportion Q as statistics; Preprocessing the image sample data of the extraction ratio Q to obtain difference image data of the ratio Q image; Assume that the image sample data type is bits, the obtained difference image data is processed according to the high bit and low The bits are evenly divided, high The bit is called profile layer K, low The first bit is called the detail layer L; Perform the first processing on the contour layer K to obtain the first codebook ; The second processing is performed on the detail layer L to obtain the second codebook ; The third processing is performed on the detail layer L to obtain the third codebook ; The image encoding module is used to divide the image into regions using the basic elements in the codebook, and then encode the image in combination with the encoding results of the basic elements in the codebook to obtain the image encoding result, specifically including: Get the image dataset to be compressed M Image sample data in G As input, the data type is Bit; For image sample data G Perform preprocessing to obtain image sample data G The difference image data; The obtained difference image data is processed according to the high bit and low The bits are evenly divided, high Profile Layer K G ,Low Detail layer L G ; Read the first codebook , at the contour layer K G In the first codebook, The basic elements in the contour layer K are found G There are basic elements in the contour layer K. G The position coordinates in And the corresponding code; Read the second codebook , at the detail layer L G In the second codebook, The basic elements in Set the encoding flag F, where the size of the encoding flag F and the detail layer L G The same, initialized to 0, execute the first judgment process; The performing of the first judgment process specifically includes: Discovery detail layer L G If there is a basic element in the image, if the corresponding position in the flag F is 0, record the position coordinates of the basic element in the image. And the corresponding code, at the same time, all areas of the size of the basic element in the same position corresponding to the flag bit F are built-in 1; If the corresponding position in the flag F is 1, repeat the above steps until the detail layer L G There is no second codebook in The basic elements in Read the third codebook , at the detail layer L G In the third codebook, The basic elements in the second judgment process are executed; The performing of the second judgment process specifically includes: Discovery detail layer L G If there is a basic element in the image, if the corresponding position in the flag F is 0, record the position of the basic element in the image. And the corresponding code, at the same time, all areas of the size of the basic element in the same position corresponding to the flag bit F are built-in 1; If the corresponding position in the flag F is 1, repeat the above steps until the detail layer L G There is no third codebook in The basic elements in Finally, the position coordinates , location coordinates , location coordinates Select each encoding method for encoding, and then combine the encoding of each codebook to complete the image compression; The image decoding module is used to decode the image according to the corresponding relationship between the image encoding result and the encoding and basic elements in the code book.
7. A computer device, It is characterized in that The method comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the high-performance compression method based on codebook training as described in any one of claims 1 to 5 when executing the computer program.
8. A computer storage medium, It is characterized in that The computer storage medium stores instructions, and when the instructions are executed on a computer, the computer executes the high-performance compression method based on codebook training as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Multi-semantic-codebook-based image feature representation method
CN105389588A
Image lossless compression method
CN112887722A
Self-coding machine image compression method based on codebook
CN114422802A
Image compression method and device, equipment and storage medium
CN115834890A
Spacer image compression method and system for electric power inspection based on graph segmentation technology
CN117560511A
