Image file coding method, image file decoding method, image file coder, and image file decoder
By compressing the DCT coefficient matrix of the image, using lossless or low-loss compression methods for low-frequency DCT coefficients and high-compression rate compression methods for high-frequency DCT coefficients, it solves the problem of encoding and decoding image files in low-computing power and low-power devices. solve the complexity problem and achieve efficient image file compression and restoration.
Patent Information
- Application Number
- PCT/CN2024/075277
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-04-13
- Filing Date
- 2024-02-01
- Publication Date
- 2024-10-17
AI Technical Summary
Under the conditions of low computing power and low power consumption, it is difficult for existing technologies to achieve high compression rate image file encoding and decoding on the basis of ensuring image quality. Especially in remote inspection systems in the field of power transmission, traditional image compression schemes are complex. High degree of accuracy makes it difficult to meet the needs of on-site image collection equipment.
By compressing the DCT coefficient matrix of the image, lossless or low-loss compression methods are used for low-frequency DCT coefficients and high compression rate compression methods for high-frequency DCT coefficients, dimensionality reduction operations and prediction algorithms to achieve low computational complexity image files. Compression, avoiding the need for inverse DCT transformation.
In an environment with low computing power and low power consumption, the compression rate of image files is improved, while the quality and restoration of the image are ensured. It is suitable for devices with low power consumption and low computing power.
Smart Images

