Image compression method and device, electronic equipment and nonvolatile storage medium

By dynamically adjusting the number of decomposed layers and quantization processing of wavelet transform, personalized compression is carried out according to the image complexity, the problem of poor image compression effect in the prior art is solved, and more efficient image compression and better compression ratio are achieved.

CN119728971AActive Publication Date: 2025-03-28CHINA TELECOM CORP LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411899286.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-20
Publication Date
2025-03-28
Estimated Expiration
2044-12-20

AI Technical Summary

Technical Problem

In the prior art, the compression effect of the image compression algorithm is poor and it is difficult to adapt to the diversity of image content.

Method used

By acquiring the number of edges of the image, evaluating the image complexity information, and dynamically adjusting the number of decomposed layers of the wavelet transform according to the complexity, performing multi-level wavelet transform and quantization processing, and finally achieving image compression.

Benefits of technology

The efficiency of image compression is improved, the compression efficiency and image quality is balanced, and the visual quality is ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119728971A_ABST
    Figure CN119728971A_ABST
Patent Text Reader

Abstract

The invention discloses an image compression method and device, electronic equipment and a nonvolatile storage medium. The method comprises the steps that a first image is acquired, the number of edges in the first image is determined, image complexity information of the first image is determined according to the number of the edges, and the edges are places where boundaries between different areas are marked in the image; according to the image complexity information, determining the number of decomposition layers of wavelet transform, and performing multi-level wavelet transform on each channel component of the first image according to the number of decomposition layers to obtain a wavelet coefficient corresponding to the channel component; performing quantization processing on the wavelet coefficient, the quantization processing being used for reducing the data volume by reducing the accuracy of the wavelet coefficient; and performing image reconstruction according to the quantized wavelet coefficient to obtain a compressed first image. According to the invention, the technical problem of poor compression effect of a compression algorithm in the prior art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] With the rapid development of digital technology, image data, as an important medium for information transmission, has occupied an indispensable position in daily life and various industries. However, due to its rich color information and high resolution, color images often have large data volumes, which not only takes up a lot of storage space, but also increases the data traffic during transmission. Therefore, how to effectively compress image data while maintaining image quality is a major challenge in the field of digital image processing.

[0003] Discrete Wavelet Transform (DWT) is widely used in the field of image compression due to its superior time-frequency local characteristics and multi-resolution analysis capabilities. However, the traditional DWT method in the related art is too static and inflexible in the selection of the number of decomposition layers, and it is difficult to adapt to the diversity of image content. This causes the compression effect of the compression algorithm in the related art to be poor.

[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0005] The embodiments of the present application provide an image compression method, device, electronic device and non-volatile storage medium to at least solve the technical problem of poor compression effect of compression algorithms in related technologies.

[0006] According to one aspect of an embodiment of the present application, an image compression method is provided, comprising: acquiring a first image, determining the number of edges in the first image, and determining image complexity information of the first image based on the number of edges, wherein the edge is a place in the image that marks the boundary between different regions; determining the number of decomposition layers of the wavelet transform based on the image complexity information, and performing a multi-level wavelet transform on each channel component of the first image according to the number of decomposition layers to obtain wavelet coefficients corresponding to the channel components; quantizing the wavelet coefficients, wherein the quantization is used to reduce the amount of data by reducing the precision of the wavelet coefficients; and reconstructing the image based on the quantized wavelet coefficients to obtain a compressed first image.

[0007] Optionally, obtaining the first image includes: obtaining a second image to be compressed, wherein the second image is an image in a red, green, and blue (RGB) color space; converting the second image from the RGB color space to a luminance and chrominance (YCbCr) color space to obtain a first image, wherein the first image includes: a luminance channel component, a blue color difference channel component, and a red color difference channel component.

[0008] Optionally, determining the image complexity information of the first image based on the number of edges includes: determining a target operator, wherein the target operator is used to enhance the grayscale transformation in the horizontal direction and / or vertical direction of the image to detect horizontal edges and vertical edges in the image; using the target operator to perform a convolution operation on each pixel in the first image to obtain an edge strength corresponding to each pixel; determining the position of a pixel in the first image whose edge strength exceeds a preset intensity threshold as a significant edge, and counting the number of significant edges to obtain the number of edges; determining a proportion of significant edges in the first image based on the number of edges, and determining the image complexity information of the first image based on the proportion.

[0009] Optionally, performing a multi-level wavelet transform on each channel component of the first image according to the number of decomposition layers to obtain wavelet coefficients corresponding to the channel components includes: determining the number of decomposition layers based on image complexity information corresponding to the brightness channel component of the first image and a preset scale factor; performing a wavelet transform on each channel component of the first image according to the number of decomposition layers to obtain wavelet coefficients corresponding to each channel component, wherein the wavelet transform is used to decompose the image into details of different scales and directions.

[0010] Optionally, quantizing the wavelet coefficients includes: dividing the wavelet coefficients by a quantization factor to obtain a target multiple; rounding the target multiple to obtain a target integer corresponding to the target multiple; and multiplying the target integer by the quantization factor to determine the result of the quantized wavelet coefficients.

