Image compression method and device, electronic equipment and storage medium

By dividing the image into multiple regions and constructing a quantization table according to the importance of the region, quantizing and encoding the JPEG images, the problem of insufficient compression rate of the existing JPEG image compression standard is solved, and more efficient image compression is achieved.

CN120186355APending Publication Date: 2025-06-20HANGZHOU HIKVISION DIGITAL TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311745512.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-18
Publication Date
2025-06-20

AI Technical Summary

Technical Problem

The existing JPEG image compression standard has a small compression rate for the original image, resulting in a large amount of JPEG image data generated, increasing the resource requirements for storage, processing and transmission. At the same time, increasing the compression rate will lead to blurred images and loss of effective information.

Method used

By dividing the original image into multiple regions, identifying and determining the quantization level of each region, building a target quantization table based on the quantization level, quantizing and encoding the images, reducing high-frequency information of unimportant regions.

Benefits of technology

While retaining information on important areas in the image, high-frequency information on unimportant areas is reduced, the amount of data in compressed images is reduced, and the image compression rate is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120186355A_ABST
    Figure CN120186355A_ABST
Patent Text Reader

Abstract

The invention provides an image compression method and device, electronic equipment and a storage medium, relates to the field of image processing, and is used for improving the image compression rate. The method comprises the following steps: dividing an original image into a plurality of areas; objects contained in all the areas in the original image are recognized, the quantization levels of all the areas are determined, and the quantization levels represent the importance degrees of the objects contained in the areas; according to the quantization level of each region, determining a target quantization table of the original image, the target quantization table including a plurality of quantization coefficients, and each region corresponding to at least one quantization coefficient; based on the target quantization table of the original image, quantizing a first matrix of the original image to obtain a second matrix of the original image, the first matrix being image data of the original image after discrete cosine transform; and encoding the second matrix of the original image to obtain a compressed image of the original image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing, and in particular, to an image compression method, apparatus, electronic device, and storage medium. Background Art

[0002] The original image files captured by a camera are usually compressed before being saved. As a widely used image compression standard, JPEG (Joint Photographic Experts Group), most of the original image files captured by imaging devices are compressed and saved in the JPEG format.

[0003] The larger the original image file is, the larger the JPEG image obtained by encoding and compressing the original image file will be. Moreover, the general compression method of the JPEG format has a relatively small compression ratio for the original image file. After a relatively large image captured by an imaging device is saved in the JPEG format, the JPEG image will also be large, which poses relatively high resource requirements for subsequent storage, processing, and transmission. However, if the compression ratio of the original image file is directly increased, then there will be more blurring in the obtained JPEG image, resulting in a large amount of loss of valid information. Summary of the Invention

[0004] The present application provides an image compression method, apparatus, electronic device, and storage medium, which are beneficial to improving the compression ratio of an image.

[0005] In a first aspect, the present application provides an image compression method, which includes: dividing an original image into multiple regions; identifying objects included in each region of the original image, and determining a quantization level for each region, where the quantization level represents the importance degree of the objects included in the region; according to the quantization levels of each region, determining a target quantization table of the original image, where the target quantization table includes multiple quantization coefficients, and each region corresponds to at least one quantization coefficient; wherein, the smaller the quantization coefficient of a region in the original image is, the higher the importance degree of the objects included in the region corresponding to the quantization level is; based on the target quantization table of the original image, quantizing a first matrix of the original image to obtain a second matrix of the original image, where the first matrix is the image data of the original image after discrete cosine transform, and the larger the quantization coefficient corresponding to a region is, the less high-frequency information of the image data in the first matrix corresponding to the region is retained after quantization; encoding the second matrix of the original image to obtain a compressed image of the original image.

[0006] As can be seen from the above embodiments, in image compression, information contained in objects with a lower degree of importance (such as detailed information) can be appropriately reduced, so as to achieve the purpose of reducing the size of image data. The image compression method provided by this application first divides the original image into multiple regions, then identifies the objects contained in each region, and determines the quantization level representing the degree of importance of the objects contained in each region. Further, a target quantization table is determined according to the quantization levels of each region. According to the target quantization table, the first matrix of the image is quantized. For the quantized second matrix, where the quantization coefficients are larger, that is, in the regions of the second matrix where the importance of the objects contained in the image is lower, the high-frequency information is reduced. Further, after encoding the second matrix, the amount of data contained in the obtained compressed image will also be reduced. It can be seen that this image compression method can retain the information of the image regions containing important objects in the original image while reducing the high-frequency information of the image regions containing unimportant objects in the original image, thus achieving the reduction of the amount of data of the finally obtained compressed image while retaining important valid information.

[0007] In a possible implementation, the multiple regions in the original image include multiple first sub-regions; identifying the objects contained in each region of the original image and determining the quantization level of the region includes: dividing the target first sub-region into multiple second sub-regions; the target first sub-region is the first sub-region in the preselected quantization level representation region where the degree of importance is greater than the preset degree of importance, and the multiple regions in the multiple original images also include multiple second sub-regions; identifying the objects contained in the second sub-regions and determining the preselected quantization levels of each second sub-region; determining the quantization levels of the non-target first sub-regions and the second sub-regions in the target first sub-region in the region according to the preselected quantization levels of the non-target first sub-regions and the preselected quantization levels of the second sub-regions in the target first sub-region.

[0008] In a possible implementation, determining the quantization levels of the non-target first sub-regions and the second sub-regions in the target first sub-region in the region according to the preselected quantization levels of the non-target first sub-regions and the preselected quantization levels of the second sub-regions in the target first sub-region includes: when the first preselected quantization level of the first sub-region and the second preselected quantization levels of the multiple second sub-regions divided by the first sub-region satisfy the preset contrary condition, determining the quantization level with a higher degree of importance of the objects contained in the region among the first preselected quantization level and the second preselected quantization levels as the quantization level of the multiple second sub-regions in the target first sub-region.

[0009] In one possible implementation, the original image includes multiple first sub-regions, and a target first sub-region is divided into m second sub-regions; the quantization level of each second sub-region in the target quantization table corresponds to at least one quantization coefficient in the quantization table, and the quantization level of each non-target first sub-region corresponds to at least m quantization coefficients in the quantization table.

[0010] In a possible implementation, a first matrix of the original image is quantized according to a target quantization table of the original image to obtain a second matrix of the original image, including: quantizing the first matrix of the original image according to a general quantization table of JPEG image compression; and quantizing the quantized first matrix again according to the target quantization table to obtain a second matrix.

[0011] In a possible implementation, a first matrix of the original image is quantized according to a target quantization table of the original image to obtain a second matrix of the original image, including: obtaining a fused quantization table based on the target quantization table and a general quantization table for JPEG image compression; and quantizing the first matrix according to the fused quantization table to obtain a second matrix.

[0012] In one possible implementation, when each area in the original image is a rectangular area, the side length of any area of ​​the original image is greater than or equal to the side length of the minimum coding unit; and / or the side length of each area of ​​the original image is greater than or equal to the predicted minimum side length of the preset object in the original image.