Figure CN2024075277_17102024_PF_FP_ABST
Abstract
Description
Image file encoding and decoding method, image file encoder and image file decoder
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on April 13, 2023, with application number 202310407735.5 and application name “Image file encoding and decoding method, image file encoder and image file decoder”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The embodiments of the present application relate to the field of image file compression, and more specifically, to an image file encoding and decoding method, an image file encoder, and an image file decoder. Background Art
[0003] As industries become increasingly automated, the demand for automated image acquisition and monitoring at work sites is growing. For example, in the power transmission sector, visual remote inspection systems that capture images of transmission channels and visualize them are a key method for power grid companies to achieve digital transmission and reduce unplanned power outages.
[0004] The visual remote patrol system generally uses on-site image acquisition equipment to collect images, and remotely transmits the image files to the host unit in real time. The host unit restores the collected images based on the files to achieve monitoring. In order to ensure the efficiency of remote transmission and the sufficient restoration of the image to the scene, it is necessary to achieve a high compression rate while ensuring image quality. However, due to the limitations of the working environment, the computing power of on-site image acquisition equipment is generally limited, and there are high requirements for low power consumption. In traditional image compression schemes, image file encoding and decoding methods that can achieve high compression ratios are generally more complex and difficult to meet the above-mentioned low computing power and low power consumption requirements. Therefore, how to improve the image file compression rate while taking into account image quality under the conditions of low computing power and low power consumption has become a technical problem that needs to be solved urgently.
[0005] Summary of the Invention
[0006] The embodiments of the present application provide a method for encoding and decoding an image file, an image file encoder, and an image file decoder, which can use a lossless or low-loss compression method for low-frequency discrete cosine transform (DCT) coefficients containing more image information, and a high-compression rate compression method for high-frequency DCT coefficients containing less image information, thereby compressing the DCT coefficient matrix of the image, taking into account image quality while improving the image file compression rate under the premise of low computational complexity.
[0007] In a first aspect, a method for encoding an image file is provided, the method comprising: obtaining a discrete cosine transform (DCT) coefficient matrix of an n-th image block among N image blocks included in an image, wherein the DCT coefficient matrix of the n-th image block includes multiple low-frequency DCT coefficients and multiple high-frequency DCT coefficients, N is a positive integer greater than 1, and n is a positive integer greater than or equal to 1 and less than or equal to N; determining at least one reduced-dimensionality DCT coefficient, wherein the at least one reduced-dimensionality DCT coefficient includes part of the high-frequency DCT coefficients of the multiple high-frequency DCT coefficients; determining predicted values of the multiple low-frequency DCT coefficients; determining multiple residual values based on differences between the predicted values and the multiple low-frequency DCT coefficients, wherein the multiple residual values correspond one-to-one to the multiple low-frequency DCT coefficients; and encoding the multiple residual values and the at least one reduced-dimensionality DCT coefficient to generate a compressed bit string of the DCT coefficient matrix of the n-th image block.
[0008] Optionally, the method can be applied to the compression of image files in the Joint Photographic Experts Group (JPEG) format.
[0009] According to the technical solution provided by this application, by using lossless predictive compression for low-frequency DCT coefficients containing more image information and high-compression dimensionality reduction compression for high-frequency DCT coefficients containing less image information, it is possible to improve the image file compression rate while ensuring high quality of the restored image. In addition, the technical solution provided by this application has low algorithm complexity and achieves image file compression by compressing the DCT coefficient matrix without processing the image pixel values. When compressing image files in a format based on DCT transform, there is no need to perform the highly complex inverse DCT transform to restore the image pixel values. This allows for improving the image file compression rate while maintaining image quality with low computational complexity.
[0010] In combination with the first aspect, in certain implementations of the first aspect, before determining the predicted values of multiple low-frequency DCT coefficients, the method also includes: replacing the high-frequency DCT coefficients in the DCT coefficient matrix of the nth image block except for at least one reduced-dimensional DCT coefficient with 0.
[0011] According to the above technical solution, by discarding some high-frequency DCT coefficients through dimensionality reduction, the amount of data required for transmission can be reduced and the compression ratio can be improved. Furthermore, by marking the discarded high-frequency DCT coefficients as zero, if the low-frequency DCT coefficients are subsequently predicted based on the high-frequency DCT coefficients, the high-frequency DCT coefficients that have been partially reduced to zero after dimensionality reduction can be used for calculations, thereby reducing computational complexity.
[0012] In combination with the first aspect, in certain implementations of the first aspect, determining the predicted values of multiple low-frequency DCT coefficients includes: when there is a prediction information image block in the nth image block, determining the predicted values of multiple low-frequency DCT coefficients in the DCT coefficient matrix of the nth image block based on the DCT coefficient matrix of the prediction information image block, wherein the prediction information image block is at least one image block among the N image blocks, and the at least one image block is adjacent to the nth image block and is located at a specific position; when there is no prediction information image block in the nth image block, determining that the predicted values of multiple low-frequency DCT coefficients in the DCT coefficient matrix of the nth image block are 0.
[0013] According to the above technical solution, a pre-defined prediction algorithm is used to predict the predicted values of low-frequency DCT coefficients based on the DCT coefficients known during decoding. This allows the decoder to calculate these predicted values during decoding. This means that only the residual between the actual value and the predicted value needs to be retained in the transmitted file for the decoder to determine the original value of the low-frequency DCT coefficient. This strengthens the correlation between adjacent image blocks, allowing the predicted values obtained from adjacent image blocks to be closer to the original values, thereby reducing the absolute value of the residual value and improving the compression ratio.
[0014] In combination with the first aspect, in certain implementations of the first aspect, before determining the predicted values of multiple low-frequency DCT coefficients, the method also includes: quantizing the DCT coefficient matrix of the nth image block according to the quantization coefficient matrix, wherein the quantization coefficient corresponding to the low-frequency DCT coefficient is smaller than the quantization coefficient corresponding to the high-frequency DCT coefficient; determining the predicted values of multiple low-frequency DCT coefficients includes: determining the predicted values of multiple low-frequency DCT coefficients according to the quantized DCT coefficient matrix.
[0015] According to the above technical solution, the DCT coefficient matrix can be appropriately quantized and lossily compressed before predicting the DCT low-frequency coefficients, thereby further improving the compression rate. In addition, by setting appropriate quantization coefficients, the quantization coefficients corresponding to the low-frequency DCT coefficients are made smaller, which can minimize the loss of low-frequency information caused by the quantization operation, thereby ensuring the quality of the restored image.
[0016] In combination with the first aspect, in some implementations of the first aspect, encoding the residual value and the reduced-dimensional DCT coefficient to generate a compressed bit string of the DCT coefficient matrix of the nth image block includes: determining M n Number of values to be encoded, where M n The value to be encoded and M n The matrix parameters correspond one to one, M n The matrix parameters include multiple residual values and at least one reduced-dimensional DCT coefficient, M nEach of the values to be encoded includes a first field, a second field, and a third field. The first field of each value to be encoded is used to indicate the positive or negative sign of the matrix parameter corresponding to each value to be encoded. The second field of each value to be encoded is used to indicate the number of bits of the binary number of the matrix parameter corresponding to each value to be encoded. The third field of each value to be encoded is a bit string determined according to the binary representation of the absolute value of the matrix parameter corresponding to each value to be encoded. n is a positive integer greater than 2; for M n The first field and the second field of the to-be-encoded value are entropy-encoded to determine the entropy-encoded bit string of each to-be-encoded value; according to M n The entropy coded bit string of the value to be coded and M n The third field of each value to be encoded is used to generate a compressed bit string, wherein the compressed bit string includes the entropy encoded bit string of each value to be encoded and the third field of each value to be encoded.
[0017] According to the above technical solution, the combination of symbol, bit length, and residual bit string used to represent a value allows each encoded value to be represented using a bit string of varying length, thereby avoiding the bit redundancy that results from using a fixed-length bit string to represent values within a certain range. Furthermore, by using entropy coding to determine the bit string representation of the symbol and bit length, the number of bits required to represent each combination can be minimized, reducing the length of the bit string required to represent the encoded image file and improving the compression ratio.
[0018] In combination with the first aspect, in certain implementations of the first aspect, obtaining the DCT coefficient matrix of the nth image block among N image blocks included in the image includes: decoding and obtaining the DCT coefficient matrix from an image file in the Joint Photographic Experts Group JPEG format.
[0019] According to the above technical solution, when compressing image files in DCT-based formats such as JPEG, subsequent compression steps can be performed by simply decoding the file to obtain the DCT coefficient matrix, without the need for an inverse DCT transform to obtain the image's pixel values. Furthermore, the DCT coefficient matrix obtained by decoding on the decoder side can be restored to the JPEG format without the need for a DCT transform. This allows for secondary compression of image files with low computing power without replacing the image's JPEG format, expanding the application scenarios of the image file encoding and decoding method.
[0020] In a second aspect, a method for decoding an image file is provided, the method comprising: obtaining a compressed bit string corresponding to an n-th image block among N image blocks included in an image, wherein N is a positive integer greater than 1, and n is a positive integer greater than or equal to 1 and less than or equal to N; decoding the compressed bit string to determine a plurality of residual values and at least one reduced-dimensionality DCT coefficient corresponding to the n-th image block; determining a plurality of high-frequency DCT coefficients in a DCT coefficient matrix of the n-th image block based on the at least one reduced-dimensionality DCT coefficient; determining predicted values of a plurality of low-frequency DCT coefficients in the DCT coefficient matrix of the n-th image block; determining a plurality of low-frequency DCT coefficients based on the predicted values and the plurality of residual values, wherein the plurality of residual values correspond one-to-one to the plurality of low-frequency DCT coefficients; and determining the DCT coefficient matrix of the n-th image block based on the plurality of high-frequency DCT coefficients and the plurality of low-frequency DCT coefficients.
[0021] In combination with the second aspect, in certain implementations of the second aspect, multiple high-frequency DCT coefficients in the DCT coefficient matrix of the nth image block are determined based on at least one reduced-dimensionality DCT coefficient, including: determining the values of the multiple high-frequency DCT coefficients except for at least one reduced-dimensionality DCT coefficient to 0.
[0022] In combination with the second aspect, in certain implementations of the second aspect, the prediction values of multiple low-frequency DCT coefficients in the DCT coefficient matrix of the nth image block are determined, including: when the nth image block has a prediction information image block, determining the prediction values of multiple low-frequency DCT coefficients in the DCT coefficient matrix of the nth image block based on the DCT coefficient matrix of the prediction information image block, wherein the prediction information image block is at least one image block among the N image blocks, and the at least one image block is adjacent to the nth image block and is located at a specific position; when the nth image block does not have a prediction information image block, determining that the prediction values of multiple low-frequency DCT coefficients in the DCT coefficient matrix of the nth image block are 0.
[0023] In combination with the second aspect, in certain implementations of the second aspect, the method further includes: inverse quantizing multiple high-frequency DCT coefficients and multiple low-frequency DCT coefficients according to a quantization coefficient matrix, wherein the quantization coefficients corresponding to the multiple low-frequency DCT coefficients are smaller than the quantization coefficients corresponding to the multiple high-frequency DCT coefficients; determining the DCT coefficient matrix of the nth image block according to the multiple high-frequency DCT coefficients and the multiple low-frequency DCT coefficients, including: determining the DCT coefficient matrix of the nth image block according to the multiple high-frequency DCT coefficients after inverse quantization and the multiple low-frequency DCT coefficients after inverse quantization.
[0024] In conjunction with the second aspect, in certain implementations of the second aspect, decoding the compressed bit string includes: parsing the compressed bit string to obtain the bit sequence corresponding to M n M values to be decoded correspond one to one nentropy coded bit strings and M n A third field, where M n The value to be decoded and M n The matrix parameters correspond one to one, M n The matrix parameters include multiple residual values and at least one reduced-dimensional DCT coefficient. The third field is based on M n A bit string determined by the binary representation of the absolute value of the matrix parameter corresponding to each of the values to be decoded, M n is a positive integer greater than 2; according to the entropy coding algorithm, determine M n The first field and the second field of each to-be-decoded value corresponding to each entropy-coded bit string in the entropy-coded bit string are used to indicate the positive and negative of the matrix parameter corresponding to each to-be-decoded value, and the second field is used to indicate the number of bits of the binary number of the matrix parameter corresponding to each to-be-decoded value; and multiple residual values and at least one reduced-dimensional DCT coefficient are determined according to the first field, the second field and the third field of each to-be-decoded value.
[0025] In combination with the second aspect, in some implementations of the second aspect, the method further includes: generating an image file in JPEG format according to a DCT coefficient matrix corresponding to each image block in the N image blocks of the image.
[0026] According to a third aspect, an image file encoder is provided, comprising: an acquisition module for acquiring a discrete cosine transform (DCT) coefficient matrix of an n-th image block among N image blocks included in an image, wherein the DCT coefficient matrix of the n-th image block includes multiple low-frequency DCT coefficients and multiple high-frequency DCT coefficients, N is a positive integer greater than 1, and n is a positive integer greater than or equal to 1 and less than or equal to N; a high-frequency dimensionality reduction module for determining at least one reduced-dimensionality DCT coefficient, wherein at least one reduced-dimensionality DCT coefficient includes part of the high-frequency DCT coefficients of the multiple high-frequency DCT coefficients; a low-frequency prediction module for determining predicted values of the multiple low-frequency DCT coefficients; a residual calculation module for determining multiple residual values based on a difference between the predicted value and the multiple low-frequency DCT coefficients, wherein the multiple residual values correspond one-to-one to the multiple low-frequency DCT coefficients; and an encoding module for encoding the multiple residual values and the at least one reduced-dimensionality DCT coefficient to generate a compressed bit string of the DCT coefficient matrix of the n-th image block.
[0027] In combination with the third aspect, in certain implementations of the third aspect, before determining the predicted values of multiple low-frequency DCT coefficients, the high-frequency dimensionality reduction module is also used to: replace the high-frequency DCT coefficients other than at least one reduced-dimensionality DCT coefficient in the DCT coefficient matrix of the nth image block with 0.
[0028] In combination with the third aspect, in certain implementations of the third aspect, the low-frequency prediction module is used to: when there is a prediction information image block in the nth image block, determine the predicted values of multiple low-frequency DCT coefficients in the DCT coefficient matrix of the nth image block based on the DCT coefficient matrix of the prediction information image block, wherein the prediction information image block is at least one image block among the N image blocks, and the at least one image block is adjacent to the nth image block and is located at a specific position; when there is no prediction information image block in the nth image block, determine that the predicted values of multiple low-frequency DCT coefficients in the DCT coefficient matrix of the nth image block are 0.
[0029] In combination with the third aspect, in certain implementations of the third aspect, the image file encoder further includes a quantization module, configured to: quantize the DCT coefficient matrix of the nth image block according to the quantization coefficient matrix, wherein the quantization coefficient corresponding to the low-frequency DCT coefficient is smaller than the quantization coefficient corresponding to the high-frequency DCT coefficient; and a low-frequency prediction module, configured to: determine predicted values of multiple low-frequency DCT coefficients based on the quantized DCT coefficient matrix.
[0030] In conjunction with the third aspect, in some implementations of the third aspect, the encoding module is configured to: determine M n Number of values to be encoded, where M n The value to be encoded and M n The matrix parameters correspond one to one, M n The matrix parameters include multiple residual values and at least one reduced-dimensional DCT coefficient, M n Each of the values to be encoded includes a first field, a second field, and a third field. The first field of each value to be encoded is used to indicate the positive or negative sign of the matrix parameter corresponding to each value to be encoded. The second field of each value to be encoded is used to indicate the number of bits of the binary number of the matrix parameter corresponding to each value to be encoded. The third field of each value to be encoded is a bit string determined according to the binary representation of the absolute value of the matrix parameter corresponding to each value to be encoded. n is a positive integer greater than 2; for M n The first field and the second field of the to-be-encoded value are entropy-encoded to determine the entropy-encoded bit string of each to-be-encoded value; according to M n The entropy coded bit string of the value to be coded and M n The third field of each value to be encoded is used to generate a compressed bit string, wherein the compressed bit string includes the entropy encoded bit string of each value to be encoded and the third field of each value to be encoded.
[0031] In combination with the third aspect, in certain implementations of the third aspect, the acquisition module is configured to: decode and acquire a DCT coefficient matrix from an image file in the Joint Photographic Experts Group JPEG format.
[0032] In a fourth aspect, an image file decoder is provided, which includes: an acquisition module for acquiring a compressed bit string corresponding to the nth image block among N image blocks included in the image, wherein N is a positive integer greater than 1, and n is a positive integer greater than or equal to 1 and less than or equal to N; a decoding module for decoding the compressed bit string to determine multiple residual values and at least one reduced-dimensionality DCT coefficient corresponding to the nth image block; a high-frequency determination module for determining multiple high-frequency DCT coefficients in a DCT coefficient matrix of the nth image block based on the at least one reduced-dimensionality DCT coefficient; a low-frequency prediction module for determining predicted values of multiple low-frequency DCT coefficients in the DCT coefficient matrix of the nth image block; a low-frequency determination module for determining multiple low-frequency DCT coefficients based on the predicted values and multiple residual values, wherein the multiple residual values correspond one-to-one to the multiple low-frequency DCT coefficients; and a matrix determination module for determining the DCT coefficient matrix of the nth image block based on the multiple high-frequency DCT coefficients and the multiple low-frequency DCT coefficients.
[0033] In combination with the fourth aspect, in certain implementations of the fourth aspect, the high-frequency determination module is configured to determine values of the multiple high-frequency DCT coefficients other than at least one reduced-dimensionality DCT coefficient as 0.
[0034] In combination with the fourth aspect, in certain implementations of the fourth aspect, the low-frequency prediction module is used to: when there is a prediction information image block in the nth image block, determine the predicted values of multiple low-frequency DCT coefficients in the DCT coefficient matrix of the nth image block based on the DCT coefficient matrix of the prediction information image block, wherein the prediction information image block is at least one image block among the N image blocks, and the at least one image block is adjacent to the nth image block and is located at a specific position; when there is no prediction information image block in the nth image block, determine that the predicted values of multiple low-frequency DCT coefficients in the DCT coefficient matrix of the nth image block are 0.
[0035] In combination with the fourth aspect, in certain implementations of the fourth aspect, the image file decoder further includes an inverse quantization module, configured to: perform inverse quantization on multiple high-frequency DCT coefficients and multiple low-frequency DCT coefficients according to a quantization coefficient matrix, wherein the quantization coefficients corresponding to the multiple low-frequency DCT coefficients are smaller than the quantization coefficients corresponding to the multiple high-frequency DCT coefficients; and a matrix determination module, configured to: determine the DCT coefficient matrix of the nth image block based on the inversely quantized multiple high-frequency DCT coefficients and the inversely quantized multiple low-frequency DCT coefficients.
[0036] In conjunction with the fourth aspect, in some implementations of the fourth aspect, the decoding module is used to: parse the compressed bit string to obtain the bit sequence corresponding to M n M values to be decoded correspond one to one n entropy coded bit strings and M n A third field, where Mn The value to be decoded and M n The matrix parameters correspond one to one, M n The matrix parameters include multiple residual values and at least one reduced-dimensional DCT coefficient. The third field is based on M n A bit string determined by the binary representation of the absolute value of the matrix parameter corresponding to each of the values to be decoded, M n is a positive integer greater than 2; according to the entropy coding algorithm, determine M n The first field and the second field of each to-be-decoded value corresponding to each entropy-coded bit string in the entropy-coded bit string are used to indicate the positive and negative of the matrix parameter corresponding to each to-be-decoded value, and the second field is used to indicate the number of bits of the binary number of the matrix parameter corresponding to each to-be-decoded value; and multiple residual values and at least one reduced-dimensional DCT coefficient are determined according to the first field, the second field and the third field of each to-be-decoded value.
[0037] In combination with the fourth aspect, in certain implementations of the fourth aspect, the image file decoder further includes a file generation module for generating an image file in JPEG format based on a DCT coefficient matrix corresponding to each of the N image blocks of the image.
[0038] In a fifth aspect, an image file encoding device is provided, comprising a processor and a memory, wherein the memory is used to store instructions, and the processor is used to call and execute the instructions from the memory, so that the image file encoding device executes the method in the first aspect or any possible implementation of the first aspect.
[0039] In a sixth aspect, an image file decoding device is provided, comprising a processor and a memory, wherein the memory is used to store instructions, and the processor is used to call and execute the instructions from the memory, so that the image file decoding device executes the method in the second aspect or any possible implementation of the second aspect.
[0040] Optionally, the processor may be a general-purpose processor, which may be implemented in hardware or software. When implemented in hardware, the processor may be a logic circuit, an integrated circuit, or the like; when implemented in software, the processor may be a general-purpose processor implemented by reading software code stored in a memory, which may be integrated into the processor or located independently of the processor.
[0041] In a seventh aspect, a chip is provided, which obtains instructions and executes the instructions to implement the method in the above-mentioned first aspect or any possible implementation manner of the first aspect.
[0042] Optionally, as an implementation, the chip includes a processor and a data interface, and the processor reads instructions stored in the memory through the data interface to execute the method in the above-mentioned first aspect or any possible implementation of the first aspect.
[0043] Optionally, as an implementation method, the chip may also include a memory, in which instructions are stored, and the processor is used to execute the instructions stored in the memory. When the instructions are executed, the processor is used to execute the method in the above-mentioned first aspect or any possible implementation method of the first aspect.
[0044] In an eighth aspect, a chip is provided, which obtains an instruction and executes the instruction to implement the method in the above-mentioned second aspect or any possible implementation manner of the second aspect.
[0045] In a ninth aspect, a computer program product comprising instructions is provided. When the instructions are executed by a computing device, a computing device cluster executes the method in the first aspect or any possible implementation of the first aspect.
[0046] In a tenth aspect, a computer program product comprising instructions is provided. When the instructions are executed by a computing device, a computing device cluster executes the method in the second aspect or any possible implementation of the second aspect.
[0047] In the eleventh aspect, a computer-readable storage medium is provided, comprising computer program instructions. When the computer instructions are executed by a computing device, the computing device executes the method in the above-mentioned first aspect or any possible implementation of the first aspect.
[0048] In a twelfth aspect, a computer-readable storage medium is provided, comprising computer program instructions. When the computer instructions are executed by a computing device, a computing device cluster executes the method in the above-mentioned second aspect or any possible implementation of the second aspect.
[0049] By way of example, these computer-readable storage media include, but are not limited to, one or more of the following: read-only memory (ROM), programmable ROM (PROM), erasable PROM (EPROM), Flash memory, electrically EPROM (EEPROM), and a hard drive.
[0050] Optionally, as an implementation manner, the above-mentioned storage medium may specifically be a non-volatile storage medium.
[0051] In a thirteenth aspect, an image file encoding and decoding system is provided, comprising at least one image file encoding device as described in the fifth aspect above, and at least one image file decoding device as described in the sixth aspect above. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] FIG1 is a schematic diagram of an image file encoding and decoding system provided in an embodiment of the present application.
[0053] FIG2 is a schematic flowchart of an image file encoding method provided in an embodiment of the present application.
[0054] FIG3 is a schematic diagram of a high-frequency DCT coefficient dimensionality reduction operation provided in an embodiment of the present application.
[0055] FIG4 is a schematic diagram of a low-frequency DCT coefficient prediction operation provided in an embodiment of the present application.
[0056] FIG5 is a schematic flowchart of a method for decoding an image file provided in an embodiment of the present application.
[0057] FIG6 is a schematic structural block diagram of an image file encoder provided in an embodiment of the present application.
[0058] FIG7 is a schematic structural block diagram of an image file decoder provided in an embodiment of the present application.
[0059] FIG8 is a schematic structural block diagram of a computing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0060] The technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings.
[0061] This application will present various aspects, embodiments, or features around systems including multiple devices, components, modules, etc. It should be understood and appreciated that each system may include additional devices, components, modules, etc., and / or may not include all of the devices, components, modules, etc. discussed in conjunction with the figures. Furthermore, combinations of these aspects may also be used.
[0062] Additionally, in the embodiments of this application, words such as "exemplary" and "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described in this application as "exemplary" should not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of the word "exemplary" is intended to present concepts in a concrete manner.
[0063] In the embodiments of the present application, “corresponding” and “relevant” may sometimes be used interchangeably. It should be noted that when the distinction between them is not emphasized, the meanings they intend to express are consistent.
[0064] The network architecture and business scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. A person skilled in the art will appreciate that, with the evolution of the network architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are equally applicable to similar technical problems.
[0065] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present application. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in yet other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0066] In this application, "at least one" means one or more, and "more" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: including the existence of A alone, the existence of A and B at the same time, and the existence of B alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.
[0067] To facilitate understanding, the following first introduces relevant terms and concepts that may be involved in the embodiments of this application.
[0068] 1. Discrete Cosine Transform (DCT): DCT is a transform related to the Fourier transform. It is similar to the Discrete Fourier Transform (DFT), but the transformed function only includes the real cosine function. Therefore, DCT is actually equivalent to constructing the input function as a real even function and then performing the DFT. There are 8 DCT forms, and the most commonly used one is as follows:
[0069] Where f(i) is the signal before DCT transformation, F(u) is the signal after DCT transformation, and N is the number of samples.
[0070] 2. DCT coefficient matrix: The formula introduced above can also be called one-dimensional DCT. Two-dimensional DCT is to perform DCT on the signal in two mutually perpendicular directions, which is equivalent to performing another DCT in the perpendicular direction on the signal obtained by one-dimensional DCT. The expression is as follows:
[0071] Where f(i,j) is the signal before DCT transformation, F(u,v) is the signal after DCT transformation, and N is the number of samples. In the above formula, if f(i,j) is used as the element of the matrix, then f(i,j) can be expressed as an N×N matrix f. Similarly, f(i,j) can be expressed as an N×N matrix F, so the above two-dimensional DCT formula can be converted into matrix multiplication form: F=AfA T
[0072] According to the above two-dimensional DCT formula, the specific form of each element in the orthogonal matrix A can be derived:
[0073] The matrix F obtained by the above DCT processing can be called the DCT coefficient matrix of the input signal, and each element of the matrix F is called the DCT coefficient
[0074] 3. Low-frequency DCT coefficients and high-frequency DCT coefficients: The above-mentioned two-dimensional DCT can be applied to the field of image compression. Taking each pixel of the image as a sampling point of the input signal, the image is equivalent to a two-dimensional matrix. Therefore, the spatial domain signal can be decomposed into frequency domain signals of different frequencies through two-dimensional DCT. In the DCT coefficient matrix obtained after DCT of the image, the position of the DCT coefficient in the matrix is distributed according to the frequency. The frequency gradually increases from left to right and from top to bottom in the DCT coefficient matrix. Therefore, the closer the DCT coefficient is to the upper left corner of the DCT coefficient matrix, the lower the frequency is, which is called a low-frequency DCT coefficient; the closer the DCT coefficient is to the lower right corner of the DCT coefficient matrix, the higher the frequency is, which is called a high-frequency DCT coefficient.
[0075] For image signals, low-frequency DCT coefficients reflect areas where brightness or grayscale changes slowly, typically large, flat areas within the image. They describe the primary portion of the image and provide a comprehensive measure of overall image intensity. High-frequency DCT coefficients reflect areas where brightness or grayscale changes dramatically, such as edges, outlines, and noise. Because the human eye is less sensitive to image detail, low-frequency DCT coefficients contain more information about the original image than high-frequency DCT coefficients.
[0076] Given the computational complexity of DCT, when processing image signals, the image is typically divided into multiple blocks with the same number of pixels, and DCT processing is performed on each block separately. For example, the size of an image block can be 4×4 pixels, 8×8 pixels, or 16×16 pixels. For an 8×8 image block, the low-frequency DCT coefficients can be the 15 DCT coefficients in the leftmost column and top row of the DCT coefficient matrix, while the high-frequency DCT coefficients can be the remaining 49 DCT coefficients in the matrix.
[0077] It should be understood that the division of low-frequency and high-frequency elements in the DCT coefficient matrix is relative. The above-mentioned specific division method is only for the convenience of illustrating the specific implementation method of the present application in the embodiments, and does not mean that the technical solution of the present application is limited to the above-mentioned division method. For example, the DCT coefficient matrix can also be 16×16 in size, where the low-frequency DCT coefficients can be the elements in the first two rows from top to bottom and the first two columns from left to right in the matrix. The size of the DCT coefficient matrix and the specific division method of the low-frequency DCT coefficients and the high-frequency DCT coefficients do not affect the technical solution of the present application, and the present application does not make specific limitations on this.
[0078] 4. Joint Photographic Experts Group (JPEG): JPEG is a standard for continuous-tone still image compression. Files with the suffix .jpg or .jpeg are the most commonly used image file format. It is a DCT-based joint encoding scheme that performs a DCT on each component in the YUV color space, followed by lossy compression to remove redundant image and color data.
[0079] Therefore, when reading a JPEG image file, the DCT coefficient matrix of the original image is first obtained through decoding, and then the specific pixel values of the original image in the YUV color space are obtained through inverse DCT. In this process, the inverse DCT is more computationally complex than other decoding processes and requires higher computing power.
[0080] With the increasing automation across various industries, the demand for automated image acquisition and monitoring at work sites is growing. For example, in the field of power transmission, transmission lines are core assets crucial to my country's national economy and people's livelihood, directly impacting the safe and reliable supply of electricity. my country has over 2 million kilometers of transmission lines 35kV and above, and third-party failures are the primary cause of unplanned power outages. Capturing and visualizing transmission channel images through a visual remote inspection system is a key method for power grid companies to achieve digital transmission and reduce unplanned power outages.
[0081] Visual remote patrol systems typically use on-site image acquisition devices to capture images and remotely transmit the image files in real time to a host unit, which then reconstructs the captured images from the files for monitoring. To ensure efficient remote transmission and sufficient image reproduction of the site, high compression rates are required while maintaining image quality. Effective monitoring generally requires at least 60% on-site image acquisition device coverage, which may require deployment in environments with limited working conditions, such as difficult power access.
[0082] Directly transmitting image files through existing image formats such as JPEG is difficult to meet the high compression rate requirements of the visual remote patrol system for transmitting image files, so image files need to be compressed. JPEG2000 is an image file format based on discrete wavelet transform (DWT) and proposed on the basis of JPEG. However, compared with JPEG, the compression rate is not significantly improved and it is difficult to meet the high compression rate requirements. The hyper-prior-based neural network image compression architecture can achieve high image compression rates, but it requires processing based on the original pixel values of the image and the algorithm complexity is relatively high. However, due to the limitations of the aforementioned working environment, the computing power of on-site image acquisition equipment is generally limited, and there are high requirements for low power consumption. The above-mentioned traditional image compression schemes are not suitable for such working scenarios. Therefore, how to improve the image file compression rate while taking into account image quality under the conditions of low computing power and low power consumption has become a technical problem that needs to be solved urgently.
[0083] In view of this, an embodiment of the present application provides a method for encoding and decoding an image file, which performs compression based on the DCT coefficient matrix of the image, without requiring an inverse DCT transformation to restore the original pixel values. Therefore, the algorithm complexity is low and can be adapted to application scenarios with low computing power and low power consumption. On this basis, a lossless or low-loss compression method is used for low-frequency DCT coefficients containing more image information, and a high-compression ratio compression method is used for high-frequency DCT coefficients containing less image information, thereby compressing the DCT coefficient matrix of the image, thereby improving the image file compression ratio while taking into account image quality while maintaining low computational complexity.
[0084] As an example, FIG1 shows a schematic diagram of an image file encoding and decoding system 10 applicable to an embodiment of the present application. For example, the image file encoding and decoding system 10 may be a visual remote patrol system. As shown in FIG1 , the image file encoding and decoding system 10 may include at least one image file encoding device, such as the image file encoding device 11 shown in FIG1 . The image file encoding and decoding system 10 may also include at least one image file decoding device, such as the image file decoding device 12 shown in FIG1 .
[0085] The image file encoding device 11 and the image file decoding device 12 can compress and transmit image files in a standard format. The image file encoding device 11 can be an image acquisition device such as a surveillance camera, and includes an image file encoder 111. The image file encoder 111 is used to compress the image file in a standard format acquired by the image file encoding device 11 into a private format using the image file encoding method provided in the embodiment of the present application, thereby transmitting the compressed image file to the image file decoding device 12. The image file decoding device 12 can be a host unit, and includes an image file decoder 121. The image file decoder 121 is used to, after receiving the compressed image file in the private format, decompress it into an image file in a standard format using the image file decoding method provided in the embodiment of the present application, thereby allowing the image file decoding device 12 to perform storage, image recognition, and other processing on the image file in the standard format. Among them, the image file in the standard format includes but is not limited to JPEG files.
[0086] It should be understood that FIG1 exemplarily illustrates one image file encoding device and one image file decoding device, but this should not constitute any limitation to the present application. Optionally, the image file encoding and decoding system 10 may include more image file decoding devices, and each image file decoding device may include another number of image file encoding devices within its coverage area. This embodiment of the present application is not limited to this.
[0087] Optionally, the image file encoding device and image file decoding device described above may further include other modules or units as needed. For example, the image file encoding device 11 shown in FIG1 may further include an image acquisition module 112 for acquiring images and generating image files in a standard format. For another example, the image file decoding device 12 may further include a main control and processing module 122 for performing image recognition and other processing on the decompressed image files in a standard format, as well as a remote communication module 123 and a power supply unit 124. This embodiment of the present application is not limited to this.
[0088] The following describes in detail the image file encoding method provided by the embodiment of the present application in conjunction with Figure 2.
[0089] Figure 2 shows a schematic flow chart of a method for encoding an image file according to an embodiment of the present application. Optionally, the method of Figure 2 can be executed by an image file encoding device, such as the image file encoding device 11 in Figure 1 above.
[0090] As shown in FIG2 , the method includes the following steps.
[0091] S210: Obtain a DCT coefficient matrix of an n-th image block among N image blocks included in the image.
[0092] For example, in step S210, the image file encoding device can obtain a DCT coefficient matrix of the image to be compressed. Specifically, the image can be divided into N image blocks, and the image file encoding device can obtain a DCT coefficient matrix of the nth image block among the N image blocks to be compressed, where N is a positive integer greater than 1 and n is a positive integer greater than or equal to 1 and less than or equal to N.
[0093] In some possible implementations, when the image to be compressed is an image file in a standard format based on DCT, the image file encoding device can directly decode the file to obtain the DCT coefficient matrix. For example, taking the image to be compressed as an image file in JPEG format, in this case, the image file encoding device decodes the JPEG image file to obtain the DCT coefficient matrix.
[0094] Since all subsequent image file encoding steps are based on the DCT matrix, this method does not require an inverse DCT transform to obtain the image's pixel values when encoding an image file in a DCT-based format, nor does it require DCT to directly obtain the DCT coefficient matrix from the file. Furthermore, the decoder also decodes the obtained DCT coefficient matrix, which can be restored to a DCT-based image without the need for a DCT transform. This allows for secondary compression of image files with low computing power without replacing the original image format, expanding the applicable scenarios for this image file encoding and decoding method.
[0095] It should be understood that the above examples are merely intended to illustrate that the image file encoding method provided by the embodiments of the present application can achieve image file compression with low computing power when compressing DCT-based image files such as JPEG, but are not limited to application to DCT-based image files. For example, for image files not based on DCT, the image file encoding device can perform DCT on the pixel values of the image to obtain a DCT coefficient matrix, thereby achieving a high compression ratio while maintaining image quality, provided that computing power and power consumption support are met.
[0096] S220: Determine at least one dimension-reduced DCT coefficient.
[0097] For example, in step S220, the image file encoding device may perform dimensionality reduction on the high-frequency DCT coefficient portion of the DCT coefficient matrix of the current n-th image block according to a dimensionality reduction rule. Specifically, the dimensionality reduction rule may specify which positions in the DCT coefficient matrix are to be retained, and only this portion of the high-frequency DCT coefficient matrix is retained in the encoded compressed image file, while the other high-frequency DCT coefficients are discarded. During decoding, the image file decoding device can only restore the aforementioned portion of the retained high-frequency DCT coefficients, so dimensionality reduction is a lossy compression of the high-frequency DCT coefficients. The high-frequency DCT coefficients retained after the dimensionality reduction may be referred to as reduced-dimensional DCT coefficients.
[0098] Figure 3 shows a schematic diagram of a high-frequency DCT coefficient dimensionality reduction operation. Taking an 8×8 DCT coefficient matrix as an example, assume that the 7×7 portion in the lower right corner is the high-frequency DCT coefficient. In this case, Figure 3(a) shows the original 7×7 high-frequency DCT coefficients before dimensionality reduction. Figure 3(b) illustrates a dimensionality reduction method, where the shaded areas represent the reduced DCT coefficients retained after dimensionality reduction. The high-frequency DCT coefficients in the white areas are not encoded or transmitted, resulting in only 17 of the original 49 high-frequency DCT coefficients remaining after dimensionality reduction. This significantly reduces the number of high-frequency DCT coefficients and improves the compression rate of the DCT coefficient matrix. Figure 3(c) shows another dimensionality reduction method, in which the number of retained reduced DCT coefficients is the same as that in Figure 3(b). Due to the different specific content of the original image, the contribution of the high-frequency DCT coefficients at each position in the DCT coefficient matrix to the image information also varies. Therefore, different dimensionality reduction methods can be selected based on actual conditions. Through different specific dimensionality reduction methods, the compression rate of the final compressed image and the degree of restoration after decompression can also be adjusted. Therefore, this application is not limited to the two dimensionality reduction methods shown in Figure 3, and the number and position of other suitable dimensionality reduction DCT coefficients can be determined according to the specific situation of the image to be compressed.
[0099] Optionally, after reducing the dimensionality of the high-frequency DCT coefficients, the image file encoding device can also replace the high-frequency DCT coefficients in the DCT coefficient matrix except for the reduced-dimensional DCT coefficients with 0. For example, in the case shown in FIG3 , the white positions can be filled with 0 as the DCT coefficients after dimensionality reduction. The above method can fill the DCT coefficient matrix after dimensionality reduction. On the one hand, since the value 0 occupies fewer bits during compression and transmission than the values of other DCT coefficients, the purpose of compressing the DCT coefficient matrix can still be achieved after filling. In addition, after filling, 49 values are compressed and transmitted in any case, so that the image file decoding device can use a unified sorting rule to restore the 49 values to the high-frequency part of the DCT coefficient matrix, without having to separately record where each decompressed value should be located in the DCT coefficient matrix according to each specific dimensionality reduction method. On the other hand, high-frequency DCT coefficients may be used when predicting low-frequency DCT coefficients in subsequent steps. In order to correctly restore the prediction results during decoding, the values used in the prediction should be those that the image file decoding device can obtain and cannot use the discarded high-frequency DCT coefficients. Therefore, using 0 to fill the reduced-dimensional high-frequency DCT coefficients can facilitate the use of the results in subsequent prediction steps. In addition, choosing 0 as a supplement can also simplify the calculations in possible subsequent uses, thereby reducing the complexity of the calculations.
[0100] S230: Determine predicted values of the plurality of low-frequency DCT coefficients.
[0101] For example, in step S230, the image file encoding device can predict the low-frequency DCT coefficients in the DCT coefficient matrix of the current nth image block based on a prediction rule. Specifically, the image file encoding device calculates the predicted values of the low-frequency DCT coefficients based on numerical values available to the image file decoding device, based on the prediction rule agreed upon with the image file decoding device. This approach enables the image file decoding device to calculate the predicted values according to the same conditions and algorithm during decoding. Therefore, the image file encoding device only needs to transmit the residual value between the predicted value and the original value to the image file decoding device, and the image file decoding device can restore the original value of these low-frequency DCT coefficients. When the prediction rule is appropriate, the predicted value can be relatively close to the original value, resulting in a residual value that is much smaller than the original value. The smaller value results in fewer bits occupied after encoding, thereby compressing the size of the transmitted file.
[0102] Optionally, in some possible implementations, the image file encoding device can perform prediction based on the DCT coefficient matrices of other image blocks in the image to be compressed. The image block used to predict the current image block can be referred to as the prediction information image block of the current image block. The DCT coefficient matrix of the prediction information image block can be determined before the current image block during decoding. Therefore, this prediction rule enables the image file decoding device to calculate and obtain the same prediction value during decoding. For image blocks without prediction information image blocks, an agreed initial prediction value, such as 0, is assigned as the starting point of the prediction algorithm.
[0103] As an example, the prediction information image block for the current nth image block can be at least one image block located at a specific position adjacent to the current nth image block. For example, when predicting, the image file encoding device can predict the DCT coefficient matrix of each image block in a left-to-right and top-to-bottom order. When restoring, the image file decoding device also restores the low-frequency DCT coefficients in the same order. Prior to this, the high-frequency DCT coefficients have already been obtained through decoding. Therefore, for the image block currently being predicted, the DCT coefficient matrix of its left adjacent image block, the DCT coefficient matrix of its upper adjacent image block, and the DCT coefficient matrix of its upper-left adjacent image block are already determined. Therefore, the image file encoding device can determine the predicted values of multiple low-frequency DCT coefficients in the DCT coefficient matrix of the current image block based on at least one of the DCT coefficient matrix of the left adjacent image block, the DCT coefficient matrix of the upper adjacent image block, and the DCT coefficient matrix of the upper-left adjacent image block of the current image block. The following describes the low-frequency DCT coefficient prediction method provided in the embodiments of the present application by way of example, combining two specific prediction methods.
[0104] Method 1: Predict some low-frequency DCT coefficients in the DCT coefficient matrix of the current image block based on the low-frequency DCT coefficients in the DCT coefficient matrix of the left adjacent image block, the DCT coefficient matrix of the upper adjacent image block, and the DCT coefficient matrix of the upper-left adjacent image block.
[0105] Specifically, only the low-frequency DCT coefficient at position (0,0) is actually predicted, and the low-frequency DCT coefficient at position (0,0) in the DCT coefficient matrix of the left adjacent image block, the DCT coefficient matrix of the upper adjacent image block, and the DCT coefficient matrix of the upper-left adjacent image block that is closest to the estimated value is used as the predicted value of the low-frequency DCT coefficient at position (0,0) in the DCT coefficient matrix of the current image block. The position (0,0) refers to the first row and first column of each image block, that is, the position at the upper left corner. The low-frequency DCT coefficients at the remaining 14 positions in the 8×8 image block are not actually predicted, that is, the predicted value is 0, so that their residual value is equal to the original value of the low-frequency DCT coefficient.
[0106] Figure 4 shows a schematic diagram of the low-frequency DCT coefficient prediction operation described above. As shown in Figure 4, the DCT coefficient matrix of the current image block is represented as X, and the DCT coefficient matrices of its upper-left adjacent image block, the DCT coefficient matrices of the upper adjacent image block, and the DCT coefficient matrices of the left adjacent image block are represented by A, B, and C, respectively. The low-frequency DCT coefficient at the upper-left position of each of the DCT coefficient matrices X, A, B, and C is represented by x, a, b, and c, respectively. First, the estimated value p = b + ca is calculated. Then, the distances |pa|, |pb|, and |pc| between the estimated value p and a, b, and c are calculated, respectively. The value of a, b, or c closest to the estimated value p is used as the predicted value of x. For example, if |pa| < |pb| and |pa| < |pc|, then the predicted value of x is a, and the residual value of the low-frequency DCT coefficient at that position calculated in the subsequent steps is xa.
[0107] For the image block at the top left, the prediction value is 0, that is, the residual value is retained as the original value of the low-frequency DCT coefficient; for the image block in the leftmost column without a left adjacent image block, the prediction value is directly determined based on the upper adjacent image block; for the image block in the top row without a upper adjacent image block, the prediction value is directly determined based on the left adjacent image block. This determines the initial value of the prediction rule.
[0108] This method only actually predicts the DCT coefficient containing the most information in each image block, and the prediction algorithm is simple, which can achieve the most obvious compression effect on low-frequency DCT coefficients under limited computing power.
[0109] It should be understood that in this approach, the image block immediately to the left of the current image block is considered the left adjacent image block, and similarly, the image block immediately above the current image block is considered the above adjacent image block. This is for illustrative purposes only. The image blocks adjacent to the current image block in the embodiments of the present application are not limited to the eight image blocks closest to the current image block. For example, the image block immediately to the left of the current image block may also be considered an adjacent image block of the current image block. Image blocks within an appropriate range may be selected as adjacent image blocks based on the actual requirements of the image to be compressed.
[0110] Method 2: predict all low-frequency DCT coefficients in the DCT coefficient matrix of the current image block based on the low-frequency DCT coefficients and high-frequency DCT coefficients in the DCT coefficient matrix of the left adjacent image block and the DCT coefficient matrix of the upper adjacent image block.
[0111] As an example, assume that the size of each image block is 8×8, and the DCT coefficient matrix of the current image block is also represented as X. The DCT coefficient matrices of its upper left adjacent image block, the DCT coefficient matrices of the upper adjacent image block, and the DCT coefficient matrices of the left adjacent image block are represented by A, B, and C, respectively. Specifically, when predicting the low-frequency DCT coefficients of the leftmost column of the current image block, the calculation is performed based on the high-frequency DCT coefficients in the same row of each DCT coefficient and the DCT coefficients at the corresponding position in the left adjacent image block. The specific formula is as follows:
[0112] Among them, (i, j) represents the position of the i+1th row and j+1th column in the DCT coefficient matrix, X i,k Represents the DCT coefficient of the (i, j) position in the matrix X. Similarly, C i,k represents the DCT coefficient at position (i, j) in matrix C, represents the predicted value of the DCT coefficient at position (i,0) in matrix X.
[0113] According to the above formula, when predicting the low-frequency DCT coefficients in the first column and the i+1th row of matrix X, it is necessary to use the low-frequency DCT coefficients in the first column and the i+1th row of matrix C and the high-frequency DCT coefficients in the i+1th row of X and C. Since the high-frequency DCT coefficients can be obtained by decoding the compressed file, and the low-frequency DCT coefficients of the left-adjacent matrix are also obtained through inverse prediction before the current DCT coefficient matrix, the above formula can predict the low-frequency DCT coefficients in the first column of X using known quantities.
[0114] In a similar way, when predicting the low-frequency DCT coefficients of the top row of the current image block, the calculation is based on the high-frequency DCT coefficients in the same column of each DCT coefficient and the DCT coefficients at the corresponding position in the upper adjacent image block. The specific formula is as follows:
[0115] According to the above formula, when predicting the low-frequency DCT coefficient in the first row, j+1 column of matrix X, it is necessary to use the low-frequency DCT coefficient in the first row, j+1 column of matrix C and the high-frequency DCT coefficient in the j+1 column of X and C. Since these quantities are known, the low-frequency DCT coefficient in the first row of X can be predicted using these known quantities. The low-frequency DCT coefficient at position (0,0) is determined by averaging the other low-frequency DCT coefficients using the above two formulas.
[0116] Although the computational complexity of this method is higher than that of method 1, it can achieve better prediction results because more factors such as high-frequency DCT coefficients are also referred to during prediction.
[0117] It should be understood that the two prediction rules described above are merely examples of how to predict low-frequency DCT coefficients, and this application does not limit the specific prediction formulas used. Any calculation method based on known quantities for the image file decoding device can achieve the purpose of predicting low-frequency DCT coefficients in this application, and this application does not impose specific restrictions on this. On this basis, the correlation between adjacent image blocks is stronger, and the predicted values obtained by predicting adjacent image blocks can be closer to the original values, thereby reducing the absolute value of the residual value and improving the compression ratio.
[0118] S240: Determine a plurality of residual values according to the difference between the predicted value and a plurality of low-frequency DCT coefficients.
[0119] For example, in step S240, the image file encoding device may subtract the predicted value at the corresponding position calculated in step S230 from the original value of the low-frequency DCT coefficient to obtain a residual value of the low-frequency DCT coefficient at that position. It should be understood that the multiple residual values determined in step S240 correspond one-to-one to the multiple low-frequency DCT coefficients in the DCT coefficient matrix, that is, each low-frequency DCT coefficient corresponds to a residual value.
[0120] As previously mentioned, the predicted value is a value that can be calculated identically on both the encoding and decoding sides. Therefore, the image file encoding device transmits the residual value to the image file decoding device. The image file decoding device then calculates the original value of the low-frequency DCT coefficients before compression based on the calculated predicted value and the residual value. Therefore, the prediction step is lossless for the low-frequency DCT coefficients, reducing the size of the transmitted file while preserving the key image information contained in the low-frequency DCT coefficients, thereby ensuring image restoration quality.
[0121] S250: Encode the multiple residual values and at least one dimension-reduced DCT coefficient to generate a compressed bit string of the DCT coefficient matrix of the n-th image block.
[0122] For example, in step S250, the image file encoding device may encode the residual value and the dimension-reduced DCT coefficient to be transmitted from numerical values into a compressed bit string form, thereby generating a compressed image file for transmission.
[0123] In some possible implementations, the image file encoder can convert M n The value to be encoded is represented as a combination of symbol, bit length and remaining bit string, and then the symbol and bit length are encoded into a bit string through entropy coding, which is then concatenated with the remaining bit string to generate a compressed bit string. n The value to be encoded and M n The matrix parameters correspond one to one, M n The matrix parameters include the multiple residual values determined in S240 and the at least one reduced-dimensional DCT coefficient determined in S220 , that is, each value to be encoded corresponds to a residual value or a reduced-dimensional DCT coefficient.
[0124] Specifically, the sign, also known as the first field of the encoded value, indicates the sign of the value. The bit length, also known as the second field of the encoded value, indicates the number of bits in the binary representation of the absolute value of the value. The remaining bit string, also known as the third field of the encoded value, is a bit string determined by the binary representation of the absolute value of the value. For the value 0, the sign and remaining bit string are not included after conversion; only the bit length is represented by 0. For non-zero values, two different values are used to indicate the sign of the value, for example, 0 indicates a positive value and 1 indicates a negative value. The bit length indicates the number of bits in the binary representation of the absolute value of the value to be encoded. The remaining bit string is the bit sequence after removing the leading 1 from the binary representation of the absolute value of the encoded value. For example, if the value to be encoded is -2023, since it is a negative number, the absolute value of 2023 is represented in binary as 11111100111, which has 11 bits. Therefore, the sign is 1, the bit length is 11, and the remaining bit string is 1111100111.
[0125] Through the above transformation, the length of the bit string after encoding the value to be encoded can be compressed. If the value is directly represented as a binary bit stream and compressed, the same number of bits must be allocated to each value to ensure that the correct value can be extracted from the bit stream during decoding. For example, if the possible transmitted values range from -255 to 255, 9 bits must be reserved for each value to ensure that all possible values can be represented. However, after compression through high-frequency dimensionality reduction and low-frequency residual prediction, the majority of values are likely to be small values distributed around 0. The number of bits actually required for these values is far less than 9 bits, resulting in a waste of bits. By representing the value as a symbol, a bit length, and the actual bit string required to represent the value, each symbol and bit length is represented by a uniquely determined encoding format. During decoding, after reading a set of symbols and bit lengths, the corresponding number of bits in the compressed bit string is read according to the value indicated by the bit length, thereby completely decoding the value. The next set of symbols and bit lengths is then read, and so on, to decode all the values represented in the bit stream. Through the above transformation, the bit string representing each value in the compressed bit string is of the shortest length rather than a fixed length, avoiding bit redundancy, thereby reducing the bit string length required to represent the image file after encoding and improving the compression rate.
[0126] In the above method, in order for the compressed bit string to be correctly decoded, each symbol and bit length must use a different, unambiguous encoding method. This can be achieved by performing entropy coding on the symbols and bit lengths. Data can be encoded according to a certain probability model to a value close to the entropy corresponding to that probability model, thereby achieving the purpose of compression. Specifically, entropy coding assigns a bit string to represent each object to be encoded. The higher the probability of occurrence, the shorter the bit string length used. Furthermore, the bit string of each object to be encoded will not become a prefix subset of the bit string of another object to be encoded, thereby avoiding ambiguity during decoding. The object to be encoded may include, but is not limited to, a symbol, a bit length, or a combination of a symbol and a bit length. Optionally, the entropy coding algorithm may include, but is not limited to, Huffman coding, arithmetic coding, etc., which is not specifically limited in this application. Entropy coding can minimize the number of bits required to represent each combination, reduce the length of the bit string required to represent the image file after encoding, and improve the compression ratio.
[0127] Optionally, the entropy coding method may be dynamic entropy coding. Specifically, the probability model used to encode each object to be encoded may be different. Before encoding each object to be encoded, the image file encoding device may select a different probability model, based on any historical information or a function thereof prior to encoding the object to be encoded. Dynamic entropy coding can make the encoding result closer to the information entropy value, thereby improving the compression ratio.
[0128] Through the technical solutions of the embodiments of the present application, it is possible to use a low-computational complexity algorithm to employ lossless predictive compression for low-frequency DCT coefficients containing more image information, and to employ high-compression-ratio dimensionality reduction compression for high-frequency DCT coefficients containing less image information. The image file encoded in this manner has a high compression ratio, which can meet transmission requirements. Furthermore, after decoding, the encoded image file can maintain a high structural similarity index measure (SSIM) and peak signal-to-noise ratio (PSNR), enabling these indicators to meet specific image file usage requirements, such as for fault identification. This improves the image file compression ratio while ensuring high quality of the restored image.
[0129] Optionally, in step S230, to further improve the compression ratio, a lossy quantization operation may be performed on the DCT coefficient matrix before predicting the low-frequency DCT coefficients. Specifically, the image file encoding device may set a quantization coefficient matrix of the same size based on the size of the DCT coefficient matrix, and divide each DCT coefficient by the quantization coefficient at the corresponding position, thereby reducing the size of the DCT coefficient, reducing the number of bits required for data transmission, and improving the compression ratio.
[0130] In the above process, since the quantization result may contain a fractional part, it is necessary to discard the fractional part for transmission, so the quantization operation is lossy. Therefore, different quantization coefficients can be set for different DCT coefficients. For example, the quantization coefficient corresponding to the low-frequency DCT coefficient is smaller than the quantization coefficient corresponding to the high-frequency DCT coefficient. The smaller the quantization coefficient, the smaller the DCT coefficient loss caused by discarding the fractional part. Therefore, by setting the appropriate quantization coefficient, the loss of low-frequency information caused by the quantization operation can be minimized, thereby ensuring the quality of the restored image.
[0131] Optionally, in the above-mentioned DCT coefficient quantization operation, the quantization of the low-frequency DCT coefficients and the high-frequency DCT coefficients can be performed separately. For example, the quantization of the high-frequency DCT coefficients can be performed before or after dimensionality reduction. This application does not specifically limit this. However, in order to ensure information parity between the encoding and decoding sides when predicting the low-frequency DCT coefficients, the quantization of the DCT coefficients required by the prediction algorithm must be performed before prediction.
[0132] The above description of the image file encoding method provided by the embodiment of the present application is combined with Figures 2 to 4. The following description of the image file decoding method provided by the embodiment of the present application is combined with Figure 5 in detail.
[0133] FIG5 is a schematic flowchart of a method for decoding an image file according to an embodiment of the present application. Optionally, the method of FIG5 can be performed by an image file decoding device, such as the image file decoding device 12 in FIG1 . The image file decoding method shown in FIG5 corresponds to the implementation of the relevant steps in the image file encoding method shown in FIG2 . Therefore, the implementation of some steps will not be further illustrated. For specific implementations, please refer to the description of the corresponding steps in the method shown in FIG2 .
[0134] As shown in FIG5 , the method includes the following steps.
[0135] S510: Obtain a compressed bit string corresponding to the nth image block among N image blocks included in the image.
[0136] For example, in step S510, the image file decoding device can obtain a compressed image file, such as a compressed image file generated by the image file encoding device according to the method shown in FIG2 . Specifically, the compressed image file may include N compressed bit strings corresponding one-to-one to N image blocks of the image, and the image file decoding device can obtain the compressed bit string corresponding to the nth image block therefrom, where N is a positive integer greater than 1, and n is a positive integer greater than or equal to 1 and less than or equal to N.
[0137] S520: Decode the compressed bit string to determine a plurality of residual values and at least one reduced-dimensional DCT coefficient corresponding to the n-th image block.
[0138] For example, in step S520, the image file decoding device can decode a plurality of residual values and at least one reduced-dimensional DCT coefficient required to determine the DCT coefficient of the n-th image from the compressed bit string.
[0139] In some possible implementations, each value to be decoded is represented in the compressed bit string by a segment of entropy coded bit string and a third field of the value to be decoded, and the image file decoding device can parse the compressed bit string to obtain the value corresponding to M. n M values to be decoded correspond one to one n entropy coded bit strings and M n A third field, where M n The value to be decoded and M n The matrix parameters correspond one to one, M n The matrix parameters include a plurality of residual values and at least one reduced-dimensional DCT coefficient.
[0140] For example, an image file decoding device reads bits from a compressed bit string from left to right. Assuming the first four bits of the compressed bit string are 1111, the entropy-coded bit string 1111 indicates that the matrix parameter corresponding to the value to be decoded is less than zero and has 11 binary bits. According to the entropy coding algorithm, the entropy-coded bit string corresponding to each object to be encoded does not become a prefix subset of the entropy-coded bit string corresponding to any other object to be encoded. Since 1111 is used as the entropy-coded bit string, to avoid ambiguity, its prefix subsets 1, 11, and 111 do not represent any information. Therefore, if the image file decoding device first reads the first bit 1 and fails to parse out any information, it then reads the first two bits 11, still failing to parse out any information. This continues until it reads the first four bits 1111, parses out the information "negative sign" and "bit count 11," and then reads the bit string consisting of bits 5 through 14, 10 bits after the bit count indication. This bit string represents the remaining bit string of the matrix parameter corresponding to the value to be decoded. Assuming the remaining bit string is 1111100111, it can be determined that the binary absolute value of the matrix parameter corresponding to the value to be decoded is 11111100111, which corresponds to the decimal number 2023. Combined with the determined sign, the value of the matrix parameter represented by bits 1 to 14 in the compressed bit string is ultimately determined to be -2023. If decoding is not complete, the image file decoding device repeats the above process starting from bit 15 to determine the next matrix parameter until all matrix parameters are decoded.
[0141] S530: Determine a plurality of high-frequency DCT coefficients in a DCT coefficient matrix of the n-th image block according to the at least one dimension-reduced DCT coefficient.
[0142] For example, in step S530, the image file decoding device can pad the high-frequency DCT coefficient portion of the DCT coefficient matrix based on the reduced-dimensionality DCT coefficients determined in S520. Specifically, because the dimensionality reduction rule agreed upon with the image file encoding device indicates the position of the reduced-dimensionality DCT coefficients in the DCT coefficient matrix, the image file decoding device can determine, in accordance with the dimensionality reduction rule, the values of the multiple high-frequency DCT coefficients included in the DCT coefficient matrix, excluding the reduced-dimensionality DCT coefficients, as fixed values, such as 0. The specific dimensionality reduction rule can be found in the description of step S220 above and will not be further elaborated here.
[0143] S540: Determine predicted values of a plurality of low-frequency DCT coefficients in the DCT coefficient matrix of the n-th image block.
[0144] For example, in step S540, the image file decoding device can predict the low-frequency DCT coefficient portion of the DCT coefficient matrix of the current nth image block according to the prediction rule. The specific prediction method can be found in the description of the aforementioned step S230 and will not be repeated here.
[0145] S550: Determine a plurality of low-frequency DCT coefficients according to the predicted value and the plurality of residual values.
[0146] For example, in step S550, the image file decoding device can add the prediction value calculated in S540 to the residual value of the corresponding position determined in S520 to obtain the low-frequency DCT coefficient corresponding to the position, wherein the multiple residual values determined in S520 correspond one-to-one to the multiple low-frequency DCT coefficients included in the DCT coefficient matrix.
[0147] S560: Determine a DCT coefficient matrix of the nth image block according to the multiple high-frequency DCT coefficients and the multiple low-frequency DCT coefficients.
[0148] For example, in step S550, the image file decoding device can restore the DCT coefficient matrix corresponding to the current n-th image block according to the high-frequency DCT coefficients determined in S530 and the low-frequency DCT coefficients determined in S550.
[0149] Optionally, if a quantization operation is performed during image file encoding, the image file decoding device may first inverse quantize the low-frequency DCT coefficients and the high-frequency DCT coefficients before determining the DCT coefficient matrix of the nth image block. Specifically, inverse quantization is the opposite of the quantization operation, i.e., using the same quantization coefficient matrix as used during quantization, each DCT coefficient is multiplied by the quantization coefficient at the corresponding position.
[0150] In some possible implementations, after obtaining the DCT coefficient matrices of all N image blocks of the image using the method shown in FIG5 , the image file decoding device can generate a JPEG format image file based on the DCT coefficient matrix corresponding to each of the N image blocks of the image, thereby using the standard format image file for subsequent transmission or storage. For example, the decoded JPEG format image file is uploaded to and stored on a server via the remote communication module 123 shown in FIG1 .
[0151] In other possible implementations, after obtaining the DCT coefficient matrices of all N image blocks of the image using the method shown in FIG5 , the image file decoding device can obtain the pixel value of each pixel in the image in the YUV color space through an inverse DCT transform, thereby directly outputting the image for subsequent image processing and use. For example, the image can be output to the main control and processing module 122 shown in FIG1 for image recognition.
[0152] The above describes an embodiment of the method for encoding and decoding an image file provided by the present application in conjunction with Figures 2 to 5. The following describes an embodiment of the device for encoding and decoding an image file provided by the present application in conjunction with Figures 6 to 8.
[0153] FIG6 shows a schematic structural block diagram of an encoder 600 for processing image files provided in an embodiment of the present application.
[0154] As shown in FIG6 , the image file encoder 600 includes: an acquisition module 610 , a high-frequency dimension reduction module 620 , a low-frequency prediction module 630 , a residual calculation module 640 , and an encoding module 650 .
[0155] Specifically, the acquisition module 610 is used to obtain the discrete cosine transform DCT coefficient matrix of the nth image block among the N image blocks included in the image, wherein the DCT coefficient matrix of the nth image block includes multiple low-frequency DCT coefficients and multiple high-frequency DCT coefficients, N is a positive integer greater than 1, and n is a positive integer greater than or equal to 1 and less than or equal to N.
[0156] Optionally, the acquisition module 610 is specifically configured to decode and acquire a DCT coefficient matrix from an image file in the Joint Photographic Experts Group JPEG format.
[0157] Specifically, the high frequency dimension reduction module 620 is configured to determine at least one dimension-reduced DCT coefficient, wherein the at least one dimension-reduced DCT coefficient includes a portion of high frequency DCT coefficients of the plurality of high frequency DCT coefficients.
[0158] Optionally, the high frequency dimension reduction module 620 is further configured to replace high frequency DCT coefficients other than at least one dimension-reduced DCT coefficient in the DCT coefficient matrix of the n-th image block with 0.
[0159] Specifically, the low-frequency prediction module 630 is used to determine predicted values of a plurality of low-frequency DCT coefficients.
[0160] Optionally, the low-frequency prediction module 630 is specifically used to determine the predicted values of multiple low-frequency DCT coefficients in the DCT coefficient matrix of the n-th image block based on the DCT coefficient matrix of the prediction information image block when there is a prediction information image block in the n-th image block, wherein the prediction information image block is at least one image block among the N image blocks, and the at least one image block is adjacent to the n-th image block and is located at a specific position; when there is no prediction information image block in the n-th image block, determine that the predicted values of multiple low-frequency DCT coefficients in the DCT coefficient matrix of the n-th image block are 0.
[0161] Specifically, the residual calculation module 640 is configured to determine a plurality of residual values according to the difference between the prediction value and the plurality of low-frequency DCT coefficients, wherein the plurality of residual values correspond to the plurality of low-frequency DCT coefficients in a one-to-one manner.
[0162] Specifically, the encoding module 650 is configured to encode a plurality of residual values and at least one reduced-dimensional DCT coefficient to generate a compressed bit string of the DCT coefficient matrix of the n-th image block.
[0163] Optionally, the encoding module 650 is specifically configured to determine M n Number of values to be encoded, where M n The value to be encoded and M n The matrix parameters correspond one to one, M n The matrix parameters include multiple residual values and at least one reduced-dimensional DCT coefficient, M n Each of the values to be encoded includes a first field, a second field, and a third field. The first field of each value to be encoded is used to indicate the positive or negative sign of the matrix parameter corresponding to each value to be encoded. The second field of each value to be encoded is used to indicate the number of bits of the binary number of the matrix parameter corresponding to each value to be encoded. The third field of each value to be encoded is a bit string determined according to the binary representation of the absolute value of the matrix parameter corresponding to each value to be encoded. n is a positive integer greater than 2; for M n The first field and the second field of the to-be-encoded value are entropy-encoded to determine the entropy-encoded bit string of each to-be-encoded value; according to M n The entropy coded bit string of the value to be coded and M n The third field of each value to be encoded is used to generate a compressed bit string, wherein the compressed bit string includes the entropy encoded bit string of each value to be encoded and the third field of each value to be encoded.
[0164] Optionally, the image file encoder 600 further includes a quantization module 660, which is used to quantize the DCT coefficient matrix of the nth image block according to the quantization coefficient matrix, wherein the quantization coefficient corresponding to the low-frequency DCT coefficient is smaller than the quantization coefficient corresponding to the high-frequency DCT coefficient; the low-frequency prediction module 630 is specifically used to determine the predicted values of multiple low-frequency DCT coefficients based on the quantized DCT coefficient matrix.
[0165] FIG7 shows a schematic structural block diagram of a decoder 700 for processing image files provided in an embodiment of the present application.
[0166] As shown in FIG. 7 , the image file encoder 700 includes: an acquisition module 710 , a decoding module 720 , a high frequency determination module 730 , a low frequency prediction module 740 , a low frequency determination module 750 , and a matrix determination module 760 .
[0167] Specifically, the acquisition module 710 is used to acquire a compressed bit string corresponding to the nth image block among N image blocks included in the image, where N is a positive integer greater than 1, and n is a positive integer greater than or equal to 1 and less than or equal to N.
[0168] Specifically, the decoding module 720 is configured to decode the compressed bit string to determine a plurality of residual values and at least one reduced-dimensional DCT coefficient corresponding to the n-th image block.
[0169] Optionally, the decoding module 720 is specifically configured to parse the compressed bit string to obtain the bit sequence corresponding to M n M values to be decoded correspond one to one n entropy coded bit strings and M n A third field, where M n The value to be decoded and M n The matrix parameters correspond one to one, M n The matrix parameters include multiple residual values and at least one reduced-dimensional DCT coefficient. The third field is based on M n A bit string determined by the binary representation of the absolute value of the matrix parameter corresponding to each of the values to be decoded, M n is a positive integer greater than 2; according to the entropy coding algorithm, determine M n The first field and the second field of each to-be-decoded value corresponding to each entropy-coded bit string in the entropy-coded bit string are used to indicate the positive and negative of the matrix parameter corresponding to each to-be-decoded value, and the second field is used to indicate the number of bits of the binary number of the matrix parameter corresponding to each to-be-decoded value; and multiple residual values and at least one reduced-dimensional DCT coefficient are determined according to the first field, the second field and the third field of each to-be-decoded value.
[0170] Specifically, the high frequency determination module 730 is configured to determine a plurality of high frequency DCT coefficients in the DCT coefficient matrix of the nth image block according to at least one dimensionally reduced DCT coefficient.
[0171] Optionally, the high frequency determination module 730 is specifically configured to determine the values of the multiple high frequency DCT coefficients except for at least one reduced-dimensionality DCT coefficient to be 0.
[0172] Specifically, the low-frequency prediction module 740 is configured to determine predicted values of a plurality of low-frequency DCT coefficients in the DCT coefficient matrix of the n-th image block.
[0173] Optionally, the low-frequency prediction module 740 is specifically used to determine the predicted values of multiple low-frequency DCT coefficients in the DCT coefficient matrix of the n-th image block based on the DCT coefficient matrix of the prediction information image block when there is a prediction information image block in the n-th image block, wherein the prediction information image block is at least one image block among the N image blocks, and the at least one image block is adjacent to the n-th image block and is located at a specific position; when there is no prediction information image block in the n-th image block, determine that the predicted values of multiple low-frequency DCT coefficients in the DCT coefficient matrix of the n-th image block are 0.
[0174] Specifically, the low-frequency determination module 750 is configured to determine a plurality of low-frequency DCT coefficients according to the prediction value and a plurality of residual values, wherein the plurality of residual values correspond one-to-one to the plurality of low-frequency DCT coefficients.
[0175] Specifically, the matrix determination module 760 is configured to determine the DCT coefficient matrix of the nth image block according to a plurality of high-frequency DCT coefficients and a plurality of low-frequency DCT coefficients.
[0176] Optionally, the image file decoder 700 further includes an inverse quantization module 770, which is used to perform inverse quantization on multiple high-frequency DCT coefficients and multiple low-frequency DCT coefficients according to a quantization coefficient matrix, wherein the quantization coefficients corresponding to the multiple low-frequency DCT coefficients are smaller than the quantization coefficients corresponding to the multiple high-frequency DCT coefficients; the matrix determination module 760 is specifically used to determine the DCT coefficient matrix of the nth image block based on the multiple high-frequency DCT coefficients after inverse quantization and the multiple low-frequency DCT coefficients after inverse quantization.
[0177] Optionally, the image file decoder 700 further includes a file generating module 780 for generating an image file in JPEG format according to a DCT coefficient matrix corresponding to each of the N image blocks of the image.
[0178] The modules in the image file encoder 600 and the image file decoder 700 may be implemented by software or hardware.
[0179] It should be noted that, in other embodiments, the acquisition module 610, the high-frequency dimensionality reduction module 620, the low-frequency prediction module 630, the residual calculation module 640, the encoding module 650 and the quantization module 660 can be respectively used to execute any step in the above-mentioned image file encoding method. The steps that the acquisition module 610, the high-frequency dimensionality reduction module 620, the low-frequency prediction module 630, the residual calculation module 640, the encoding module 650 and the quantization module 660 are responsible for implementing can be specified as needed. The full functions of the image file encoder are realized by implementing different steps in the above-mentioned image file encoding method through the acquisition module 610, the high-frequency dimensionality reduction module 620, the low-frequency prediction module 630, the residual calculation module 640, the encoding module 650 and the quantization module 660.
[0180] Correspondingly, in other embodiments, the acquisition module 710, the decoding module 720, the high-frequency determination module 730, the low-frequency prediction module 740, the low-frequency determination module 750, the matrix determination module 760, the inverse quantization module 770, and the file generation module 780 can be respectively used to perform any step in the above-mentioned image file decoding method. The steps that the acquisition module 710, the decoding module 720, the high-frequency determination module 730, the low-frequency prediction module 740, the low-frequency determination module 750, the matrix determination module 760, the inverse quantization module 770, and the file generation module 780 are responsible for implementing can be specified as needed. By having the acquisition module 710, the decoding module 720, the high-frequency determination module 730, the low-frequency prediction module 740, the low-frequency determination module 750, the matrix determination module 760, the inverse quantization module 770, and the file generation module 780 respectively implement different steps in the above-mentioned image file decoding method, all functions of the image file decoder are realized.
[0181] This application also provides a computing device 100. As shown in FIG8 , computing device 100 includes a bus 102, a processor 104, a memory 106, and a communication interface 108. Processor 104, memory 106, and communication interface 108 communicate with each other via bus 102. Computing device 100 may be an image file encoding device or an image file decoding device. It should be understood that this application does not limit the number of processors and memories in computing device 100.
[0182] Bus 102 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, among others. Buses may be classified as address buses, data buses, control buses, and the like. For ease of illustration, FIG8 illustrates a single bus line, but this does not imply a single bus or type of bus. Bus 102 may include a path for transmitting information between various components of computing device 100 (e.g., memory 106, processor 104, and communication interface 108).
[0183] The processor 104 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0184] The memory 106 may include volatile memory, such as random access memory (RAM). The processor 104 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0185] The memory 106 stores executable program code. The processor 104 executes the executable program code to implement the functions of the aforementioned acquisition module, high-frequency dimensionality reduction module, low-frequency prediction module, residual calculation module, and encoding module, or to implement the functions of the aforementioned acquisition module, decoding module, high-frequency determination module, low-frequency prediction module, low-frequency determination module, and matrix determination module, thereby implementing the aforementioned image file encoding method or image file decoding method. In other words, the memory 106 stores instructions for executing the aforementioned image file encoding method or image file decoding method.
[0186] The communication interface 108 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 100 and other devices or a communication network.
[0187] An embodiment of the present application further provides a chip, which includes a processor and a data interface. The processor reads instructions stored in a memory through the data interface to execute the above-mentioned image file encoding method or image file decoding method.
[0188] Embodiments of the present application also provide a computer program product containing instructions. This computer program product can be software or a program product containing instructions that can be run on a computing device or stored on any available medium. When this computer program product is run on at least one computing device, it causes the at least one computing device to execute the aforementioned image file encoding method or image file decoding method.
[0189] The present application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be stored by a computing device, or a data storage device such as a data center that contains one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive). The computer-readable storage medium includes instructions that instruct the computing device to execute the above-mentioned image file encoding method or image file decoding method.
[0190] The technical features of the above-mentioned embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above-mentioned embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0191] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the protection scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for encoding an image file, characterized in that: include: Acquire a discrete cosine transform (DCT) coefficient matrix of an n-th image block among N image blocks included in the image, wherein the DCT coefficient matrix of the n-th image block includes a plurality of low-frequency DCT coefficients and a plurality of high-frequency DCT coefficients, N is a positive integer greater than 1, and n is a positive integer greater than or equal to 1 and less than or equal to N; Determining at least one reduced-dimensionality DCT coefficient, wherein the at least one reduced-dimensionality DCT coefficient includes a portion of high-frequency DCT coefficients of the plurality of high-frequency DCT coefficients; Determining predicted values of the plurality of low-frequency DCT coefficients; Determine a plurality of residual values according to a difference between the predicted value and the plurality of low-frequency DCT coefficients, wherein the plurality of residual values correspond one-to-one to the plurality of low-frequency DCT coefficients; The plurality of residual values and the at least one reduced-dimensional DCT coefficient are encoded to generate a compressed bit string of the DCT coefficient matrix of the n-th image block.
2. The method according to claim 1, characterized in that Before determining the predicted values of the plurality of low-frequency DCT coefficients, the method further comprises: The high-frequency DCT coefficients other than the at least one reduced-dimensional DCT coefficient in the DCT coefficient matrix of the n-th image block are replaced with 0.
3. The method according to claim 1 or 2, characterized in that: The step of determining the predicted values of the plurality of low-frequency DCT coefficients comprises: In the case where the n-th image block has a prediction information image block, determining the prediction values of the plurality of low-frequency DCT coefficients in the DCT coefficient matrix of the n-th image block according to the DCT coefficient matrix of the prediction information image block, wherein the prediction information image block is at least one image block among the N image blocks, and the at least one image block is adjacent to the n-th image block and is located at a specific position; In the case that the n-th image block has no prediction information image block, the prediction values of the multiple low-frequency DCT coefficients in the DCT coefficient matrix of the n-th image block are determined to be 0.
4. The method according to any one of claims 1 to 3, characterized in that Before determining the predicted values of the plurality of low-frequency DCT coefficients, the method further comprises: quantizing the DCT coefficient matrix of the n-th image block according to the quantization coefficient matrix, wherein the quantization coefficient corresponding to the low-frequency DCT coefficient is smaller than the quantization coefficient corresponding to the high-frequency DCT coefficient; The step of determining the predicted values of the plurality of low-frequency DCT coefficients comprises: The predicted values of the plurality of low-frequency DCT coefficients are determined according to the quantized DCT coefficient matrix.
5. The method according to any one of claims 1 to 4, characterized in that: The encoding of the residual value and the reduced-dimensional DCT coefficient to generate a compressed bit string of the DCT coefficient matrix of the n-th image block includes: Determine M n To be encoded values, where the M n The number to be encoded and M n The matrix parameters correspond one to one, and the M n The matrix parameters include the plurality of residual values and the at least one reduced-dimensional DCT coefficient, the M n Each of the to-be-encoded values includes a first field, a second field, and a third field, wherein the first field of each of the to-be-encoded values is used to indicate the positive or negative of the matrix parameter corresponding to each of the to-be-encoded values, the second field of each of the to-be-encoded values is used to indicate the number of bits of the binary number of the matrix parameter corresponding to each of the to-be-encoded values, and the third field of each of the to-be-encoded values is a bit string determined according to the binary representation of the absolute value of the matrix parameter corresponding to each of the to-be-encoded values, M n is a positive integer greater than 2; For the M n entropy encoding the first field and the second field of each to-be-encoded value to determine an entropy coded bit string for each to-be-encoded value; According to the M n The entropy coded bit string of the value to be coded and the M n The third field of each value to be encoded is used to generate the compressed bit string, wherein the compressed bit string includes the entropy encoded bit string of each value to be encoded and the third field of each value to be encoded.
6. The method according to any one of claims 1 to 5, characterized in that The DCT coefficient matrix of the nth image block among the N image blocks included in the acquired image includes: The DCT coefficient matrix is obtained by decoding from an image file in the Joint Photographic Experts Group JPEG format.
7. A method for decoding an image file, characterized in that: include: Obtain the compressed bit string corresponding to the nth image block among the N image blocks included in the image, where N is a positive integer greater than 1 and n is A positive integer greater than or equal to 1 and less than or equal to N; Decoding the compressed bit string to determine a plurality of residual values and at least one reduced-dimensional DCT coefficient corresponding to the n-th image block; Determine a plurality of high-frequency DCT coefficients in a DCT coefficient matrix of the nth image block according to the at least one reduced-dimensional DCT coefficient; Determining predicted values of a plurality of low-frequency DCT coefficients in the DCT coefficient matrix of the nth image block; Determine the plurality of low-frequency DCT coefficients according to the predicted value and the plurality of residual values, wherein the plurality of residual values correspond one-to-one to the plurality of low-frequency DCT coefficients; A DCT coefficient matrix of the nth image block is determined according to the multiple high-frequency DCT coefficients and the multiple low-frequency DCT coefficients.
8. The method according to claim 7, characterized in that The step of determining a plurality of high-frequency DCT coefficients in the DCT coefficient matrix of the n-th image block according to the at least one reduced-dimensional DCT coefficient comprises: The values of the plurality of high frequency DCT coefficients other than the at least one reduced dimension DCT coefficient are determined to be zero.
9. The method according to claim 7 or 8, characterized in that: The step of determining the predicted values of a plurality of low-frequency DCT coefficients in the DCT coefficient matrix of the n-th image block comprises: In the case where the n-th image block has a prediction information image block, determining the prediction values of the plurality of low-frequency DCT coefficients in the DCT coefficient matrix of the n-th image block according to the DCT coefficient matrix of the prediction information image block, wherein the prediction information image block is at least one image block among the N image blocks, and the at least one image block is adjacent to the n-th image block and is located at a specific position; In the case that the n-th image block has no prediction information image block, the prediction values of the multiple low-frequency DCT coefficients in the DCT coefficient matrix of the n-th image block are determined to be 0.
10. The method according to any one of claims 7 to 9, characterized in that The method further comprises: According to a quantization coefficient matrix, inverse quantization is performed on the multiple high-frequency DCT coefficients and the multiple low-frequency DCT coefficients, wherein the quantization coefficients corresponding to the multiple low-frequency DCT coefficients are smaller than the quantization coefficients corresponding to the multiple high-frequency DCT coefficients; The step of determining the DCT coefficient matrix of the n-th image block according to the multiple high-frequency DCT coefficients and the multiple low-frequency DCT coefficients includes: The DCT coefficient matrix of the n-th image block is determined according to the multiple high-frequency DCT coefficients after inverse quantization and the multiple low-frequency DCT coefficients after inverse quantization.
11. The method according to any one of claims 7 to 10, characterized in that The decoding of the compressed bit string comprises: Parse the bit string corresponding to M from the compressed bit string n The M values to be decoded correspond to each other n entropy coded bit strings and M n A third field, wherein the M n The number to be decoded and M n The matrix parameters correspond one to one, and the M n The matrix parameters include the plurality of residual values and the at least one reduced-dimensional DCT coefficient, and the third field is based on the M n A bit string determined by the binary representation of the absolute value of the matrix parameter corresponding to each of the values to be decoded, M n is a positive integer greater than 2; According to the entropy coding algorithm, the M n a first field and a second field of each to-be-decoded value corresponding to each entropy-coded bit string in an entropy-coded bit string, wherein the first field is used to indicate the positive or negative of the matrix parameter corresponding to each to-be-decoded value, and the second field is used to indicate the number of bits of the binary number of the matrix parameter corresponding to each to-be-decoded value; The multiple residual values and the at least one reduced-dimensional DCT coefficient are determined according to the first field, the second field and the third field of each value to be decoded.
12. The method according to any one of claims 7 to 11, characterized in that The method further comprises: An image file in JPEG format is generated according to the DCT coefficient matrix corresponding to each image block in the N image blocks of the image.
13. An image file encoder, characterized in that: include: An acquisition module, used to acquire a discrete cosine transform DCT coefficient matrix of an n-th image block among N image blocks included in the image, wherein the DCT coefficient matrix of the n-th image block includes a plurality of low-frequency DCT coefficients and a plurality of high-frequency DCT coefficients, N is a positive integer greater than 1, and n is a positive integer greater than or equal to 1 and less than or equal to N; A high frequency dimension reduction module, used for determining at least one dimension reduction DCT coefficient, wherein the at least one dimension reduction DCT coefficient comprises part of the high frequency DCT coefficients of the plurality of high frequency DCT coefficients; A low frequency prediction module, used to determine the predicted values of the plurality of low frequency DCT coefficients; A residual calculation module, used to determine a plurality of residual values according to the difference between the predicted value and the plurality of low-frequency DCT coefficients, wherein the plurality of residual values correspond to the plurality of low-frequency DCT coefficients one by one; An encoding module is used to encode the multiple residual values and the at least one reduced-dimensional DCT coefficient to generate a compressed bit string of the DCT coefficient matrix of the n-th image block.
14. The image file encoder according to claim 13, characterized in that: Before determining the predicted values of the plurality of low-frequency DCT coefficients, the high-frequency dimension reduction module is further used to: The high-frequency DCT coefficients other than the at least one reduced-dimensional DCT coefficient in the DCT coefficient matrix of the n-th image block are replaced with 0.
15. The image file encoder according to claim 13 or 14, characterized in that: The low frequency prediction module is used for: In the case where the n-th image block has a prediction information image block, determining the prediction values of the plurality of low-frequency DCT coefficients in the DCT coefficient matrix of the n-th image block according to the DCT coefficient matrix of the prediction information image block, wherein the prediction information image block is at least one image block among the N image blocks, and the at least one image block is adjacent to the n-th image block and is located at a specific position; In the case that the n-th image block has no prediction information image block, the prediction values of the multiple low-frequency DCT coefficients in the DCT coefficient matrix of the n-th image block are determined to be 0.
16. The image file encoder according to any one of claims 13 to 15, characterized in that: The image file encoder further comprises a quantization module, which is used for: quantizing the DCT coefficient matrix of the n-th image block according to the quantization coefficient matrix, wherein the quantization coefficient corresponding to the low-frequency DCT coefficient is smaller than the quantization coefficient corresponding to the high-frequency DCT coefficient; The low frequency prediction module is used for: The predicted values of the plurality of low-frequency DCT coefficients are determined according to the quantized DCT coefficient matrix.
17. The image file encoder according to any one of claims 13 to 16, characterized in that: The encoding module is used for: Determine M n To be encoded values, where the M n The number to be encoded and M n The matrix parameters correspond one to one, and the M n The matrix parameters include the plurality of residual values and the at least one reduced-dimensional DCT coefficient, the M n Each of the to-be-encoded values includes a first field, a second field, and a third field, wherein the first field of each of the to-be-encoded values is used to indicate the positive or negative of the matrix parameter corresponding to each of the to-be-encoded values, the second field of each of the to-be-encoded values is used to indicate the number of bits of the binary number of the matrix parameter corresponding to each of the to-be-encoded values, and the third field of each of the to-be-encoded values is a bit string determined according to the binary representation of the absolute value of the matrix parameter corresponding to each of the to-be-encoded values, M n is a positive integer greater than 2; For the M n entropy encoding the first field and the second field of each to-be-encoded value to determine an entropy coded bit string for each to-be-encoded value; According to the M n The entropy coded bit string of the value to be coded and the M n The third field of each value to be encoded is used to generate the compressed bit string, wherein the compressed bit string includes the entropy encoded bit string of each value to be encoded and the third field of each value to be encoded.
18. The image file encoder according to any one of claims 13 to 17, characterized in that: The acquisition module is used to: The DCT coefficient matrix is obtained by decoding from an image file in the Joint Photographic Experts Group JPEG format.
19. An image file decoder, characterized in that: include: An acquisition module, used to acquire a compressed bit string corresponding to an n-th image block among N image blocks included in the image, wherein N is a positive integer greater than 1, and n is a positive integer greater than or equal to 1 and less than or equal to N; A decoding module, used for decoding the compressed bit string to determine a plurality of residual values and at least one reduced-dimensional DCT coefficient corresponding to the n-th image block; A high frequency determination module, configured to determine a plurality of high frequency DCT coefficients in the DCT coefficient matrix of the nth image block according to the at least one dimensionally reduced DCT coefficient; A low-frequency prediction module, used to determine the predicted values of a plurality of low-frequency DCT coefficients in the DCT coefficient matrix of the n-th image block; A low-frequency determination module, configured to determine the plurality of low-frequency DCT coefficients according to the predicted value and the plurality of residual values, wherein the plurality of residual values correspond one-to-one to the plurality of low-frequency DCT coefficients; The matrix determination module is used to determine the DCT coefficient matrix of the nth image block according to the multiple high-frequency DCT coefficients and the multiple low-frequency DCT coefficients.
20. The image file decoder according to claim 19, characterized in that: The high frequency determination module is used to: The values of the plurality of high frequency DCT coefficients other than the at least one reduced dimension DCT coefficient are determined to be zero.
21. The image file decoder according to claim 19 or 20, characterized in that: The low frequency prediction module is used for: In the case where the n-th image block has a prediction information image block, determining the prediction values of the plurality of low-frequency DCT coefficients in the DCT coefficient matrix of the n-th image block according to the DCT coefficient matrix of the prediction information image block, wherein the prediction information image block is at least one image block among the N image blocks, and the at least one image block is adjacent to the n-th image block and is located at a specific position; In the case that the n-th image block has no prediction information image block, the prediction values of the multiple low-frequency DCT coefficients in the DCT coefficient matrix of the n-th image block are determined to be 0.
22. The image file decoder according to any one of claims 19 to 21, characterized in that: The image file decoder further comprises an inverse quantization module, which is used for: According to a quantization coefficient matrix, inverse quantization is performed on the multiple high-frequency DCT coefficients and the multiple low-frequency DCT coefficients, wherein the quantization coefficients corresponding to the multiple low-frequency DCT coefficients are smaller than the quantization coefficients corresponding to the multiple high-frequency DCT coefficients; The matrix determination module is used for: The DCT coefficient matrix of the n-th image block is determined according to the multiple high-frequency DCT coefficients after inverse quantization and the multiple low-frequency DCT coefficients after inverse quantization.
23. The image file decoder according to any one of claims 19 to 22, characterized in that: The decoding module is used for: Parse the bit string corresponding to M from the compressed bit string n The M values to be decoded correspond to each other n entropy coded bit strings and M n A third field, wherein the M n The number to be decoded and M n The matrix parameters correspond one to one, and the M n The matrix parameters include the plurality of residual values and the at least one reduced-dimensional DCT coefficient, and the third field is based on the M n A bit string determined by the binary representation of the absolute value of the matrix parameter corresponding to each of the values to be decoded, M n is a positive integer greater than 2; According to the entropy coding algorithm, the M n a first field and a second field of each to-be-decoded value corresponding to each entropy-coded bit string in an entropy-coded bit string, wherein the first field is used to indicate the positive or negative of the matrix parameter corresponding to each to-be-decoded value, and the second field is used to indicate the number of bits of the binary number of the matrix parameter corresponding to each to-be-decoded value; The multiple residual values and the at least one reduced-dimensional DCT coefficient are determined according to the first field, the second field and the third field of each value to be decoded.
24. The image file decoder according to any one of claims 19 to 23, characterized in that: The image file decoder also includes a file generation module, which is used to: An image file in JPEG format is generated according to the DCT coefficient matrix corresponding to each image block in the N image blocks of the image.
25. An image file encoding device, characterized in that: The apparatus comprises a processor and a memory, wherein the processor is used to execute instructions stored in the memory, so that the image file encoding device executes the method according to any one of claims 1 to 6.
26. An image file decoding device, characterized in that: The apparatus comprises a processor and a memory, wherein the processor is used to execute instructions stored in the memory, so that the image file encoding device executes the method according to any one of claims 7 to 12.
27. A computer-readable storage medium, characterized in that: The method comprises computer program instructions, which, when executed by a computing device, cause the computing device to execute the method according to any one of claims 1 to 6, or to execute the method according to any one of claims 7 to 12.
28. An image file encoding and decoding system, characterized in that: It comprises at least one image file encoding device as claimed in claim 25 and at least one image file decoding device as claimed in claim 26.
Citation Information
Patent Citations
Image coding method and device
CN101267566A
Lossless secondary compression method for JPEG image
CN109672891A
Guaranteed-Rate Tiled Image Data Compression
US20110206289A1
Image compression
US20200059670A1
Image compression method and apparatus
WO2022067526A1