[0011] Optionally, image reconstruction is performed based on the quantized wavelet coefficients to obtain the compressed first image, including: performing an inverse wavelet transform on the quantized wavelet coefficients corresponding to each channel component to obtain image data corresponding to each channel component; cropping the image data corresponding to the channel component according to image size information of the first image, and merging the cropped image data corresponding to each channel component to obtain the compressed first image.

[0012] Optionally, after obtaining the compressed first image, the method further includes: converting the compressed first image from a YCbCr color space to an RGB color space to obtain a compressed second image.

[0013] According to another aspect of an embodiment of the present application, an image compression device is also provided, including: a complexity determination module, used to obtain a first image, determine the number of edges in the first image, and determine the image complexity information of the first image based on the number of edges, wherein the edge is a place in the image that marks the boundary between different areas; a wavelet transform module, used to determine the number of decomposition layers of the wavelet transform based on the image complexity information, and perform multi-level wavelet transform on each channel component of the first image according to the number of decomposition layers to obtain wavelet coefficients corresponding to the channel components; a quantization compression module, used to quantize the wavelet coefficients, wherein the quantization process is used to reduce the amount of data by reducing the precision of the wavelet coefficients; an image reconstruction module, used to reconstruct the image based on the wavelet coefficients after quantization to obtain a compressed first image.

[0014] According to another aspect of the embodiments of the present application, there is also provided an electronic device, including: a memory and a processor, the processor being configured to run a program stored in the memory, wherein the image compression method is executed when the program is run.

[0015] According to another aspect of the embodiments of the present application, a non-volatile storage medium is provided, the non-volatile storage medium includes a stored computer program, wherein the device where the non-volatile storage medium is located executes the image compression method by running the computer program.

[0016] According to another aspect of the embodiments of the present application, a computer program product is provided, including a computer program, which implements the steps of the image compression method when the computer program is executed by a processor.

[0017] In an embodiment of the present application, a first image is acquired, and the number of edges in the first image is determined, and based on the number of edges, image complexity information of the first image is determined, wherein the edge is a place in the image that marks the boundary between different areas; based on the image complexity information, the number of decomposition layers of the wavelet transform is determined, and a multi-level wavelet transform is performed on each channel component of the first image according to the number of decomposition layers to obtain wavelet coefficients corresponding to the channel components; the wavelet coefficients are quantized, wherein the quantization is used to reduce the amount of data by reducing the precision of the wavelet coefficients; an image is reconstructed based on the quantized wavelet coefficients to obtain a compressed first image. Based on an improved discrete wavelet transform (DWT) color image compression method, image complexity is estimated through a multi-scale decomposition strategy, and the number of decomposition layers of the wavelet transform is automatically adjusted according to the complexity. Afterwards, data redundancy is reduced through a quantization process, and image data is further compressed, thereby achieving a balance between compression efficiency and image quality, so that the compressed image has a better compression ratio while ensuring visual quality, thereby solving the technical problem of poor compression effect of compression algorithms in related technologies. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0019] Figure 1 It is a hardware structure block diagram of a computer terminal (or electronic device) for implementing an image compression method provided in an embodiment of the present application;

[0020] Figure 2 is a schematic diagram of a method flow for image compression provided according to an embodiment of the present application;

[0021] Figure 3 It is a structural schematic diagram of an image compression device provided according to an embodiment of the present application. DETAILED DESCRIPTION

[0022] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0023] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0024] Image compression technology is one of the core technologies in the field of digital image processing, which aims to reduce the amount of image data, improve storage and transmission efficiency, and maintain the original quality of the image as much as possible. In recent years, various image compression technologies have been developed and improved in related technologies. For example, discrete wavelet transform (DWT) has been widely used in image coding due to its superior time-frequency characteristics and hierarchical structure. However, despite the existence of a variety of efficient image compression methods, how to further improve the compression ratio while ensuring image quality remains a challenge. Especially for image contents of different complexities, how to design flexible and efficient compression strategies to meet the needs of different scenarios is one of the key points of current research.

[0025] In order to solve the above problems, a color image compression method based on improved DWT is provided in an embodiment of the present application. First, the image is converted from RGB color space to YCbCr color space, and color space transformation is used to reduce color redundancy. Then, by evaluating the complexity of the image, the number of decomposition layers of DWT is dynamically adjusted, and personalized compression is performed according to the different characteristics of the image content. In addition, a quantization processing step is introduced to optimize the storage and transmission efficiency of data. The innovation of the present application is to provide a strategy for automatically adjusting compression parameters according to the complexity of the image, achieving a better balance between improving compression efficiency and maintaining image quality. Experimental verification shows that the method of the present application has demonstrated excellent compression ratios and visual effects on a variety of image samples, showing a wide range of application potential, especially suitable for fields with high requirements for compression efficiency and image quality, such as satellite image processing, medical image storage, and online video transmission. A detailed introduction is given below.