[0013] In one possible implementation, identifying objects contained in a first sub-region and determining a preselected quantization level for each first sub-region includes: inputting an image of the first sub-region into a first image recognition evaluation model to obtain a preselected quantization level for the first sub-region output by the first image recognition evaluation model; the first image recognition evaluation model is used to determine a preselected quantization level corresponding to the object contained in the image region; identifying objects contained in a second sub-region and determining a preselected quantization level for each second sub-region includes: inputting an image of the second sub-region into a second image recognition evaluation model to obtain a preselected quantization level for the second sub-region output by the second image recognition evaluation model; the second image recognition evaluation model is used to determine a preselected quantization level corresponding to the object contained in the image region; wherein the image input to the first image recognition evaluation model and the image input to the second image recognition evaluation model have different sizes.

[0014] In a possible implementation, the image compression method further includes: inputting a plurality of first sample images having the same size as the first sub-region and corresponding first labels into a first image recognition and evaluation model to train the first image recognition and evaluation model; the first label includes a first quantization level and a second quantization level, and the importance level of the object included in the first sample image represented by the first quantization level is lower than the importance level of the object included in the first sample image represented by the second quantization level.

[0015] In a possible implementation, the image compression method further includes: inputting a plurality of second sample images having the same size as the first sub-region and corresponding second labels into a second image recognition and evaluation model to train the second image recognition and evaluation model; the second label includes a first quantization level, a second quantization level, and a third quantization level, and the importance level of the object included in the second sample image represented by the first quantization level is lower than the importance level of the object included in the second sample image represented by the second quantization level, and the importance level of the object included in the second sample image represented by the second quantization level is lower than the importance level of the object included in the second sample image represented by the second quantization level.

[0016] In a possible implementation, the second label is related to the importance levels of all the objects included in the second sample image and the area occupancy size of the object with the highest importance level included in the second sample image in the image.

[0017] In a second aspect, the present application provides an image compression apparatus, which includes: an image partitioning unit for partitioning an original image into a plurality of regions; an evaluation unit for identifying the objects included in each region of the original image and determining the quantization level of each region, where the quantization level represents the importance level of the object included in the region; a quantization table determination unit for determining a target quantization table of the original image according to the quantization levels of each region, the target quantization table includes a plurality of quantization coefficients, and each region corresponds to at least one quantization coefficient; wherein, the smaller the quantization coefficient of the region in the original image, the higher the importance level of the object included in the region represented by the corresponding quantization level; a quantization unit for quantizing the first matrix of the original image based on the target quantization table of the original image to obtain a second matrix of the original image, the first matrix is the image data of the original image after discrete cosine transform, and the larger the quantization coefficient corresponding to the region, the less high-frequency information of the image data corresponding to the region in the first matrix is retained after quantization; an encoding unit for encoding the second matrix of the original image to obtain a compressed image of the original image.

[0018] In a possible implementation, multiple regions in the original image include multiple first sub-regions; the evaluation unit includes a first evaluation sub-unit, a second evaluation sub-unit, and a quantization level determination sub-unit. The first evaluation sub-unit is configured to: identify the objects included in the first sub-regions, and determine the preselected quantization levels of the respective first sub-regions; the image partitioning unit is further configured to partition a target first sub-region into multiple second sub-regions; the target first sub-region is a first sub-region in which the importance of the object included in the preselected quantization level representation region is greater than a preset importance level. Multiple regions in the multiple original images further include multiple second sub-regions; the second evaluation sub-unit is configured to identify the objects included in the second sub-regions, and determine the preselected quantization levels of the respective second sub-regions; the quantization level determination sub-unit is configured to determine the quantization levels of the non-target first sub-regions and the second sub-regions in the target first sub-region in the region according to the preselected quantization levels of the non-target first sub-regions and the preselected quantization levels of the second sub-regions in the target first sub-region.

[0019] In a possible implementation, the quantization level determination sub-unit is specifically configured to: when the first preselected quantization level of the first sub-region and the second preselected quantization levels of the multiple second sub-regions obtained by partitioning the first sub-region satisfy a preset conflicting condition, determine the quantization level with a higher importance level of the object included in the region in the first preselected quantization level and the second preselected quantization levels as the quantization level of the multiple second sub-regions in the target first sub-region.

[0020] In a possible implementation, the original image includes multiple first sub-regions, and one target first sub-region is partitioned into m second sub-regions; the quantization level of each second sub-region in the target quantization table corresponds to at least one quantization coefficient in the quantization table, and the quantization level of each non-target first sub-region corresponds to at least m quantization coefficients in the quantization table.

[0021] In a possible implementation, the quantization unit is specifically configured to: quantize the first matrix of the original image according to the general quantization table for JPEG image compression; and quantize the quantized first matrix again according to the target quantization table to obtain a second matrix.

[0022] In a possible implementation, the quantization unit is specifically configured to: obtain a fused quantization table based on the target quantization table and the general quantization table for JPEG image compression; and quantize the first matrix according to the fused quantization table to obtain a second matrix.

[0023] In a possible implementation, when each region in the original image is a rectangular region, the side length of any region in the original image is greater than or equal to the side length of the minimum coding unit; and / or, the side lengths of each region in the original image are greater than or equal to the predicted minimum side length of the preset object in the original image.

[0024] In a possible implementation manner, the first evaluation subunit is specifically configured to: input the image of the first sub-region into the first image recognition evaluation model to obtain the preselected quantization level of the first sub-region output by the first image recognition evaluation model; the first image recognition evaluation model is used to determine the preselected quantization level corresponding to the object included in the image region; the second evaluation subunit is specifically configured to: input the image of the second sub-region into the second image recognition evaluation model to obtain the preselected quantization level of the second sub-region output by the second image recognition evaluation model; the second image recognition evaluation model is used to determine the preselected quantization level corresponding to the object included in the image region; wherein, the sizes of the images input to the first image recognition evaluation model and the second image recognition evaluation model are different.

[0025] In a possible implementation manner, the image compression device further includes a training unit, configured to: input a plurality of first sample images having the same size as the first sub-region and corresponding first labels into the first image recognition evaluation model to train the first image recognition evaluation model; the first labels include a first quantization level and a second quantization level, and the importance level of the object included in the first sample image represented by the first quantization level is lower than the importance level of the object included in the first sample image represented by the second quantization level.

[0026] In a possible implementation manner, the training unit is further configured to input a plurality of second sample images having the same size as the first sub-region and corresponding second labels into the second image recognition evaluation model to train the second image recognition evaluation model; the second labels include a first quantization level, a second quantization level, and a third quantization level, and the importance level of the object included in the second sample image represented by the first quantization level is lower than the importance level of the object included in the second sample image represented by the second quantization level, and the importance level of the object included in the second sample image represented by the second quantization level is lower than the importance level of the object included in the second sample image represented by the second quantization level.

[0027] In a possible implementation manner, the second label is related to the importance levels of all the objects included in the second sample image and the area occupancy size of the object with the highest importance level included in the second sample image in the image.

[0028] In a third aspect, an embodiment of the present application provides an electronic device, including: a memory and a processor; the memory and the processor are coupled; the memory is used to store computer program code, and the computer program code includes computer instructions; wherein, when the processor executes the computer instructions, the electronic device is caused to execute the image compression method as described in the first aspect and any one of its possible design manners.

[0029] Fourthly, the present application provides a computer-readable storage medium, which includes: computer software instructions; when the computer software instructions run in an image compression device, the image compression device is enabled to implement the method of the first aspect above.

[0030] Fifthly, the present application provides a computer program product, which when running on an image compression device, enables the image compression device to execute the steps of the related method described in the first aspect above, so as to implement the method of the first aspect.

