Image compression method and device
By chunking the image and selecting a combination of multiple compression methods, the problem of low compression quality caused by complex image feature recognition is solved, and efficient and accurate image compression effect is achieved.
Patent Information
- Application Number
- CN202110827582.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2017-05-03
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2037-05-03
AI Technical Summary
In the prior art, image feature recognition is complex and inaccurate, resulting in improper selection of image compression algorithms, which in turn affects image compression quality.
By blocking the images, each image block is compressed by multiple compression methods, and the compressed data with the best compression ratio or the best image recovery quality is selected as the preferred compressed data, and merge them to obtain the compression of the image result.
It realizes efficient and accurate image compression, improves image compression quality, and avoids the problems caused by complex image feature recognition.
Smart Images

Figure CN113570677B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular to an image compression method and device. Background Art
[0002] In the related art, when compressing an image, different types of images will get different compression ratios and image restoration qualities when compressed and encoded with different compression algorithms. Therefore, in order to achieve better compression quality, in the related art, a variety of methods are generally used to analyze image features, select the compression algorithm with the best image compression quality, and compress the image according to the selected compression algorithm. However, when analyzing image features, the algorithm for identifying image features is relatively complex and has low accuracy, which leads to inaccurate selection of image compression algorithms, and ultimately low image compression quality.
[0003] Therefore, in the related art, there is a problem that when compressing images by selecting a compression algorithm based on image features, not only is the image feature recognition complicated, but the image compression quality is also not high. Summary of the invention
[0004] The embodiments of the present invention provide an image compression method and device to at least solve the technical problems in the related art that image feature recognition is complicated and image compression quality is not high.
[0005] According to one aspect of an embodiment of the present invention, there is provided an image compression method, comprising: dividing an image into blocks to obtain a plurality of image blocks; compressing each of the plurality of image blocks respectively to obtain preferred compressed data; and merging the preferred compressed data obtained by compressing each image block to obtain a compression result of compressing the image.
[0006] Optionally, compressing each of the multiple image blocks separately to obtain the preferred compressed data includes: compressing each of the multiple image blocks using multiple compression methods to obtain corresponding multiple compressed data; and selecting compressed data with the best compression ratio from the multiple compressed data as the preferred compressed data.
[0007] Optionally, compressing each of the multiple image blocks separately to obtain the preferred compressed data includes: compressing each of the multiple image blocks using multiple compression methods to obtain corresponding multiple compressed data; reverse decoding the multiple compressed data using decoding methods corresponding to the multiple compression methods to obtain corresponding multiple decoded data; selecting decoded data with the best image restoration quality from the multiple decoded data, and using the compressed data corresponding to the selected decoded data as the preferred compressed data.
[0008] Optionally, compressing each of the multiple image blocks separately to obtain the preferred compressed data includes: compressing each of the multiple image blocks using multiple compression methods to obtain corresponding multiple compressed data; reverse decoding the multiple compressed data using decoding methods corresponding to the multiple compression methods to obtain corresponding multiple decoded data; selecting decoded data whose image restoration quality exceeds a first predetermined threshold from the multiple decoded data; selecting decoded data whose compression ratio of the corresponding compressed data exceeds a second predetermined threshold from the decoded data whose image restoration quality exceeds the first predetermined threshold; and determining that the compressed data corresponding to the selected decoded data is the preferred compressed data.
[0009] Optionally, compressing each of the multiple image blocks separately to obtain the preferred compressed data includes: selecting a preferred compression method corresponding to the image type of each of the multiple image blocks according to the image type of the image block; and compressing each of the multiple image blocks according to the selected preferred compression method to obtain the preferred compressed data.
[0010] According to another aspect of the present invention, there is provided an image compression device, comprising: a blocking module for blocking an image to obtain a plurality of image blocks; a compression module for respectively compressing each of the plurality of image blocks to obtain preferred compressed data; and a merging module for merging the preferred compressed data obtained by compressing each image block to obtain a compression result of compressing the image.
[0011] Optionally, the compression module includes: a first compression unit, used to compress each of the multiple image blocks using multiple compression methods to obtain corresponding multiple compressed data; a first selection unit, used to select compressed data with the best compression ratio from the multiple compressed data as the preferred compressed data.
[0012] Optionally, the compression module includes: a second compression unit, used to compress each of the multiple image blocks using multiple compression methods to obtain corresponding multiple compressed data; a first decoding unit, used to reversely decode the multiple compressed data using decoding methods corresponding to the multiple compression methods to obtain corresponding multiple decoded data; a second selection unit, used to select decoded data with the best image restoration quality from the multiple decoded data, and use the compressed data corresponding to the selected decoded data as the preferred compressed data.
[0013] Optionally, the compression module includes: a third compression unit, used to compress each of the multiple image blocks using multiple compression methods to obtain corresponding multiple compressed data; a second decoding unit, used to reversely decode the multiple compressed data using decoding methods corresponding to the multiple compression methods to obtain corresponding multiple decoded data; a third selection unit, used to select decoded data whose image restoration quality exceeds a first predetermined threshold from the multiple decoded data; a fourth selection unit, used to select decoded data whose compression ratio of corresponding compressed data exceeds a second predetermined threshold from the decoded data whose image restoration quality exceeds the first predetermined threshold; and a determination unit, used to determine that the compressed data corresponding to the selected decoded data is the preferred compressed data.
[0014] According to another aspect of the present invention, a storage medium is provided, wherein the storage medium includes a stored program, wherein the program executes any one of the above-mentioned image compression methods.
[0015] According to another aspect of the present invention, a processor is provided, wherein the processor is used to run a program, wherein the program executes any one of the above-mentioned image compression methods when running.
[0016] In the embodiment of the present invention, an image is divided into blocks to obtain a plurality of image blocks; each of the plurality of image blocks is compressed respectively to obtain preferred compressed data; the preferred compressed data obtained by compressing each image block are merged to obtain a compression result of compressing the image, and the divided image blocks are compressed to obtain the preferred compressed data, and the compression result is obtained based on the preferred compressed data, thereby achieving the technical effect of using a direct compression method to achieve efficient and accurate compression, thereby solving the technical problem in the related art that not only is image feature recognition complex, but also the image compression quality is not high. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0018] Figure 1 is a flow chart of an image compression method according to an embodiment of the present invention;
[0019] Figure 2 is a flow chart of an image compression method according to an embodiment of the present invention;
[0020] Figure 3 is a schematic diagram of dividing an image into blocks according to an embodiment of the present invention;
[0021] Figure 4is a schematic diagram of compressed data merged and encoded according to an embodiment of the present invention;
[0022] Figure 5 is a structural block diagram of an image compression device according to an embodiment of the present invention;
[0023] Figure 6 is a preferred structural framework of the compression module 54 in the image compression device according to an embodiment of the present invention. Figure 1 ;
[0024] Figure 7 is a preferred structural framework of the compression module 54 in the image compression device according to an embodiment of the present invention. Figure 2 ;
[0025] Figure 8 is a preferred structural framework of the compression module 54 in the image compression device according to an embodiment of the present invention. Figure 3 . DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0028] According to an embodiment of the present invention, a method embodiment of an image compression method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0029] Figure 1is a flow chart of an image compression method according to an embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:
[0030] Step S102, dividing the image into blocks to obtain a plurality of image blocks;
[0031] Step S104, compressing each of the multiple image blocks respectively to obtain optimal compressed data;
[0032] Step S106, merging the preferred compressed data obtained by compressing each image block to obtain a compression result of compressing the image.
[0033] Through the above steps, the preferred compressed data is obtained by compressing the divided image blocks, and the compression result is obtained based on the preferred compressed data, thereby achieving the technical effect of using a direct compression method to achieve efficient and accurate compression, thereby solving the technical problem in the related technology that not only the image feature recognition is complicated but also the image compression quality is not high.
[0034] When compressing each of the multiple image blocks separately to obtain preferred compressed data, multiple methods can be used. For example, if the compression effect mainly considered is the compression ratio, each of the multiple image blocks can be directly compressed using multiple compression methods to obtain corresponding multiple compressed data; and compressed data with the best compression ratio is selected from the multiple compressed data as the preferred compressed data.
[0035] If the compression effect that is mainly considered is the image restoration quality, each of the multiple image blocks is compressed separately to obtain the preferred compressed data, which can be achieved in the following manner: each of the multiple image blocks is compressed using multiple compression methods to obtain corresponding multiple compressed data; the multiple compressed data are reversely decoded using decoding methods corresponding to the multiple compression methods to obtain corresponding multiple decoded data; the decoded data with the best image restoration quality is selected from the multiple decoded data, and the compressed data corresponding to the selected decoded data is used as the preferred compressed data.
[0036] If it is necessary to consider the above-mentioned compression ratio and image restoration quality compatibly, and compress each of the multiple image blocks respectively to obtain preferred compressed data, the following processing method can be adopted: compress each of the multiple image blocks using multiple compression methods to obtain corresponding multiple compressed data; reversely decode the multiple compressed data using decoding methods corresponding to the multiple compression methods to obtain corresponding multiple decoded data; select decoded data whose image restoration quality exceeds a first predetermined threshold from the multiple decoded data; select decoded data whose compression ratio of the corresponding compressed data exceeds a second predetermined threshold from the decoded data whose image restoration quality exceeds the first predetermined threshold; determine that the compressed data corresponding to the selected decoded data is the preferred compressed data.
[0037] In addition, when compressing each of the multiple image blocks separately to obtain preferred compressed data, for images with obvious image types, in order to improve compression efficiency, a preferred compression method corresponding to the image type can be directly and roughly selected based on the image type of each of the multiple image blocks; and each of the multiple image blocks is compressed based on the selected preferred compression method to obtain preferred compressed data.
[0038] Based on the above embodiments and preferred implementation modes, a preferred embodiment is provided. Figure 2 is a flow chart of an image compression method according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:
[0039] Step S202, dividing the image into blocks, Figure 3 is a schematic diagram of dividing an image into blocks according to an embodiment of the present invention;
[0040] Step S204, using multiple compression algorithms (the number and type of encoders are not limited) to compress each image block in parallel, and selecting an encoder with the best compression ratio according to the compression result;
[0041] Step S206, save the location information of each image block, select the encoder, compress the data, Figure 4 is a schematic diagram of compressed data combined and encoded according to an embodiment of the present invention, such as Figure 4 As shown, the combined encoding result is:
[0042] {Image block coordinates: (0,0), encoder: C, compressed data: [……]},
[0043] {Picture block coordinates: (0,1), encoder: B, compressed data: [……]},
[0044] {Image block coordinates: (1,0), encoder: A, compressed data: [……]},
[0045] {Image block coordinates: (1,1), encoder: B, compressed data: [……]},
[0046] Step S208, during decompression, a corresponding decompression algorithm is used on the encoding result of each picture block to restore the decompressed data to the corresponding coordinates.
[0047] According to an embodiment of the present invention, a device embodiment of an image compression device is provided. Figure 5 is a structural block diagram of an image compression device according to an embodiment of the present invention. Figure 5 As shown, the device includes: a block division module 52, a compression module 54 and a merging module 56. The device is described below.
[0048] The blocking module 52 is used to block the image to obtain multiple image blocks; the compression module 54 is connected to the above-mentioned blocking module 52 and is used to compress each image block in the multiple image blocks respectively to obtain preferred compressed data; the merging module 56 is connected to the above-mentioned compression module 54 and is used to merge the preferred compressed data obtained by compressing each image block to obtain a compression result for compressing the image.
[0049] Figure 6 is a preferred structural framework of the compression module 54 in the image compression device according to an embodiment of the present invention. Figure 1 ,like Figure 5 As shown, the compression module 54 includes: a first compression unit 62 and a first selection unit 64. The compression module 54 is described below.
[0050] The first compression unit 62 is used to compress each of the multiple image blocks using multiple compression methods to obtain corresponding multiple compressed data; the first selection unit 64 is connected to the above-mentioned first compression unit 62, and is used to select compressed data with the best compression ratio from the multiple compressed data as preferred compressed data.
[0051] Figure 7 is a preferred structural framework of the compression module 54 in the image compression device according to an embodiment of the present invention. Figure 2 ,like Figure 7 As shown, the compression module 54 includes: a second compression unit 72, a first decoding unit 74 and a second selection unit 76. The compression module 54 is described below.
[0052] The second compression unit 72 is used to compress each of the multiple image blocks using multiple compression methods to obtain corresponding multiple compressed data; the first decoding unit 74 is connected to the above-mentioned second compression unit 72, and is used to reversely decode the multiple compressed data using decoding methods corresponding to the multiple compression methods to obtain corresponding multiple decoded data; the second selection unit 76 is connected to the above-mentioned first decoding unit 74, and is used to select the decoded data with the best image restoration quality from the multiple decoded data, and use the compressed data corresponding to the selected decoded data as the preferred compressed data.
[0053] Figure 8 is a preferred structural framework of the compression module 54 in the image compression device according to an embodiment of the present invention. Figure 3 ,like Figure 8 As shown, the compression module 54 includes: a third compression unit 80, a second decoding unit 82, a third selection unit 84, a fourth selection unit 86 and a determination unit 88. The compression module 54 is described below.
[0054] A third compression unit 80 is used to compress each of the multiple image blocks using multiple compression methods to obtain corresponding multiple compressed data; a second decoding unit 82 is connected to the third compression unit 80 and is used to reversely decode the multiple compressed data using decoding methods corresponding to the multiple compression methods to obtain corresponding multiple decoded data; a third selection unit 84 is connected to the second decoding unit 82 and is used to select decoded data whose image restoration quality exceeds a first predetermined threshold from the multiple decoded data; a fourth selection unit 86 is connected to the third selection unit 84 and is used to select decoded data whose compression ratio exceeds a second predetermined threshold from the decoded data whose image restoration quality exceeds the first predetermined threshold; a determination unit 88 is connected to the fourth selection unit 86 and is used to determine that the compressed data corresponding to the selected decoded data is the preferred compressed data.
[0055] According to another aspect of the present invention, a storage medium is provided, the storage medium comprising a stored program, wherein the program executes any one of the above-mentioned image compression methods.
[0056] According to another aspect of the present invention, a processor is provided, and the processor is used to run a program, wherein any one of the above-mentioned image compression methods is executed when the program is run.
[0057] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0058] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0059] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0060] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed over multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0061] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0062] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0063] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. An image compression method, characterized in that: include: Divide the image into blocks to obtain multiple image blocks; Using multiple compression algorithms to compress each image block in parallel, and obtaining optimal compressed data according to the compression ratio; Merging the preferred compressed data obtained by compressing each image block to obtain a compression result of compressing the image; Among them, compressing each of the multiple image blocks respectively to obtain preferred compressed data includes: compressing each of the multiple image blocks using multiple compression methods to obtain corresponding multiple compressed data; reverse decoding the multiple compressed data using decoding methods corresponding to the multiple compression methods to obtain corresponding multiple decoded data; selecting decoded data whose image restoration quality exceeds a first predetermined threshold from the multiple decoded data; selecting decoded data whose compression ratio of the corresponding compressed data exceeds a second predetermined threshold from the decoded data whose image restoration quality exceeds the first predetermined threshold; and determining that the compressed data corresponding to the selected decoded data is the preferred compressed data.
2. An image compression device, characterized in that: include: A block division module, used for dividing the image into blocks to obtain multiple image blocks; A compression module, used to compress each of the plurality of image blocks in parallel using a plurality of compression algorithms at the same time, and to obtain preferred compressed data according to the compression ratio; A merging module, used for merging the preferred compressed data obtained by compressing each image block to obtain a compression result of compressing the image; Wherein, the compression module includes: a third compression unit, used to compress each of the multiple image blocks by using multiple compression methods to obtain corresponding multiple compressed data; a second decoding unit, used to reversely decode the multiple compressed data by using decoding methods corresponding to the multiple compression methods to obtain corresponding multiple decoded data; a third selection unit, used to select decoded data whose image restoration quality exceeds a first predetermined threshold from the multiple decoded data; a fourth selection unit, used to select decoded data whose compression ratio of the corresponding compressed data exceeds a second predetermined threshold from the decoded data whose image restoration quality exceeds the first predetermined threshold; a determination unit, used to determine that the compressed data corresponding to the selected decoded data is the preferred compressed data.
3. A storage medium, characterized in that: The storage medium includes a stored program, wherein the program executes the image compression method according to claim 1.
4. A processor, characterized in that: The processor is used to run a program, wherein the program executes the image compression method according to claim 1 when running.
Citation Information
Patent Citations
Image compression method and equipment, and system
CN103886623A
Image compression method
CN1937748A
Image processing device, image processing method, image processing program and computer-readable recording medium on which the program is recorded
US20040095601A1