[0026] According to an embodiment of the present application, an embodiment of a method for image compression is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0027] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG. 1 shows a hardware structure block diagram of a computer terminal (or electronic device) for implementing an image compression method. Figure 1As shown, the computer terminal 10 (or electronic device) may include one or more (102a, 102b, ..., 102n are used to illustrate) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.

[0028] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10 (or electronic device). As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0029] The memory 104 can be used to store software programs and modules of application software, such as program instructions / data storage devices corresponding to the image compression method in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, the above-mentioned image compression method is realized. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0030] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0031] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or electronic device).

[0032] Under the above operating environment, the embodiment of the present application provides an image compression method. Figure 2 is a schematic diagram of a method flow of image compression provided according to an embodiment of the present application, such as Figure 2 As shown, the method comprises the following steps:

[0033] Step S202, acquiring a first image, and determining the number of edges in the first image, and determining image complexity information of the first image based on the number of edges, wherein an edge is a place in the image that identifies a boundary between different regions;

[0034] Step S204, determining the number of decomposition layers of wavelet transform according to the image complexity information, and performing multi-level wavelet transform on each channel component of the first image according to the number of decomposition layers to obtain wavelet coefficients corresponding to the channel components;

[0035] Step S206, quantizing the wavelet coefficients, wherein the quantization is used to reduce the precision of the wavelet coefficients to reduce the amount of data;

[0036] Step S208: reconstructing an image based on the quantized wavelet coefficients to obtain a compressed first image.

[0037] Through the above steps, the color image compression method based on the improved discrete wavelet transform estimates the image complexity through a multi-scale decomposition strategy, and automatically adjusts the number of decomposition layers of the wavelet transform according to the complexity. After that, the redundancy of the data is reduced through a quantization process, and the image data is further compressed, thereby achieving a balance between compression efficiency and image quality, so that the compressed image has a better compression ratio while ensuring the visual quality, thereby solving the technical problem of poor compression effect of the compression algorithm in the related technology.

[0038] The image compression method in steps S202 to S208 of the embodiment of the present application is further introduced below.

[0039] In the embodiment of the present application, when compressing a color image, the color image can first be converted from the RGB color space to the YCbCr color space. Then, the image complexity is estimated by a multi-scale decomposition strategy, and the number of decomposition layers of the wavelet transform is automatically adjusted according to the complexity. After that, the redundancy of the data is reduced by a quantization process, and the image data is further compressed to obtain a compressed image. The steps in this process are described in detail below.

[0040] In the process of color image compression, the original image (i.e., the second image to be compressed) is first converted from the RGB color space to the YCbCr color space, which can better separate the brightness and chrominance components of the image, thereby optimizing the subsequent compression steps, as follows.

[0041] In some embodiments of the present application, obtaining a first image includes the following steps: obtaining a second image to be compressed, wherein the second image is an image in a red, green, and blue (RGB) color space; converting the second image from the RGB color space to a luminance and chrominance (YCbCr) color space to obtain a first image, wherein the first image includes: a luminance channel component, a blue color difference channel component, and a red color difference channel component.

[0042] Specifically, in actual implementation, relevant libraries for processing images and mathematical calculations in Python can be introduced, and the image processing library Pillow is used to load the original RGB image (i.e., the second image) for color space conversion, that is, the color space of the image is converted from RGB to YCbCr to obtain the first image, wherein the brightness information (Y, i.e., brightness channel component) and chrominance information (Cb and Cr, i.e., blue and red color difference channel components) of an image can be processed separately in the YCbCr color space.

[0043] For example, the steps of color space conversion can be implemented by the following code:

[0044] “#Introduce the required libraries

[0045] import numpy as np

[0046] import pywt

[0047] from PIL import Image

[0048] #Use Pillow library to convert color space from RGB to YCbCr

[0049] def convert_rgb_to_ycbcr(image):

[0050] return image.convert('YCbCr')"

[0051] After obtaining the first image in the YCbCr color space, a multi-scale decomposition strategy can be used to evaluate the complexity of the image. First, the number of edges in the first image is determined, and then the image complexity information of the first image is determined based on the number of edges. The specific steps are as follows.

[0052] In some embodiments of the present application, determining the image complexity information of the first image based on the number of edges includes the following steps: determining a target operator, wherein the target operator is used to enhance the grayscale transformation in the horizontal direction and / or vertical direction of the image to detect horizontal edges and vertical edges in the image; using the target operator to perform a convolution operation on each pixel in the first image to obtain an edge strength corresponding to each pixel; determining the position of the pixel in the first image whose edge strength exceeds a preset intensity threshold as a significant edge, and counting the number of significant edges to obtain the number of edges; determining the proportion of significant edges in the first image based on the number of edges, and determining the image complexity information of the first image based on the proportion.

[0053] For example, the following code can be used to evaluate the complexity of an image:

[0054] "#Evaluate the complexity of the image by counting the number of edges

[0055] def estimate_complexity(image_array):