[0031] For the beneficial effects of the second to fifth aspects above, reference may be made to the corresponding descriptions of the first aspect, and details will not be repeated here. Description of the Drawings

[0032] Figure 1 Schematic diagram of an image taken in the scenario of the public transportation management field for an image compression method provided by the present application;

[0033] Figure 2 Schematic diagram of the structure of an image compression device in an image compression method provided by the present application;

[0034] Figure 3 Flow chart of an image compression method provided by the present application Figure 1 ;

[0035] Figure 4 Schematic diagram of data corresponding to the minimum coding unit in an image compression method provided by the present application;

[0036] Figure 5 Flow chart of an image compression method provided by the present application Figure 2 ;

[0037] Figure 6 Schematic diagram of quantization coefficients corresponding to different regions in an image compression method provided by the present application;

[0038] Figure 7 Schematic diagram of the structure of an image compression device provided by the present application. Detailed Embodiments

[0039] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments of the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

[0040] It should be noted that in the embodiments of the present application, words such as "exemplarily" or "for example" are used to give examples, illustrations or explanations. Any embodiment or design solution described as "exemplarily" or "for example" in the embodiments of the present application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, the use of words such as "exemplarily" or "for example" is intended to present relevant concepts in a specific manner.

[0041] For the convenience of clearly describing the technical solutions of the embodiments of the present application, in the embodiments of the present application, terms such as "first" and "second" are used to distinguish identical or similar items with basically the same functions and roles. Those skilled in the art can understand that terms such as "first" and "second" do not limit the quantity and execution order.

[0042] With the development of technology, the resolution of cameras has been continuously improved, and the field of view that can be captured has also been expanded. However, when the field of view of the camera is expanded, a large amount of useless information will exist in the field of view. Further, the high-resolution invalid information will result in a large data volume of the captured image file.

[0043] For example, in the field of public transportation management, the camera devices installed on the road are usually used to capture information of passing vehicles and pedestrians. However, due to the expanded field of view, each captured image often also contains a large amount of areas such as green belts that generally do not need to be captured and managed most of the time. The images in these areas are all useless information. As Figure 1 shown, when the camera device captures on the road, in the obtained original image, there may also be a lot of image information of other objects (such as plants) on both sides of the road area. In areas such as green belts, the texture of the grass and trees is often relatively complex, and capturing at high resolution will increase the data volume of the image file.

[0044] JPEG (Joint Photographic Experts Group), as a widely used image compression standard, most of the original image files captured by camera devices are compressed and saved in JPEG format. JPEG mainly uses a combined coding method of predictive coding (DPCM), discrete cosine transform (DCT) and entropy coding to remove redundant image and color data. The original image files captured by the camera are usually compressed and then saved. As a widely used image compression standard, most of the original image files captured by camera devices are compressed and saved in JPEG format. However, since the compression ratio of JPEG for images is not large, for the above-mentioned original images with a large field of view and high resolution, the generated JPEG images will also have a large data volume, which brings great pressure to the storage, transmission and processing of the images.

[0045] In view of this problem, an embodiment of the present application provides an image compression method, apparatus, electronic device, and storage medium.

[0046] In some possible embodiments, an image compression method provided by an embodiment of the present application can be applied to an image compression device.

[0047] The image compression device can divide the original image into multiple regions; identify the objects included in each region of the original image, determine the quantization level of each region, where the quantization level represents the importance of the objects included in the region; according to the quantization levels of each region, determine the target quantization table of the original image, the target quantization table includes multiple quantization coefficients, and each region corresponds to at least one quantization coefficient; among them, the smaller the quantization coefficient of the region in the original image, the higher the importance of the objects included in the region represented by the corresponding quantization level; based on the target quantization table of the original image, quantize the first matrix of the original image to obtain the second matrix of the original image, the first matrix is the image data of the original image after discrete cosine transform, and the larger the quantization coefficient corresponding to the region, the less high-frequency information of the image data corresponding to the region in the first matrix is retained after quantization; encode the second matrix of the original image to obtain the compressed image of the original image.

[0048] In a possible implementation manner, the image compression device can also identify the objects included in the first sub-region, and determine the preselected quantization level of each first sub-region; divide the target first sub-region with a preselected quantization level greater than the preset level into multiple second sub-regions; the multiple regions in the multiple original images also include multiple second sub-regions; identify the objects included in the second sub-region, and determine the preselected quantization level of each second sub-region; according to the preselected quantization level of the non-target first sub-region and the preselected quantization level of the second sub-region in the target first sub-region, determine the quantization levels of the non-target first sub-region and the second sub-region in the target first sub-region in the region.

[0049] In a possible implementation manner, when the first preselected quantization level of the first sub-region and the second preselected quantization levels of the multiple second sub-regions divided from the first sub-region satisfy the preset conflicting condition, the quantization level representing the higher importance of the objects included in the region among the first preselected quantization level and the second preselected quantization levels is determined as the quantization level of the multiple second sub-regions in the target first sub-region.

[0050] In a possible implementation manner, the original image includes multiple first sub-regions, and one target first sub-region is divided into m second sub-regions; the quantization level of each second sub-region in the target quantization table corresponds to at least one quantization coefficient in the quantization table, and the quantization level of each non-target first sub-region corresponds to at least m quantization coefficients in the quantization table.

[0051] In a possible implementation, the image compression device may also quantize the first matrix of the original image according to the general quantization table for JPEG image compression; and re-quantize the quantized first matrix according to the target quantization table to obtain a second matrix.

[0052] In a possible implementation, the image compression device may also obtain a fused quantization table based on the target quantization table and the general quantization table for JPEG image compression; and quantize the first matrix according to the fused quantization table to obtain a second matrix.

[0053] In a possible implementation, the image compression device may also input the image of the first sub-region into a first image recognition and evaluation model to obtain a preselected quantization level of the first sub-region output by the first image recognition and evaluation model; the first image recognition and evaluation model is used to determine the preselected quantization level corresponding to the object included in the image region; input the image of the second sub-region into a second image recognition and evaluation model to obtain a preselected quantization level of the second sub-region output by the second image recognition and evaluation model; the second image recognition and evaluation model is used to determine the preselected quantization level corresponding to the object included in the image region; wherein, the images input to the first image recognition and evaluation model and the second image recognition and evaluation model have different sizes.

[0054] In a possible implementation, the image compression device may also input multiple first sample images with the same size as the first sub-region and their corresponding first labels into the first image recognition and evaluation model to train the first image recognition and evaluation model; the first label includes a first quantization level and a second quantization level, and the importance level of the object included in the first sample image represented by the first quantization level is lower than that of the object included in the first sample image represented by the second quantization level.

[0055] In a possible implementation, the image compression device may also input multiple second sample images with the same size as the first sub-region and their corresponding second labels into the second image recognition and evaluation model to train the second image recognition and evaluation model; the second label includes a first quantization level, a second quantization level, and a third quantization level, and the importance level of the object included in the second sample image represented by the first quantization level is lower than that of the object included in the second sample image represented by the second quantization level, and the importance level of the object included in the second sample image represented by the second quantization level is lower than that of the object included in the second sample image represented by the second quantization level.

[0056] In a possible implementation, the second label is related to the importance levels of all objects included in the second sample image and the area occupancy size of the object with the highest importance level included in the second sample image in the image.