[0056] #In this example, a simple Sobel operator can be used to estimate edge density. In practice, a more accurate method can be used.

[0057] sobel_x=np.array([[-1,0,1],[-2,0,2],[-1,0,1]])

[0058] sobel_y=np.array([[-1,-2,-1],[0,0,0],[1,2,1]])

[0059] edge_x=np.abs(np.convolve(image_array,sobel_x,mode='valid'))

[0060] edge_y=np.abs(np.convolve(image_array,sobel_y,mode='valid'))

[0061] edges=np.hypot(edge_x,edge_y)

[0062] edge_density = np.sum(edges>50) / edges.size#The preset intensity threshold 50 here can be adjusted according to actual needs

[0063] return edge_density"

[0064] Specifically, the evaluation of image complexity information can be achieved by calculating the number of edges in the first image. In this embodiment, a target operator (such as a Sobel operator) can be used to identify edges, and the complexity can be evaluated based on the edge density. The evaluation result of this complexity will affect the number of layers of subsequent wavelet transforms.

[0065] Among them, the above-mentioned Sobel operator is used to detect horizontal and vertical edges in an image. The edge is a place where the brightness changes significantly in the image, usually marking the boundary between different areas. In this embodiment, the Sobel operator includes two 3x3 convolution kernels (kernels), including: a horizontal edge detection kernel (Sobel_x) and a vertical edge detection kernel (Sobel_y), which are respectively used to detect horizontal and vertical edges in the image. The Sobel operator is applied to each pixel of the image, and the edge strength is calculated by convolution operation. The specific steps are as follows: For each pixel in the image, its neighborhood (usually a 3x3 area) is convolved with the Sobel_x and Sobel_y kernels. The convolution operation is completed by multiplying each element of the kernel with its corresponding pixel element and then summing them. Among them, after convolving the image with the Sobel_x kernel, the result obtained is a horizontal edge strength map. After convolving the image with the Sobel_y kernel, the result obtained is a vertical edge strength map. The horizontal and vertical edge strengths are combined to obtain a total edge strength map. This can usually be done by calculating the Euclidean distance of the horizontal and vertical edge strengths. At the same time, in order to determine which edges are significant, a preset intensity threshold needs to be set. In the above code, this threshold is 50, but this value can be adjusted according to the image and application scenario. By comparing the edge intensity with the threshold, the significant edges are determined; by calculating the total number of significant edges and then dividing it by the total number of pixels in the edge intensity map edges.size, the edge density edge_density is obtained, that is, the proportion of significant edges in the first image above. The edge density can be used to evaluate the complexity of the image. The higher the edge density, the more complex the image.

[0066] After that, the number of decomposition levels can be automatically adjusted according to the image complexity information, and discrete wavelet transform (DWT) is applied to the Y, Cb, and Cr channels respectively according to the number of decomposition levels, and multi-layer processing is performed to achieve a predetermined compression effect. The specific steps are as follows.

[0067] In some embodiments of the present application, performing a multi-level wavelet transform on each channel component of the first image according to the number of decomposition layers to obtain the wavelet coefficients corresponding to the channel components includes the following steps: determining the number of decomposition layers based on image complexity information corresponding to the brightness channel component of the first image and a preset scaling factor; performing a wavelet transform on each channel component of the first image according to the number of decomposition layers to obtain the wavelet coefficients corresponding to each channel component, wherein the wavelet transform is used to decompose the image into details of different scales and directions.

[0068] For example, the wavelet transform of each channel component can be implemented by the following code:

[0069] “#Perform multi-level wavelet transform on the image

[0070] def wavelet_transform(image,levels=3):

[0071] #Convert the image into an array for processing

[0072] image_array = np.array(image)

[0073] #Get each channel

[0074] y_channel,cb_channel,cr_channel=image_array[:,:,0],image_array[:,:,1],image_array[:,:,2]

[0075] #Evaluate the complexity of the Y channel to determine the number of decomposition layers

[0076] complexity=estimate_complexity(y_channel)

[0077] #The scale factor 2 here can be adjusted as needed

[0078] levels=base_level+int(complexity*2)

[0079] #Perform wavelet transform on all channels

[0080] coeffs_y=pywt.wavedec2(y_channel,'haar',level=levels)

[0081] coeffs_cb=pywt.wavedec2(cb_channel,'haar',level=levels)

[0082] coeffs_cr=pywt.wavedec2(cr_channel,'haar',level=levels)

[0083] return coeffs_y,coeffs_cb,coeffs_cr”

[0084] Specifically, wavelet transform can be performed on each channel (Y, Cb, Cr) of the image according to the complexity corresponding to the first image, especially the complexity of the brightness channel (Y channel). Wavelet transform can decompose the image into details of different scales and directions, allowing different parts of the image to be processed at different levels. Depending on the complexity of the image, different decomposition levels can be selected to optimize the compression efficiency.

[0085] Subsequently, the obtained wavelet coefficients can be quantized to further reduce the amount of data. The specific steps are as follows.