[0057] The image compression device in the embodiments of the present application may be an electronic device such as a central platform server, a desktop computer, a tablet computer, a laptop computer, a handheld computer, a wearable electronic device, a handheld computer, an Ultra-mobile Personal Computer (UMPC), a netbook, etc., and the embodiments of the present application do not make any restrictions thereon.

[0058] The image compression device in the embodiments of the present application may include a computing device as Figure 2 shown, and the computing device includes a processor 101, a memory 102, a communication interface 103, and a bus 104. The processor 101, the memory 102, and the communication interface 103 may be connected through the bus 104.

[0059] The processor 101 is the control center of the computing device, and may be a single processor or a collective term for multiple processing elements. For example, the processor 101 may be a general-purpose central processing unit (CPU), or other general-purpose processors. Among them, the general-purpose processor may be a microprocessor or any conventional processor, etc.

[0060] As some embodiments, the processor 101 may include one or more CPUs, such as Figure 2 the CPU 0 and CPU 1 shown in

[0061] The memory 102 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a disk storage medium, or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto.

[0062] In some possible implementation manners, the memory 102 may exist independently of the processor 101. The memory 102 may be connected to the processor 101 through the bus 104 for storing instructions or program code. When the processor 101 calls and executes the instructions or program code stored in the memory 102, the model deployment method provided by the embodiments of the present application can be implemented.

[0063] In the embodiments of the present application, for an image processing device, different software programs stored in the memory 102 implement different functions. The functions performed by each device will be described in conjunction with the following flowcharts.

[0064] In another possible implementation, the memory 102 can also be integrated with the processor 101.

[0065] The communication interface 103 is used for the computing device to be connected to other devices through a communication network, and the communication network can be an Ethernet, a radio access network (RAN), a wireless local area network (WLAN), etc. The communication interface 103 can include a receiving unit for receiving data and a sending unit for sending data.

[0066] The bus 104 can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, etc. This bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of simplicity of representation, Figure 2 only a thick line is used to represent it in the figure, but it does not mean that there is only one bus or one type of bus.

[0067] It should be noted that Figure 2 the structure shown in the figure does not constitute a limitation on the computing device. Except Figure 2 for the components shown, the computing device can include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.

[0068] As Figure 3 shown in the figure is a schematic flowchart of an image compression method provided by the embodiments of the present application, including the following S301 to S305.

[0069] S301, divide the original image into multiple regions.

[0070] It should be understood that the above original image file contains data processed by the image sensors of digital cameras, scanners, or film scanners. Of course, it can also be various images that have been preliminarily processed. The present application does not make specific limitations on this.

[0071] S302, identify the objects included in each region of the original image and determine the quantization level of each region.

[0072] Among them, the quantization level characterizes the importance of the objects included in the region.

[0073] For example, in the case where the original image is an image obtained by a photographing device in the field of public road traffic management, the original image may contain various objects such as roads, vehicles, pedestrians, green plants, and the sky. Since the original image is used for public road traffic management, the objects such as roads, vehicles, and pedestrians in the original image are relatively important image information, while green plants and the sky are less important image information. Then, the objects included in different regions are different. According to the importance of the objects in the region, different quantization levels can be obtained.

[0074] Of course, a region may also contain multiple objects. For example, a region contains both a green plant object and a vehicle object. Then, the quantization level of the region can be determined according to the size of the regions occupied by the multiple objects in the region. Or other methods can be used to determine the quantization level of the region.

[0075] S303. Determine the target quantization table of the original image according to the quantization levels of each region.

[0076] Among them, the target quantization table contains multiple quantization coefficients, and each region corresponds to at least one quantization coefficient. The smaller the quantization coefficient of the region in the original image, the higher the importance of the objects included in the corresponding quantization level characterization region.

[0077] It should be understood that in different image compression methods, quantization is performed on the image. For example, when compressing an object image in the JPEG format, quantization is a process of further compressing the matrix after the image undergoes DCT (Discrete Cosine Transform). Generally, the smaller the quantization coefficient, the less the compression loss of the region (pixel) is represented. Therefore, when the importance of the objects included in the corresponding quantization level characterization region is higher, the quantization coefficient of the region in the original image will be smaller.

[0078] Of course, the quantization level can be the same as the quantization coefficient. For example, in the case where the importance of the objects included in the region characterized by the quantization level of 1 is greater than the importance of the objects included in the region characterized by the quantization level of 2, the quantization level is similar to the quantization coefficient and also satisfies that the smaller the value, the higher the importance of the objects included in the corresponding characterization region. Further, if the numerical value of the quantization level is still suitable for subsequent processing, the quantization level can also be used as the quantization coefficient.

[0079] S304. Quantize the first matrix of the original image based on the target quantization table of the original image to obtain the second matrix of the original image.

[0080] Among them, the first matrix is the image data after the discrete cosine transform of the original image. The larger the quantization coefficient corresponding to the region, the less high-frequency information of the image data corresponding to the region in the first matrix is retained after quantization.

[0081] It should be understood that in an image, the low-frequency components correspond to the regions where the brightness of the objects in the image is uniform or changes slowly, and the high-frequency components correspond to the edges, details, and noises of the objects in the image. For example, the fine patterns existing in green plants, or the positions where the colors suddenly change at the boundaries of two objects, all belong to high-frequency information. The human eye is less sensitive to the high-frequency information in the image and much more sensitive to the low-frequency information. Therefore, when reducing the data volume of the image by reducing the amount of information, it is possible to give priority to reducing the high-frequency information in the image. Further, if the image contains multiple objects, some of which are unimportant and some are important, it is also possible to reduce the amount of information to reduce the data volume of the image by retaining more high-frequency information of the more important objects and less or no high-frequency information of the unimportant objects in the image.

[0082] For example, during quantization, the matrix in this region can be compressed according to the quantization coefficient. The values of the pixels in each minimum quantization unit in the region in each color channel and / or light and dark channel can be divided by the quantization coefficient corresponding to the region. Since the smaller the quantization coefficient of the region, the higher the importance level of the object contained in the corresponding quantization level represents. Therefore, the quantization coefficient corresponding to the object with a high importance level is smaller, and less data is lost in the above division operation. Even when the quantization coefficient is 1, no data is lost. However, the quantization coefficient corresponding to the object with a low importance level is larger, and more data is lost in the above division operation.

[0083] Another example is that during quantization, some high-frequency information of the image in this region can be discarded, and only the low-frequency information is retained. As Figure 4 shown, the figure shows the part corresponding to a minimum coding unit in the first matrix, and each circle represents a piece of data. Since in the image data (the first matrix) after the DCT transform, the high-frequency information in each minimum coding unit will concentrate towards the lower right corner of the matrix, and the low-frequency information will concentrate towards the upper left corner of the matrix. Therefore, during quantization, some of the high-frequency information can also be set to 0 or a smaller value. For example, when the quantization coefficient of the region is 1, the high-frequency information in the last column and the last row of the information corresponding to each minimum coding unit in the region in the first matrix can be set to 0, that is Figure 4The data shown by L1 in the figure. If the quantization coefficient of another region is 4, that is, the importance of the objects contained in this region is lower than that of the objects contained in the region with a quantization coefficient of 1. Then, for the region with a quantization coefficient of 4, more high-frequency information can be discarded. For example, the information from L1, L2, L3 to L4 in the figure can be set to 0, that is, the information in the last four rows and the last four columns is set to 0, and the information in L5, L6, L7, and L8 in the figure is retained. After the high-frequency data is set to 0, the final generated data volume will decrease. First, since the originally longer data is set to 0, the data volume decreases. Additionally, after the data of the image is quantized, it usually needs to be encoded. In zigzag scan, special marks can be made for adjacent data that are all 0, thereby further reducing the data volume.

[0084] In a possible implementation, according to the target quantization table of the original image, the first matrix of the original image is quantized to obtain the second matrix of the original image, including: quantizing the first matrix of the original image according to the general quantization table for JPEG image compression. According to the target quantization table, the quantized first matrix is quantized again to obtain the second matrix.

[0085] In a possible implementation, according to the target quantization table of the original image, the first matrix of the original image is quantized to obtain the second matrix of the original image, including: based on the target quantization table and the general quantization table for JPEG image compression, a fused quantization table is obtained. According to the fused quantization table, the first matrix is quantized to obtain the second matrix.

[0086] It should be understood that when compressing JPEG images, there are commonly used and general quantization tables summarized based on image processing experience. In the embodiments of this method, the first matrix after DCT of the original image can be quantized first according to the general quantization table for JPEG image compression, and further, the quantized first matrix can be quantized with the target quantization table. Or, the target quantization table and the general quantization table for JPEG image compression are fused first, and then the first matrix is quantized according to the fused quantization table.

[0087] Since each quantization coefficient in the target quantization table corresponds to one image region in the original image, while the general quantization table for JPEG image compression corresponds to any smallest coding unit in the entire image. Therefore, after the target quantization table and the general quantization table for JPEG image compression are fused, one coefficient in the obtained fused quantization table may correspond to one pixel in the original image.

[0088] S305, encode the second matrix of the original image to obtain the compressed image of the original image.

[0089] It can be seen from the above embodiments that, in image compression, the information (such as detail information) contained in objects with lower importance can be appropriately reduced, thereby achieving the purpose of reducing the size of image data. The image compression method provided by the present application first divides the original image into multiple regions, then identifies the objects contained in each region, and determines the quantization level that characterizes the importance of the objects contained in each region. Further, the target quantization table is determined according to the quantization level of each region. According to the target quantization table, the first matrix of the image is quantized. The second matrix after quantization, in which the quantization coefficient is larger, that is, the region with lower importance of the object contained in the image in the second matrix, the high-frequency information is reduced. Further, after encoding the second matrix, the amount of data contained in the obtained compressed image will also be reduced. It can be seen that the image compression method can retain the information of the image region containing important objects in the original image while reducing the high-frequency information of the image region of unimportant objects contained in the original image, thereby achieving the reduction of the data amount of the compressed image finally obtained while retaining important effective information.

[0090] In a possible implementation, the plurality of regions in the original image include a plurality of first sub-regions. Objects contained in each region in the original image are identified, and the quantization level of the region is determined, such as Figure 5 As shown, it includes the following S3021 to S3024.

[0091] S3021, identifying objects contained in the first sub-regions, and determining a pre-selected quantization level for each first sub-region.

[0092] For example, Figure 5 As shown in FIG. 1 , the original image may contain multiple first sub-regions, and each first sub-region has the same size. If the width of the original image is w and the height is h, and each row of the original image can be divided into m first sub-regions, and each column of the original image can be divided into n first sub-regions. Then the data of the pre-selected quantization levels corresponding to each first sub-region, if represented by a matrix, can be Figure 5 As shown in , each row has w / m pre-selected quantization levels corresponding to the first sub-regions, and each column has h / n pre-selected quantization levels corresponding to the first sub-regions.

[0093] S3022: Divide the target first sub-region into multiple second sub-regions.

[0094] The target first sub-region is a first sub-region in which the importance of the object contained in the pre-selected quantization level representation region is greater than a preset importance, and the multiple regions in the multiple original images also include multiple second sub-regions.

[0095] It should be understood that since the second sub-region is obtained by dividing the first sub-region, the image size corresponding to the first sub-region is larger than the image size corresponding to the second sub-region. Moreover, since the sizes of the first sub-region and the second sub-region are different, the rules for determining the preselected quantization levels can also be different. For example, since the image corresponding to the second sub-region is smaller, it is more likely that the divided images contain a single object. Therefore, different preselected quantization levels can be set according to each object. While the image corresponding to the first sub-region is larger and usually contains more objects, so the preselected quantization levels can be simply divided according to whether it contains important objects (such as vehicles in a road scene).

[0096] The target first sub-region is the first sub-region in which the importance of the contained objects is greater than the preset importance level, that is, it indicates that the objects contained in the target first sub-region have a relatively high importance level. Therefore, it can be further divided into multiple second sub-regions. Thus, the region in the first sub-region that contains objects with a relatively high importance level and the region that does not contain objects with a relatively high importance level are distinguished. Only the high-frequency information in the second sub-regions that contain objects with a relatively high importance level is retained, while the high-frequency information in the second sub-regions with a relatively low importance level is discarded. Thus, the data volume of the encoded image is reduced.

[0097] In a possible implementation, to identify the objects contained in the first sub-region and determine the preselected quantization levels of each first sub-region, it includes: inputting the image of the first sub-region into the first image recognition and evaluation model to obtain the preselected quantization level of the first sub-region output by the first image recognition and evaluation model. The first image recognition and evaluation model is used to determine the preselected quantization level corresponding to the objects contained in the image region. To identify the objects contained in the second sub-region and determine the preselected quantization levels of each second sub-region, it includes: inputting the image of the second sub-region into the second image recognition and evaluation model to obtain the preselected quantization level of the second sub-region output by the second image recognition and evaluation model. The second image recognition and evaluation model is used to determine the preselected quantization level corresponding to the objects contained in the image region. Among them, the images input into the first image recognition and evaluation model and the second image recognition and evaluation model have different sizes.

[0098] It should be understood that the determination of the preselected quantization levels for the first sub-region and the second sub-region can be completed by using an image recognition and evaluation model to identify the corresponding objects in the image region and output the preselected quantization levels corresponding to the objects contained in the image region. When the first image recognition and evaluation model and the second image recognition and evaluation model are being trained and recognized, the corresponding image sizes are different, and the grading degrees of the preselected quantization levels they output may also be different.

[0099] Continuing with the above embodiment, as Figure 5As shown, if each first sub-region is divided into 4 second sub-regions, then the data of the preselected quantization levels corresponding to the respective second sub-regions, when represented as a matrix, can be Figure 5 as shown in a two-row and two-column matrix.

[0100] S3023, identify the objects included in the second sub-region and determine the preselected quantization levels of the respective second sub-regions.

[0101] S3024, determine the quantization levels of the non-target first sub-regions and the second sub-regions in the target first sub-region in the region according to the preselected quantization levels of the non-target first sub-regions and the preselected quantization levels of the second sub-regions in the target first sub-region.

[0102] It should be understood that the division of the first sub-region into the second sub-region in the above embodiments is only an example. According to different requirements, similar to the division of the first sub-region into the second sub-region, the original image can be divided into regions of various different scales.