[0086] In some embodiments of the present application, quantizing the wavelet coefficients includes the following steps: dividing the wavelet coefficients by a quantization factor to obtain a target multiple; rounding the target multiple to obtain a target integer corresponding to the target multiple; multiplying the target integer by the quantization factor to determine the result of the quantized wavelet coefficients.

[0087] Specifically, after the wavelet transform, a series of coefficients are obtained, which represent the different frequency components of the image. In order to further compress the image, these coefficients are quantized, that is, the accuracy of the coefficients is reduced. Through quantization, many high-frequency coefficients may become zero, thereby reducing the amount of data while retaining the main image features.

[0088] For example, the quantization of wavelet coefficients can be achieved through the following code:

[0089] “#Quantitative process, the actual quantitative strategy can be adjusted

[0090] def apply_quantization(coeffs,qfactor=50):

[0091] quantized_coeffs=map(lambda x:np.round(x / qfactor)*qfactor,coeffs)

[0092] return list(quantized_coeffs)”

[0093] In this embodiment, a function named apply_quantization is defined, which accepts two parameters: coeffs (a list of wavelet coefficients after wavelet transformation) and qfactor (quantization factor, the default value is 50). The lambda function is used to quantize each wavelet coefficient in coeffs. Specifically, the wavelet coefficient x is divided by the quantization factor qfactor. Then, the np.round function is used to round the result to the nearest integer (i.e., the target integer). This step actually "compresses" the value of the coefficient to a multiple of the quantization factor. Finally, the rounded value is multiplied by the quantization factor qfactor to restore its original magnitude, but with reduced accuracy.

[0094] Afterwards, the image is reconstructed using the quantized wavelet coefficients, and the details of each frequency and position of the image are resynthesized to obtain a compressed first image. The specific steps are as follows.

[0095] In some embodiments of the present application, image reconstruction is performed based on the quantized wavelet coefficients to obtain a compressed first image, which includes the following steps: performing an inverse wavelet transform on the quantized wavelet coefficients corresponding to each channel component to obtain image data corresponding to each channel component; cropping the image data corresponding to the channel component according to the image size information of the first image, and merging the cropped image data corresponding to each channel component to obtain a compressed first image.

[0096] For example, image reconstruction can be achieved through the following code:

[0097] “#Merge Y, Cb, Cr channels and reassemble the three channels into a complete image.

[0098] def inverse_wavelet_transform(coeffs_y,coeffs_cb,coeffs_cr,image_size):

[0099] y_reconstructed=pywt.waverec2(coeffs_y,'haar')

[0100] cb_reconstructed=pywt.waverec2(coeffs_cb,'haar')

[0101] cr_reconstructed=pywt.waverec2(coeffs_cr,'haar')

[0102] #Since the reconstructed size may be slightly different from the original size, it needs to be cropped or padded to the original size y_reconstructed = y_reconstructed[:image_size[0],:image_size[1]]

[0103] cb_reconstructed=cb_reconstructed[:image_size[0],:image_size[1]]

[0104] cr_reconstructed=cr_reconstructed[:image_size[0],:image_size[1]]

[0105] #Stack the three channels to generate the target image, which is the first image after compression

[0106] reconstructed_image=np.stack([y_reconstructed,cb_reconstructed,cr_reconstructed],axi s=-1).astype(np.uint8)

[0107] return reconstructed_image"

[0108] In this embodiment, a function named inverse_wavelet_transform is defined, which accepts four parameters: coeffs_y (wavelet coefficients of the Y channel), coeffs_cb (wavelet coefficients of the Cb channel), coeffs_cr (wavelet coefficients of the Cr channel), and image_size (the size of the original image, given in the form of `(width, height)`). An inverse wavelet transform is performed on the wavelet coefficients of each channel using the pywt.waverec2` function. This function converts the wavelet coefficients back to the original image data. Since the image size obtained after the inverse wavelet transform may be slightly different from the original image size, the reconstructed image needs to be cropped or padded to the original size. Finally, the np.stack` function is used to stack the reconstructed images of the three channels of Y, Cb, and Cr along the last axis (usually the color channel axis) to generate a complete image, that is, the compressed first image.

[0109] Furthermore, after obtaining the compressed first image, the method further includes the following steps: converting the compressed first image from the YCbCr color space to the RGB color space to obtain a compressed second image. That is, converting the reconstructed first image from the YCbCr color space back to the original RGB color space and outputting it to obtain a compressed second image. The whole process not only optimizes the storage and transmission efficiency, but also maintains the visual quality of the image to a certain extent.

[0110] In order to ensure the reliability of the method, the hardware solution of this application can be used for experiments on an elastic cloud host, with hardware specifications of 8-core CPU, 16GB memory, 500GB object storage cloud hard disk, Ubuntu 20.04LTS operating system, and 20Mbps bandwidth. The software solution of this method is implemented by writing applications based on Python's Numpy library and Pywt library. In order to verify the compression effect of the algorithm in a practical environment, the experiment used classic image processing data sets, including four types of pictures: Baboon, Lena, Peppers, and Boat. The colors and patterns contained in these types of pictures are relatively comprehensive, and are suitable as original images for image processing algorithms.