[0103] For example, if the quantization levels of the non-target first sub-regions and the second sub-regions in the target first sub-region in the region are stored in the form of a matrix (hereinafter referred to as the target matrix), the matrix can be first updated by the matrix of the preselected quantization levels corresponding to the first sub-region (hereinafter referred to as the first preselected quantization matrix). Specifically, it can be updated by the following formula 1. Where Q y,x represents the quantization level of the x-th row and y-th column in the target matrix, represents the column, row quantization level in the first preselected quantization matrix.

[0104]

[0105] Furthermore, the target matrix can be further updated according to the matrix of the preselected quantization levels corresponding to the second sub-region (hereinafter referred to as the second preselected quantization matrix). Since only when the preselected quantization level of the first sub-region is greater than the preset level, the first sub-region (target first sub-region) will be divided to obtain the corresponding second sub-regions, therefore, the second preselected quantization matrix will only update a part of the target matrix, specifically as follows formula 2. Where represents the quantization level of the x-th row and y-th column in the target matrix. When the preselected quantization level of the first sub-region is greater than the preset level, the first sub-region (target first region) is divided into multiple second sub-regions, represents the column, row corresponding to the first sub-region in the first preselected quantization matrix, and the quantization level of the k-th second sub-region corresponding to it.

[0106]

[0107] In a possible implementation, as shown in Equation 3, if the target first sub-region corresponding to the column, row of the first preselected quantization matrix is correspondingly divided into 4 second sub-regions. Then, when is odd and is odd, then this second sub-region is the first (located at the upper left corner) second sub-region of this target first sub-region. Similarly, when is odd and is even, then this second sub-region is the second (located at the upper right corner) second sub-region of this target first sub-region. The rest is the same.

[0108]

[0109] In a possible implementation, according to the preselected quantization level of the non-target first sub-region and the preselected quantization level of the second sub-region in the target first sub-region, the quantization levels of the non-target first sub-region and the second sub-region in the target first sub-region in the region are determined, including: when the first preselected quantization level of the first sub-region and the second preselected quantization levels of the multiple second sub-regions divided from the first sub-region satisfy a preset conflicting condition, the quantization level representing a higher importance degree of the object contained in the region among the first preselected quantization level and the second preselected quantization levels is determined as the quantization level of the multiple second sub-regions in the target first sub-region.

[0110] It should be understood that since the corresponding region sizes of the first sub-region and the second sub-region are different, there may be a situation where the preselected quantization level of the target first sub-region is relatively high, while the quantization levels of the multiple second sub-regions divided from the target first sub-region are all relatively low. Or, the preselected quantization level of the target first sub-region is relatively low, while the quantization levels of the multiple second sub-regions divided from the target first sub-region are all relatively high. These situations are the cases where the first preselected quantization level of the first sub-region and the second preselected quantization levels of the multiple second sub-regions divided from the first sub-region satisfy a preset conflicting condition.

[0111] For example, for an object with a relatively high importance degree contained in the target first sub-region, when it is divided into second sub-regions, each part of the object is respectively divided into the second sub-regions, resulting in the second sub-regions not being able to recognize the object, then the quantization level of the second sub-regions will be relatively low.

[0112] Then, in order to avoid the area containing objects with a higher degree of importance being confirmed with a lower quantization level, in the case of the first preselected quantization level of the first sub-region and the second preselected quantization levels of the multiple second sub-regions divided from the first sub-region, usually the higher one of the first preselected quantization level and the second preselected quantization levels is determined as the final quantization level, that is, the quantization levels of the multiple second sub-regions in the target first sub-region.

[0113] In a possible implementation manner, the original image includes multiple first sub-regions, and a target first sub-region is divided into m second sub-regions. The quantization level of each second sub-region in the target quantization table corresponds to at least one quantization coefficient in the quantization table, and the quantization level of each non-target first sub-region corresponds to at least m quantization coefficients in the quantization table.

[0114] The quantization table is usually presented in the form of a matrix (or table). In this method, each quantization coefficient in the target quantization table corresponds to an image region, such as the first sub-region and the second sub-region, and they may have different sizes. When the target quantization table in this method quantizes the image, the image sizes corresponding to each quantization coefficient in the target quantization table are the same. Therefore, if a first sub-region corresponds to only one quantization coefficient and a second sub-region also corresponds to one quantization coefficient, when the target quantization table appears in the form of a matrix, the quantization coefficient cannot properly process the corresponding region. Therefore, the smallest region in the original image is used as the region corresponding to at least one quantization coefficient, and other regions correspond to more quantization coefficients according to the size difference relationship with the smallest region.

[0115] For example, as Figure 6 shown, take a first sub-region (non-target first sub-region) and a target first sub-region in the original image as an example for illustration. If a target first sub-region can be divided into four second sub-regions, that is Figure 6 the second sub-region A, the second sub-region B, the second sub-region C, and the second sub-region D shown. And, each first sub-region corresponds to 4 quantization coefficients, that is, the 2*2 quantization table matrix composed of the quantization coefficient b in the figure. Then, for the first sub-region, its corresponding quantization coefficients are as Figure 6 shown in the 4*4 quantization table matrix composed of a.

[0116] In a possible implementation manner, when each region in the original image is a rectangular region, the side length of any region in the original image is greater than or equal to the side length of the smallest coding unit. And / or, the side lengths of each region in the original image are greater than or equal to the predicted minimum side length of the preset object in the original image.

[0117] It should be understood that the original image contains multiple regions, and the sizes of the regions may be different, such as the above-mentioned first sub-region and second sub-region. Moreover, the importance levels of the various objects in the original image are different. Therefore, in order to ensure that relatively important objects are not divided into different image regions due to region division, resulting in incomplete objects that are difficult to recognize and process. So, it is required that each region of the original image can at least completely contain a complete object with a relatively high importance level. It is necessary to limit the side length of the region to be greater than or equal to the predicted minimum side length of the preset object. The preset object can be some pre-set objects. For example, the preset object can be an object with a relatively high importance level.

[0118] In addition, since the minimum processing unit during image compression is the minimum coding unit, the side lengths of the various regions in the original image should also be greater than the minimum coding unit.

[0119] In a possible implementation, the image compression method further includes: inputting a plurality of first sample images with the same size as the first sub-region and corresponding first labels into a first image recognition and evaluation model to train the first image recognition and evaluation model. The first label includes a first quantization level and a second quantization level. The importance level of the object contained in the first sample image represented by the first quantization level is lower than the importance level of the object contained in the first sample image represented by the second quantization level.

[0120] In a possible implementation, the image compression method further includes: inputting a plurality of second sample images with the same size as the first sub-region and corresponding second labels into a second image recognition and evaluation model to train the second image recognition and evaluation model. The second label includes a first quantization level, a second quantization level, and a third quantization level. The importance level of the object contained in the second sample image represented by the first quantization level is lower than the importance level of the object contained in the second sample image represented by the second quantization level, and the importance level of the object contained in the second sample image represented by the second quantization level is lower than the importance level of the object contained in the second sample image represented by the second quantization level.

[0121] Of course, according to requirements, the number of quantization levels in the above-mentioned first label and second label can be more.

[0122] In a possible implementation, the corresponding relationship between the object and the quantization levels in the second label can be as shown in Table 1 below.

[0123] Of course, there can also be different corresponding relationships. This application is only for illustration and does not constitute an actual limitation.

[0124] Table 1