[0111] In order to analyze the experimental results, this method develops a web application in the cloud environment, which contains the algorithm proposed in this paper. The web application runs in the cloud environment of the cloud network service, encapsulates the algorithm into a web module, and opens the interface. The HTTP network request is called on the local computer, and the local data set is transferred to the cloud server through the interface program to verify the encryption algorithm result.

[0112] The following is an introduction to the test and verification results of this application solution.

[0113] In the implementation of this application, in order to evaluate the performance of the color image compression method based on the improved DWT, the compression effect of this method is compared with that of the traditional JPEG 2000 compression technology. Each image is first converted to the YCbCr color space, and then the appropriate number of wavelet transform layers is selected for DWT according to the complexity of the brightness channel. After the image is compressed, it is reconstructed by inverse wavelet transform and finally converted back to RGB color space. In this embodiment, the peak signal-to-noise ratio (PSNR) and structural similarity index (SSIM) are used to evaluate the image quality. The compression results are compared as shown in the following table.

[0114]

[0115]

[0116] Experimental results show that the proposed method performs particularly well on highly complex images. On images of lower complexity, such as simple natural landscapes, the improved DWT method can achieve a compression ratio similar to that of JPEG 2000, but is more effective in maintaining higher image quality.

[0117] On the other hand, for the analysis of compression time, in addition to the above-mentioned pictures, this embodiment also compares other types of pictures, such as grayscale and color images, and compares pictures of different image sizes. The comparison results of different image types, sizes, and dimensions are shown in the following table.

[0118]

[0119] As can be seen from the table, the average compression time and the average decompression time are related to the size of the image, and the larger the size of the image, the longer the compression and decompression time. Compared with the grayscale image, the compression time will also increase due to the richer colors on the color channel. However, the overall compression and decompression time is also controlled within a certain range. In terms of image size, the size of the processed image is obviously smaller than the original image.

[0120] The embodiment of the present application dynamically adjusts the number of decomposition levels of the discrete wavelet transform (DWT) by evaluating the complexity of the image, which is more flexible to adapt to the diversity of image content than the static decomposition strategy of the traditional method; by converting the color space from RGB to YCbCr, a more effective expression of image information is achieved, especially for the separation of brightness and chrominance information, which plays an important role in improving compression efficiency and maintaining image quality; after the wavelet transform, the coefficients are quantized, which effectively reduces the amount of data and reduces the redundancy in the storage and transmission process, providing strong support for achieving a high compression ratio.

[0121] In summary, the present application proposes a color image compression method based on improved discrete wavelet transform, which realizes personalized compression for different image contents by adding image complexity evaluation and dynamically adjusting the decomposition layer strategy in the compression process. The original image is converted from RGB color space to YCbCr color space, which effectively reduces color redundancy, and optimizes the brightness and chromaticity components of the image to further improve the compression efficiency. Experimental verification shows that compared with traditional compression technologies such as JPEG 2000, the present application method can provide a better compression ratio while maintaining visual quality, especially when processing high-complexity images. The goal of improving the compression ratio while ensuring the visual quality of the image is achieved. This method has broad application potential and practical value in application scenarios that require efficient data storage and transmission, such as satellite image processing, medical image storage, and online video transmission.

[0122] Specifically, in the process of satellite image transmission and storage, efficient compression technology is particularly important due to the huge amount of image data. This method can dynamically adjust the compression strategy according to the complexity of the image, and is suitable for optimizing the storage and transmission of satellite image data, reducing bandwidth occupancy, and improving data processing speed; in the medical field, the high quality of images such as MRI and CT is the key to diagnostic accuracy. This technology reduces the amount of data while ensuring image quality, which can help medical institutions effectively manage and store large amounts of image data and improve access efficiency; for live video and online video services, compression technology can significantly reduce data transmission time and cost. This method can optimize the transmission quality and buffering speed of streaming media by dynamically adjusting the compression level to adapt to the complexity of different scenes in the video.

[0123] By utilizing the present application scheme, by effectively compressing image data, enterprises and service providers can reduce the required archiving space while maintaining image quality, thereby directly reducing physical storage costs; compression technology can reduce the amount of data transmitted on the network, speed up data transmission, and reduce the burden on the network, especially when broadband resources are limited. This advantage is particularly important. Smaller data volumes during data processing and transmission can reduce energy consumption, which is an environmental and cost factor that cannot be ignored for companies running large data centers. By effectively compressing image data, the present application scheme allows enterprises and service providers to reduce the required archiving space while maintaining image quality. The dynamically adjusted compression strategy provided opens up a new way of personalized data processing and meets the specific needs of different users and industries for data processing. It has certain research value in network data security protection.

[0124] According to an embodiment of the present application, an embodiment of an image compression device is also provided. Figure 3 is a schematic diagram of the structure of an image compression device provided according to an embodiment of the present application. Figure 3 As shown, the device comprises:

[0125] The complexity determination module 30 is used to obtain a first image, determine the number of edges in the first image, and determine the image complexity information of the first image based on the number of edges, wherein the edge is a place in the image that identifies the boundary between different regions;

[0126] The wavelet transform module 32 is used to determine the number of decomposition layers of the wavelet transform according to the image complexity information, and perform multi-level wavelet transform on each channel component of the first image according to the number of decomposition layers to obtain wavelet coefficients corresponding to the channel components;

[0127] A quantization compression module 34, used for performing quantization processing on the wavelet coefficients, wherein the quantization processing is used to reduce the data volume by reducing the precision of the wavelet coefficients;

[0128] The image reconstruction module 36 is used to reconstruct the image according to the quantized wavelet coefficients to obtain a compressed first image.

[0129] Optionally, obtaining the first image includes: obtaining a second image to be compressed, wherein the second image is an image in a red, green, and blue (RGB) color space; converting the second image from the RGB color space to a luminance and chrominance (YCbCr) color space to obtain a first image, wherein the first image includes: a luminance channel component, a blue color difference channel component, and a red color difference channel component.

[0130] Optionally, determining the image complexity information of the first image based on the number of edges includes: determining a target operator, wherein the target operator is used to enhance the grayscale transformation in the horizontal direction and / or vertical direction of the image to detect horizontal edges and vertical edges in the image; using the target operator to perform a convolution operation on each pixel in the first image to obtain an edge strength corresponding to each pixel; determining the position of a pixel in the first image whose edge strength exceeds a preset intensity threshold as a significant edge, and counting the number of significant edges to obtain the number of edges; determining a proportion of significant edges in the first image based on the number of edges, and determining the image complexity information of the first image based on the proportion.

[0131] Optionally, performing a multi-level wavelet transform on each channel component of the first image according to the number of decomposition layers to obtain wavelet coefficients corresponding to the channel components includes: determining the number of decomposition layers based on image complexity information corresponding to the brightness channel component of the first image and a preset scale factor; performing a wavelet transform on each channel component of the first image according to the number of decomposition layers to obtain wavelet coefficients corresponding to each channel component, wherein the wavelet transform is used to decompose the image into details of different scales and directions.

[0132] Optionally, quantizing the wavelet coefficients includes: dividing the wavelet coefficients by a quantization factor to obtain a target multiple; rounding the target multiple to obtain a target integer corresponding to the target multiple; and multiplying the target integer by the quantization factor to determine the result of the quantized wavelet coefficients.

[0133] Optionally, image reconstruction is performed based on the quantized wavelet coefficients to obtain the compressed first image, including: performing an inverse wavelet transform on the quantized wavelet coefficients corresponding to each channel component to obtain image data corresponding to each channel component; cropping the image data corresponding to the channel component according to image size information of the first image, and merging the cropped image data corresponding to each channel component to obtain the compressed first image.

[0134] Optionally, after obtaining the compressed first image, the method further includes: converting the compressed first image from a YCbCr color space to an RGB color space to obtain a compressed second image.

[0135] It should be noted that the various modules in the above-mentioned image compression device can be program modules (for example, a set of program instructions that implement a certain specific function) or hardware modules. For the latter, it can be expressed in the following forms, but is not limited to this: the expression form of each of the above-mentioned modules is a processor, or the functions of each of the above-mentioned modules are implemented by a processor.

[0136] It should be noted that the image compression device provided in this embodiment can be used to perform Figure 2 The image compression method shown, therefore, the relevant explanations and descriptions of the above-mentioned image compression method are also applicable to the embodiments of the present application and will not be repeated here.

[0137] An embodiment of the present application also provides a non-volatile storage medium, the non-volatile storage medium includes a stored computer program, wherein the device where the non-volatile storage medium is located executes the following image compression method by running the computer program: obtaining a first image, and determining the number of edges in the first image, and based on the number of edges, determining the image complexity information of the first image, wherein the edge is a place in the image that marks the boundary between different areas; determining the number of decomposition layers of the wavelet transform based on the image complexity information, and performing a multi-level wavelet transform on each channel component of the first image according to the number of decomposition layers to obtain wavelet coefficients corresponding to the channel components; quantizing the wavelet coefficients, wherein the quantization is used to reduce the amount of data by reducing the precision of the wavelet coefficients; reconstructing the image based on the quantized wavelet coefficients to obtain a compressed first image.

[0138] The embodiments of the present application also provide a computer program product, including a computer program, which, when executed by a processor, implements the steps of the image compression method described in each embodiment of the present application: obtaining a first image, determining the number of edges in the first image, and determining the image complexity information of the first image based on the number of edges, wherein the edge is a place in the image that marks the boundary between different areas; determining the number of decomposition layers of the wavelet transform based on the image complexity information, and performing a multi-level wavelet transform on each channel component of the first image according to the number of decomposition layers to obtain the wavelet coefficients corresponding to the channel components; quantizing the wavelet coefficients, wherein the quantization is used to reduce the amount of data by reducing the precision of the wavelet coefficients; reconstructing the image based on the quantized wavelet coefficients to obtain a compressed first image.