[0125] Item category Quantization level Trees, grass, shrubs, flower beds, etc. 8 Roadside debris, garbage dumps, etc. 7 Billboards, street lights, fences, etc. 5 Traffic signs, signal lights, marking lines 3 House walls 6 House doors and windows 4 People 1 Vehicle body 2 Large vehicle carrying goods 5 Vehicle license plate and cab 1 Roadside stores, guard posts, bus stops, etc. 5 Road surface 4

[0126] In a possible implementation, the second tag is related to the importance levels of all objects included in the second sample image and the area occupied by the object with the highest importance level included in the second sample image in the image.

[0127] It should be understood that since multiple different objects may also be included in the second sample image, in order to train the second tag of the second sample image to correspond to an appropriate quantization level, the importance levels of all objects included therein and the area occupied by the object with the highest importance level in the image can be comprehensively considered.

[0128] In a possible embodiment, the present application provides an image compression device, as Figure 7 shown. The image compression device includes:

[0129] An image division unit 401, configured to divide the original image into multiple regions.

[0130] An evaluation unit 402, configured to identify the objects included in each region of the original image and determine the quantization level of each region, where the quantization level represents the importance level of the objects included in the region.

[0131] A quantization table determination unit 403, configured to determine a target quantization table of the original image according to the quantization levels of each region. The target quantization table includes multiple quantization coefficients, and each region corresponds to at least one quantization coefficient. Among them, the smaller the quantization coefficient of the region in the original image, the higher the importance level of the objects included in the corresponding quantization level of the region.

[0132] A quantization unit 404, configured to quantize the first matrix of the original image based on the target quantization table of the original image to obtain a second matrix of the original image. The first matrix is the image data of the original image after discrete cosine transform. The larger the quantization coefficient corresponding to the region, the less high-frequency information of the image data corresponding to the region in the first matrix is retained after quantization.

[0133] An encoding unit 405, configured to encode the second matrix of the original image to obtain a compressed image of the original image.

[0134] In a possible implementation, multiple regions in the original image include multiple first sub-regions; the evaluation unit 402 includes a first evaluation sub-unit, a second evaluation sub-unit, and a quantization level determination sub-unit. The first evaluation sub-unit is configured to: identify the objects included in the first sub-regions and determine the preselected quantization levels of the respective first sub-regions; the image partitioning unit 401 is further configured to partition the target first sub-regions with preselected quantization levels greater than the preset level into multiple second sub-regions; multiple regions in the multiple original images further include multiple second sub-regions; the second evaluation sub-unit is configured to identify the objects included in the second sub-regions and determine the preselected quantization levels of the respective second sub-regions; the quantization level determination sub-unit is configured to determine the quantization levels of the non-target first sub-regions and the second sub-regions in the target first sub-regions in the region according to the preselected quantization levels of the non-target first sub-regions and the preselected quantization levels of the second sub-regions in the target first sub-regions.

[0135] In a possible implementation, the quantization level determination sub-unit is specifically configured to: when the first preselected quantization level of the first sub-region and the second preselected quantization levels of the multiple second sub-regions divided from the first sub-region satisfy the preset conflicting condition, determine the quantization level representing a higher importance degree of the objects included in the region among the first preselected quantization level and the second preselected quantization levels as the quantization level of the multiple second sub-regions in the target first sub-region.

[0136] In a possible implementation, the original image includes multiple first sub-regions, and one target first sub-region is divided into m second sub-regions; the quantization level of each second sub-region in the target quantization table corresponds to at least one quantization coefficient in the quantization table, and the quantization level of each non-target first sub-region corresponds to at least m quantization coefficients in the quantization table.

[0137] In a possible implementation, the quantization unit 404 is specifically configured to: quantize the first matrix of the original image according to the general quantization table for JPEG image compression; and re-quantize the quantized first matrix according to the target quantization table to obtain a second matrix.

[0138] In a possible implementation, the quantization unit 404 is specifically configured to: obtain a fused quantization table based on the target quantization table and the general quantization table for JPEG image compression; and quantize the first matrix according to the fused quantization table to obtain a second matrix.

[0139] In a possible implementation, when each region in the original image is a rectangular region, the side length of any region in the original image is greater than or equal to the side length of the minimum coding unit 405; and / or, the side lengths of each region in the original image are greater than or equal to the predicted minimum side length of the object in the original image.

[0140] In a possible implementation, the first evaluation subunit is specifically configured to: input the image of the first sub-region into the first image recognition evaluation model to obtain the preselected quantization level of the first sub-region output by the first image recognition evaluation model; the first image recognition evaluation model is used to determine the preselected quantization level corresponding to the object included in the image region; the second evaluation subunit is specifically configured to: input the image of the second sub-region into the second image recognition evaluation model to obtain the preselected quantization level of the second sub-region output by the second image recognition evaluation model; the second image recognition evaluation model is used to determine the preselected quantization level corresponding to the object included in the image region; wherein, the images input into the first image recognition evaluation model and the second image recognition evaluation model are of different sizes.

[0141] In a possible implementation, the image compression device further includes a training unit, configured to: input a plurality of first sample images having the same size as the first sub-region, and the corresponding first labels, into the first image recognition evaluation model to train the first image recognition evaluation model; the first labels include a first quantization level and a second quantization level, and the importance degree of the object included in the first sample image represented by the first quantization level is lower than the importance degree of the object included in the first sample image represented by the second quantization level.

[0142] In a possible implementation, the training unit is further configured to input a plurality of second sample images having the same size as the first sub-region, and the corresponding second labels, into the second image recognition evaluation model to train the second image recognition evaluation model; the second labels include a first quantization level, a second quantization level, and a third quantization level, and the importance degree of the object included in the second sample image represented by the first quantization level is lower than the importance degree of the object included in the second sample image represented by the second quantization level, and the importance degree of the object included in the second sample image represented by the second quantization level is lower than the importance degree of the object included in the second sample image represented by the second quantization level.

[0143] In a possible implementation, the second label is related to the importance degrees of all the objects included in the second sample image, and the area occupancy size of the object with the highest importance degree included in the second sample image in the image.

[0144] Through the description of the above embodiments, those skilled in the art can clearly understand that for the convenience and simplicity of description, only the above division of each functional module is used as an example. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the image compression device is divided into different functional modules to complete all or part of the functions described above.

[0145] The embodiments of the present application also provide a computer-readable storage medium. All or part of the processes in the above method embodiments can be completed by computer instructions instructing relevant hardware. The program can be stored in the above computer-readable storage medium. When the program is executed, it can include the processes of the above method embodiments. The computer-readable storage medium can be the memory in any of the foregoing embodiments. The above computer-readable storage medium can also be an external storage device of the above image compression device, such as a plug-in hard disk equipped on the above image compression device, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. Further, the above computer-readable storage medium can also include both the internal storage unit of the above image compression device and the external storage device. The above computer-readable storage medium is used to store the above computer program and other programs and data required by the above image compression device. The above computer-readable storage medium can also be used to temporarily store the data that has been output or will be output.

[0146] The embodiments of the present application also provide a computer program product. The computer product includes a computer program. When the computer program product runs on a computer, it causes the computer to execute any one of the image compression methods provided in the above embodiments.

[0147] Although the present application has been described in conjunction with various embodiments, however, in the process of implementing the claimed present application, those skilled in the art can understand and implement other variations of the disclosed embodiments by viewing the drawings, the disclosed content, and the appended claims. In the claims, the word "comprising" does not exclude other components or steps, and "a" or "one" does not exclude a plurality. A single processor or other unit can implement several functions recited in the claims. Certain measures are recited in mutually different dependent claims, but this does not mean that these measures cannot be combined to produce good results.

[0148] Although the present application has been described in conjunction with specific features and their embodiments, it is obvious that various modifications and combinations can be made without departing from the spirit and scope of the present application. Accordingly, the present specification and the drawings are merely exemplary descriptions of the present application defined by the appended claims, and are considered to cover any and all modifications, variations, combinations, or equivalents within the scope of the present application. Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalent technologies, the present application is also intended to include these changes and modifications.

[0149] The above is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. An image compression method, characterized in that, Including: Dividing the original image into multiple regions; Identifying the objects included in each region of the original image, and determining the quantization level of each region, where the quantization level characterizes the importance of the objects included in the region; Determining a target quantization table for the original image according to the quantization levels of each region, where the target quantization table includes multiple quantization coefficients, and each region corresponds to at least one of the quantization coefficients; wherein, the smaller the quantization coefficient of the region in the original image, the higher the importance of the objects included in the corresponding quantization level characterized region; Quantizing the first matrix of the original image based on the target quantization table of the original image to obtain a second matrix of the original image, where the first matrix is the image data of the original image after discrete cosine transform, and the larger the quantization coefficient corresponding to the region, the less high-frequency information of the image data corresponding to the region in the first matrix is retained after quantization; Encoding the second matrix of the original image to obtain a compressed image of the original image.

2. The image compression method according to claim 1, characterized in that, The multiple regions in the original image include multiple first sub-regions; the identifying the objects included in each region of the original image and determining the quantization level of the region includes: Identifying the objects included in the first sub-region and determining the preselected quantization level of each first sub-region; Dividing a target first sub-region into multiple second sub-regions; the target first sub-region is a first sub-region where the importance of the objects included in the region characterized by the preselected quantization level is greater than a preset importance level, and the multiple regions in the multiple original images also include multiple second sub-regions; Identifying the objects included in the second sub-region and determining the preselected quantization level of each second sub-region; Determining the quantization levels of the non-target first sub-region and the second sub-region in the target first sub-region in the region according to the preselected quantization level of the non-target first sub-region and the preselected quantization level of the second sub-region in the target first sub-region.

3. The image compression method according to claim 2, characterized in that, The determining the quantization levels of the non-target first sub-region and the second sub-region in the target first sub-region in the region according to the preselected quantization level of the non-target first sub-region and the preselected quantization level of the second sub-region in the target first sub-region includes: When the first preselected quantization level of the first sub-region and the second preselected quantization levels of the multiple second sub-regions divided from the first sub-region satisfy a preset contradictory condition, determining the quantization level with a higher importance of the objects included in the region in the first preselected quantization level and the second preselected quantization levels as the quantization level of the multiple second sub-regions in the target first sub-region.

4. The image compression method according to claim 2, characterized in that, The original image includes multiple first sub-regions, and one target first sub-region is divided into m second sub-regions; the quantization level of each second sub-region in the target quantization table corresponds to at least one of the quantization coefficients in the quantization table, and the quantization level of each non-target first sub-region corresponds to at least m quantization coefficients in the quantization table.

5. The image compression method according to claim 1, characterized in that, Quantizing the first matrix of the original image according to the target quantization table of the original image to obtain a second matrix of the original image, includes: Quantizing the first matrix of the original image according to the general quantization table for JPEG image compression; Quantizing the quantized first matrix again according to the target quantization table to obtain the second matrix.

6. The image compression method according to claim 1, characterized in that, Quantizing the first matrix of the original image according to the target quantization table of the original image to obtain a second matrix of the original image, includes: Obtaining a fused quantization table based on the target quantization table and the general quantization table for JPEG image compression; Quantizing the first matrix according to the fused quantization table to obtain the second matrix.

7. The image compression method according to any one of claims 1 to 6, characterized in that, When each region in the original image is a rectangular region, the side length of any region of the original image is greater than or equal to the side length of the minimum coding unit; And / or, the side lengths of each region of the original image are greater than or equal to the predicted minimum side length of a preset object in the original image.

8. The image compression method according to claim 2, characterized in that, Identifying the objects included in the first sub-region and determining the preselected quantization levels of each of the first sub-regions, includes: Inputting the image of the first sub-region into a first image recognition evaluation model to obtain the preselected quantization level of the first sub-region output by the first image recognition evaluation model; the first image recognition evaluation model is used to determine the preselected quantization level corresponding to the object included in the image region; Identifying the objects included in the second sub-region and determining the preselected quantization levels of each of the second sub-regions, includes: Inputting the image of the second sub-region into a second image recognition evaluation model to obtain the preselected quantization level of the second sub-region output by the second image recognition evaluation model; the second image recognition evaluation model is used to determine the preselected quantization level corresponding to the object included in the image region; Wherein, the sizes of the images input to the first image recognition evaluation model and the second image recognition evaluation model are different.

9. The image compression method according to claim 8, characterized in that, The method further includes: Inputting a plurality of first sample images with the same size as the first sub-region and corresponding first labels into the first image recognition evaluation model to train the first image recognition evaluation model; the first labels include a first quantization level and a second quantization level, and the importance of the object included in the first sample image represented by the first quantization level is lower than the importance of the object included in the first sample image represented by the second quantization level.

10. The image compression method according to claim 8, wherein, The method further includes: Input multiple second sample images having the same size as the first sub-region and corresponding second labels into the second image recognition and evaluation model to train the second image recognition and evaluation model; the second labels include a first quantization level, a second quantization level, and a third quantization level, and the importance level of the object included in the second sample image represented by the first quantization level is lower than the importance level of the object included in the second sample image represented by the second quantization level, and the importance level of the object included in the second sample image represented by the second quantization level is lower than the importance level of the object included in the second sample image represented by the second quantization level.

11. The image compression method according to claim 10, wherein, The second label is related to the importance levels of all objects included in the second sample image and the area occupancy size of the object with the highest importance level included in the second sample image in the image.

12. An image compression device, wherein, The apparatus includes: An image partitioning unit for partitioning an original image into multiple regions; An evaluation unit for identifying the objects included in each region of the original image and determining the quantization level of each region, where the quantization level represents the importance level of the object included in the region; A quantization table determination unit for determining a target quantization table of the original image according to the quantization levels of each region, the target quantization table including multiple quantization coefficients, and each region corresponding to at least one quantization coefficient; wherein, the smaller the quantization coefficient of the region in the original image, the higher the importance level of the object included in the region represented by the corresponding quantization level; A quantization unit for quantizing the first matrix of the original image based on the target quantization table of the original image to obtain a second matrix of the original image, the first matrix being the image data of the original image after discrete cosine transform, and the larger the quantization coefficient corresponding to the region, the less high-frequency information of the image data corresponding to the region in the first matrix is retained after quantization; An encoding unit for encoding the second matrix of the original image to obtain a compressed image of the original image.

13. An electronic device, wherein, It includes a processor and a memory, the memory is used to store computer instructions, and the processor is used to call and run the computer instructions from the memory to implement the image compression method according to any one of claims 1-11.

14. A computer-readable storage medium, wherein, The computer-readable storage medium includes: computer software instructions; when the computer software instructions run in the image compression apparatus, the image compression apparatus is caused to implement the image compression method according to any one of claims 1-11.