[0139] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0140] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0141] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0142] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0143] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0144] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), mobile hard disk, disk or CD-ROM and other media that can store program codes.

[0145] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. An image compression method, characterized in that: include: Acquire a first image, determine the number of edges in the first image, and determine image complexity information of the first image based on the number of edges, wherein the edge is a place in the image that identifies a boundary between different regions; Determining the number of decomposition layers of wavelet transform according to the image complexity information, and performing multi-level wavelet transform on each channel component of the first image according to the number of decomposition layers to obtain wavelet coefficients corresponding to the channel components; quantizing the wavelet coefficients, wherein the quantization is used to reduce the amount of data by reducing the precision of the wavelet coefficients; Image reconstruction is performed based on the wavelet coefficients after the quantization process to obtain the compressed first image.

2. The image compression method according to claim 1, characterized in that: Acquiring the first image includes: Acquire a second image to be compressed, wherein the second image is an image in a red, green, and blue (RGB) color space; The second image is converted from the RGB color space to the luminance and chrominance YCbCr color space to obtain the first image, wherein the first image includes: a luminance channel component, a blue color difference channel component, and a red color difference channel component.

3. The image compression method according to claim 1, characterized in that: Determining the image complexity information of the first image according to the number of edges includes: Determining a target operator, wherein the target operator is used to enhance grayscale transformation in the horizontal direction and / or vertical direction in the image to detect horizontal edges and vertical edges in the image; Using the target operator, perform a convolution operation on each pixel in the first image to obtain an edge strength corresponding to each pixel; Determining positions of pixels in the first image whose edge strength exceeds a preset strength threshold as significant edges, and counting the number of the significant edges to obtain the number of edges; According to the number of edges, a ratio of the significant edges in the first image is determined, and according to the ratio, the image complexity information of the first image is determined.

4. The image compression method according to claim 1, characterized in that: Performing multi-level wavelet transform on each channel component of the first image according to the number of decomposition layers to obtain wavelet coefficients corresponding to the channel components includes: Determining the number of decomposition layers according to the image complexity information corresponding to the brightness channel component of the first image and a preset scale factor; According to the decomposition level, wavelet transform is performed on each of the channel components of the first image to obtain the wavelet coefficients corresponding to each of the channel components, wherein the wavelet transform is used to decompose the image into details of different scales and directions.

5. The image compression method according to claim 4, characterized in that: The quantization process of the wavelet coefficients includes: Dividing the wavelet coefficient by the quantization factor to obtain a target multiple; Rounding the target multiple to obtain a target integer corresponding to the target multiple; The product of the target integer and the quantization factor is determined as the result of the quantization processing of the wavelet coefficients.

6. The image compression method according to claim 5, characterized in that: Performing image reconstruction according to the wavelet coefficients after the quantization process to obtain the compressed first image includes: Performing inverse wavelet transform on the wavelet coefficients corresponding to each of the channel components after the quantization process to obtain image data corresponding to each of the channel components; According to the image size information of the first image, the image data corresponding to the channel components are cropped, and the image data corresponding to each of the channel components after cropping are merged to obtain the compressed first image.

7. The image compression method according to claim 6, characterized in that: After obtaining the compressed first image, the method further includes: The compressed first image is converted from the YCbCr color space to the RGB color space to obtain a compressed second image.

8. An image compression device, characterized in that: include: a complexity determination module, configured to obtain a first image, determine the number of edges in the first image, and determine image complexity information of the first image based on the number of edges, wherein the edge is a place in the image that identifies a boundary between different regions; A wavelet transform module, used to determine the number of decomposition layers of the wavelet transform according to the image complexity information, and perform multi-level wavelet transform on each channel component of the first image according to the number of decomposition layers to obtain wavelet coefficients corresponding to the channel components; A quantization compression module, used for performing quantization processing on the wavelet coefficients, wherein the quantization processing is used for reducing the precision of the wavelet coefficients to reduce the amount of data; An image reconstruction module is used to perform image reconstruction based on the wavelet coefficients after the quantization process to obtain the compressed first image.

9. An electronic device, characterized in that: include: A memory and a processor, wherein the processor is used to run a program stored in the memory, wherein the program executes the image compression method according to any one of claims 1 to 7 when running.

10. A non-volatile storage medium, characterized in that: The non-volatile storage medium includes a stored computer program, wherein the device where the non-volatile storage medium is located executes the image compression method according to any one of claims 1 to 7 by running the computer program.

11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the image compression method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Structured prior constraint-based method for improving sparse image reconstruction precision and reducing complexity

    CN107784278A

  • Image compression method and device and electronic equipment

    CN109996078A

  • Compressed sensing method for adaptive multi-scale block size of image

    CN117478905A

  • Methods and systems for optimizing image data compression involving wavelet transform

    US6101284A