CN111147861A - Image compression method, device, user equipment and computer readable storage medium - Google Patents

Image compression method, device, user equipment and computer readable storage medium Download PDF

Info

Publication number
CN111147861A
CN111147861A CN202010000679.XA CN202010000679A CN111147861A CN 111147861 A CN111147861 A CN 111147861A CN 202010000679 A CN202010000679 A CN 202010000679A CN 111147861 A CN111147861 A CN 111147861A
Authority
CN
China
Prior art keywords
image
compressed
information
data
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010000679.XA
Other languages
Chinese (zh)
Inventor
林寿耿
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Huya Technology Co Ltd
Original Assignee
Guangzhou Huya Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Huya Technology Co Ltd filed Critical Guangzhou Huya Technology Co Ltd
Priority to CN202010000679.XA priority Critical patent/CN111147861A/en
Publication of CN111147861A publication Critical patent/CN111147861A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/42Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/182Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being a pixel
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/90Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using coding techniques not provided for in groups H04N19/10-H04N19/85, e.g. fractals
    • H04N19/91Entropy coding, e.g. variable length coding [VLC] or arithmetic coding

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The image compression method is applied to user equipment and comprises the steps of obtaining image data of an image to be compressed, wherein the image data comprises α channel information of the image to be compressed, the α channel information is used for determining α channel number of the image to be compressed, removing all α channel data of the image to be compressed according to the image data to obtain intermediate data, obtaining a target compressed image after the intermediate data are compressed, performing image compression by using the image compression method provided by the application, deleting α channel data in the image to be compressed, reducing the memory size occupied by the compressed image under the condition of not influencing user experience, and improving the compression ratio of the image.

Description

Image compression method, device, user equipment and computer readable storage medium
Technical Field
The present application relates to the field of image processing, and in particular, to an image compression method, apparatus, user equipment, and computer-readable storage medium.
Background
The information age brings "information explosion" and greatly increases the data volume, so that the data needs to be effectively compressed regardless of transmission or storage.
When the picture is compressed by using a Bitmap compression mode externally provided by the Android platform, the compression ratio is not high, and meanwhile, the compressed picture has poor quality and insufficient compression ratio and cannot achieve the effect of project requirements. Therefore, how to improve the compression quality of the image is an urgent problem to be solved at present.
Disclosure of Invention
In order to overcome at least the above-mentioned deficiencies in the prior art, it is an object of the present application to provide an image compression method, apparatus, user equipment and computer readable storage medium.
According to a first aspect, the embodiment provides an image compression method applied to user equipment, and the method comprises the steps of obtaining image data of an image to be compressed, wherein the image data comprises α channel information of the image to be compressed, and the α channel information is used for determining α channel number of the image to be compressed.
In an optional embodiment, the image data further includes width information and height information, and the obtaining a target compressed image obtained by compressing the intermediate data includes: acquiring pixel information of the target compressed image according to the height information and the width information; the pixel information includes the number of pixels of the target compressed image and the position information of each pixel. And performing Huffman calculation on the intermediate data to obtain a Huffman coding tree corresponding to each pixel point. And recoding the intermediate data according to the Huffman coding trees of all the pixel points to obtain the target compressed image.
In an optional embodiment, the obtaining pixel information of the target compressed image according to the height information and the width information includes: acquiring target compression parameters of the image to be compressed according to the height information and the width information; the target compression parameters include a target width and a target height. And determining the pixel information according to the target compression parameter.
In an optional embodiment, before the obtaining the pixel information of the target compressed image according to the height information and the width information, the obtaining a target compressed image after compressing the intermediate data further includes: and storing the intermediate data to a memory space matched with the width information and the height information. The performing huffman calculation on the intermediate data to obtain the huffman coding tree corresponding to each pixel point includes: and scanning the intermediate data in the memory space to obtain the Huffman coding tree corresponding to each pixel point.
In an optional embodiment, the re-encoding the intermediate data according to the huffman coding trees of all the pixel points to obtain a target compressed image includes: recoding the intermediate data according to the Huffman coding trees of all the pixel points to obtain compressed data; the compressed data includes image data of the target compressed image and image parameter information. Reading the compressed data to generate the target compressed image.
According to a second aspect, the embodiment provides an image compression device, which comprises a processing module and a compression module, wherein the processing module is used for obtaining image data of an image to be compressed, the image data comprises α channel information of the image to be compressed, the α channel information is used for determining α channel number of the image to be compressed, the processing module is further used for removing all α channel data of the image to be compressed according to the image data to obtain intermediate data, and the compression module is used for obtaining a target compressed image after the intermediate data is compressed.
In an alternative embodiment, the image data further comprises width information and height information; the compression module is further used for acquiring pixel information of the target compressed image according to the height information and the width information; the pixel information includes the number of pixels of the target compressed image and the position information of each pixel. The compression module is further used for performing Huffman calculation on the intermediate data to obtain a Huffman coding tree corresponding to each pixel point; and the compression module is also used for recoding the intermediate data according to the Huffman coding trees of all the pixel points to acquire the target compressed image.
In an optional implementation manner, the compression module is further configured to re-encode the intermediate data according to the huffman coding trees of all the pixel points to obtain compressed data. The compressed data includes image data of the target compressed image and image parameter information. The compression module is further configured to read the compressed data to generate the target compressed image.
In a third aspect, embodiments provide a user equipment comprising a processor and a memory, the memory storing machine executable instructions executable by the processor to implement the image compression method of any one of the preceding embodiments.
In a fourth aspect, embodiments provide a computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the image compression method as described in any one of the preceding embodiments.
Compared with the prior art, the image compression method is applied to the user equipment, the image compression method comprises the steps of obtaining image data of an image to be compressed, wherein the image data comprises α channel information of the image to be compressed, the α channel information is used for determining α channel number of the image to be compressed, removing all α channel data of the image to be compressed to obtain intermediate data according to the image data, obtaining a target compressed image after the intermediate data are compressed, performing image compression by using the image compression method provided by the application, deleting α channel data in the image, reducing the memory size occupied by the compressed image under the condition of not influencing user experience, and improving the compression rate of the image.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained from the drawings without inventive effort.
Fig. 1 is a schematic structural diagram of a user equipment according to an embodiment of the present application;
fig. 2 is a schematic flowchart of an image compression method according to an embodiment of the present application;
FIG. 3 is a schematic diagram illustrating an image compression algorithm according to an embodiment of the present application;
fig. 4 is a schematic flowchart of another image compression method according to an embodiment of the present application;
fig. 5 is a schematic flowchart of another image compression method according to an embodiment of the present application;
fig. 6 is a schematic flowchart of another image compression method according to an embodiment of the present application;
fig. 7 is a schematic flowchart of another image compression method according to an embodiment of the present application;
fig. 8 is a block diagram of an image compression apparatus according to an embodiment of the present application.
Icon: 100-user equipment, 110-processor, 120-external memory interface, 121-internal memory, 130-USB interface, 140-charging management module, 141-power management module, 142-battery, 150-mobile communication module, 160-wireless communication module, 194-display screen, 40-image compression device, 41-processing module, 42-compression module.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
In the description of the present application, it is further noted that, unless expressly stated or limited otherwise, the terms "disposed," "mounted," "connected," and "connected" are to be construed broadly, e.g., as meaning either a fixed connection, a removable connection, or an integral connection; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. The specific meaning of the above terms in the present application can be understood in a specific case by those of ordinary skill in the art.
At present, when an Application Program Interface (API) provided by an Android platform is used for image compression through a Bitmap compression method, however, the realized image compression ratio is not high, and cannot reach the image compression ratio required by a project, but a memory is the most precious resource on user equipment, and how to reduce the size of the memory required by loading an image onto the memory on the basis of not influencing user experience is an urgent problem to be solved at present. In order to solve the above problem, an embodiment of the present application provides a possible image compression method, which is applied to a user equipment.
It can be understood that the image compression method provided in the embodiment of the present application may be applied to a Mobile phone, a tablet Computer, a wearable device, an in-vehicle device, an Augmented Reality (AR)/Virtual Reality (VR) device, a notebook Computer, a super-Mobile Personal Computer (UMPC), a netbook, a Personal Digital Assistant (PDA), and other user devices, and the embodiment of the present application does not limit the specific type of the user device.
Fig. 1 shows a schematic structural diagram of a user equipment 100. The user equipment 100 may include a processor 110, an external memory interface 120, an internal memory 121, a Universal Serial Bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, a display screen 194, and the like. It is to be understood that the illustrated structure of the embodiment of the present application does not constitute a specific limitation to the user equipment 100. In other embodiments of the present application, user device 100 may include more or fewer components than shown, or combine certain components, or split certain components, or a different arrangement of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
Processor 110 may include one or more processing units, such as: the Processor 110 may include an Application Processor (AP), a modem Processor, a Graphics Processor (GPU), an Image Signal Processor (ISP), a controller, a memory, a video codec, a Digital Signal Processor (DSP), a baseband Processor, and/or a Neural-Network Processing Unit (NPU), and the like. The different processing units may be separate devices or may be integrated into one or more processors. The controller may be, among other things, a neural hub and a command center of the user device 100. The controller can generate an operation control signal according to the instruction operation code and the timing signal to complete the control of instruction fetching and instruction execution. A memory may also be provided in processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may hold instructions or data that have just been used or recycled by the processor 110. If the processor 110 needs to reuse the instruction or data, it can be called directly from the memory, avoiding repeated accesses, reducing the latency of the processor 110, and thus increasing the efficiency of the system.
In some embodiments, processor 110 may include one or more interfaces. The Interface may include an Integrated Circuit (I2C) Interface, an Inter-Integrated Circuit built-in audio (I2S) Interface, a Pulse Code Modulation (PCM) Interface, a Universal Asynchronous Receiver Transmitter (UART) Interface, a Mobile Industry Processor Interface (MIPI), a General-purpose input/Output (GPIO) Interface, a Subscriber Identity Module (SIM) Interface, and/or a Universal Serial Bus (USB) Interface, etc. The I2C interface is a bidirectional synchronous Serial bus including a Serial Data Line (SDA) and a Serial Clock Line (SCL). In some embodiments, processor 110 may include multiple sets of I2C buses. The processor 110 may be coupled to a charger, a flash, etc. through different I2C bus interfaces, respectively.
The USB interface 130 is an interface conforming to the USB standard specification, and may specifically be a Mini USB interface, a Micro USB interface, a USB Type C interface, or the like. The USB interface 130 may be used to connect a charger to charge the user equipment 100, and may also be used to transmit data between the user equipment 100 and peripheral devices. And the earphone can also be used for connecting an earphone and playing audio through the earphone. The interface may also be used to connect other user devices, such as AR devices and the like. It should be understood that the interfacing relationship between the modules illustrated in the embodiment of the present application is only an exemplary illustration, and does not constitute a structural limitation for the user equipment 100. In other embodiments of the present application, the user equipment 100 may also adopt different interface connection manners or a combination of multiple interface connection manners in the above embodiments.
The charging management module 140 is configured to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger via the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive a wireless charging input through a wireless charging coil of the user device 100. The charging management module 140 may also supply power to the user device through the power management module 141 while charging the battery 142. The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and/or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the external memory, the display 194, the wireless communication module 160, and the like. The power management module 141 may also be used to monitor parameters such as battery capacity, battery cycle count, and battery state of health (including leakage and impedance). In some other embodiments, the power management module 141 may also be disposed in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may be disposed in the same device.
The wireless communication function of the user equipment 100 may be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, a modem processor, a baseband processor, and the like. The antennas 1 and 2 are used for transmitting and receiving electromagnetic wave signals. Each antenna in the user equipment 100 may be used to cover a single or multiple communication bands. Different antennas can also be multiplexed to improve the utilization of the antennas. For example: the antenna 1 may be multiplexed as a diversity antenna of a wireless local area network. In other embodiments, the antenna may be used in conjunction with a tuning switch. The mobile communication module 150 may provide a solution including 2G/3G/4G/5G wireless communication applied on the user equipment 100. The mobile communication module 150 may include at least one filter, a switch, a power Amplifier, a Low Noise Amplifier (LNA), and the like. The mobile communication module 150 may receive the electromagnetic wave from the antenna 1, filter, amplify, etc. the received electromagnetic wave, and transmit the electromagnetic wave to the modem processor for demodulation. The mobile communication module 150 may also amplify the signal modulated by the modem processor, and convert the signal into electromagnetic wave through the antenna 1 to radiate the electromagnetic wave. In some embodiments, at least some of the functional modules of the mobile communication module 150 may be disposed in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 may be disposed in the same device as at least some of the modules of the processor 110. The modem processor may include a modulator and a demodulator. The modulator is used for modulating a low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used for demodulating the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then passes the demodulated low frequency baseband signal to a baseband processor for processing. The low frequency baseband signal is processed by the baseband processor and then transferred to the application processor. The application processor displays images or video via the display screen 194. In some embodiments, the modem processor may be a stand-alone device. In other embodiments, the modem processor may be provided in the same device as the mobile communication module 150 or other functional modules, independent of the processor 110.
The Wireless Communication module 160 may provide a solution for Wireless Communication applied to the user equipment 100, including Wireless Local Area Networks (WLANs) (e.g., Wireless Fidelity (Wi-Fi) network), Bluetooth (BT), Global Navigation Satellite System (GNSS), Frequency Modulation (FM), Near Field Communication (NFC), Infrared (IR), and the like. The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, performs frequency modulation and filtering processing on electromagnetic wave signals, and transmits the processed signals to the processor 110. The wireless communication module 160 may also receive a signal to be transmitted from the processor 110, frequency-modulate and amplify the signal, and convert the signal into electromagnetic waves via the antenna 2 to radiate the electromagnetic waves.
In some embodiments, antenna 1 of user equipment 100 is coupled to mobile communication module 150 and antenna 2 is coupled to wireless communication module 160 so that user equipment 100 can communicate with networks and other devices through wireless communication techniques. The wireless communication technology may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time-Division Multiple Access (TDSCDMA), Long Term Evolution (Long Term Evolution, LTE), BT, GNSS, WLAN, NFC, FM, and/or IR technologies, etc. The GNSS may include a Global Positioning System (GPS), a Global Navigation Satellite System (GLONASS), a beidou Navigation Satellite System (BDS), a Quasi-Zenith Satellite System (QZSS), and/or a Satellite Based Augmentation System (SBAS).
The user device 100 implements display functions via the GPU, the display screen 194, and the application processor. The GPU is a microprocessor for image processing, and is connected to the display screen 194 and an application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or alter display information. The display screen 194 is used to display images, videos, and the like. The Display screen 194 includes a Display panel, and the Display panel may adopt a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), an Active Matrix Organic Light-Emitting Diode (Active-Matrix Organic Light-Emitting Diode, AMOLED), a flexible Light-Emitting Diode (FLED), a Mini LED, a Micro OLED, a Quantum Dot Light-Emitting Diode (QLED), or the like. In some embodiments, the user device 100 may include 1 or N display screens 194, with N being a positive integer greater than 1.
Based on the user equipment 100 shown in fig. 1, in order to reduce the size of the memory required for loading the image onto the memory without affecting the user experience, please refer to fig. 2, and fig. 2 is a flowchart illustrating an image compression method according to an embodiment of the present disclosure. The image compression method may include:
and S200, acquiring image data of an image to be compressed.
It is understood that different formats of images, having α channels, are different, each pixel containing three channels of color information-red, green and blue, each channel containing 8 bits of color depth in a 24-bit image, taking a true color bitmap as an example, if the graphics card has a 32-bit bus, an additional 8-bit signal is used to hold an invisible transparency signal for processing, white α pixels are used to define opaque color pixels, black α pixels are used to define transparent pixels, and a gray scale between black and white is used to define translucent pixels, which is α channels.
S201, removing all α channel data of the image to be compressed according to the image data to obtain intermediate data.
It can be understood that, first, the image data of the image to be compressed is determined, where the image data includes α channels of the image to be compressed, and according to the α channels and other related image data, all α channels of the image to be compressed are removed to obtain intermediate data, where the intermediate data includes remaining Red, Green, and Blue (RGB) image data.
S202, acquiring a target compressed image obtained after the intermediate data is compressed.
It can be understood that the intermediate data is the content in the image to be compressed remaining after the α channel data is deleted, and in order to improve the viewing effect of the compressed image, the intermediate data needs to be compressed so as to obtain the final target compressed image.
For example, under the condition that the memory size occupied by the image to be compressed is 10MB and the quality of a target compressed image is the same, the image can be compressed to 5MB by using the prior art, the memory size occupied by the target compressed image can be obviously reduced by using the image compression method of the application, under the condition that the memory occupied by the target compressed image is 10MB, the α channel is obtained by compression by using the prior art, the target compressed image obtained by using the image compression method of the application does not have α channel, 10MB can store more image data, the image quality is obviously improved, and the condition that the memory overflow of user equipment can be effectively avoided under the condition that the size of the current generation compressed image is determined.
To facilitate understanding of the image compression method in the foregoing embodiment, taking the user equipment 100 shown in fig. 1 as a mobile phone as an example, please refer to fig. 3, and fig. 3 is a schematic diagram illustrating an image compression algorithm according to an embodiment of the present application. Taking the example that the user equipment 100 (mobile phone) operates under the Android platform, the user equipment includes a Java service layer, a Java Native Interface (JNI), and a C + + layer, where the C + + layer may include any image compression method provided in the present application. When the image needs to be compressed, the Java service layer can call an image compression algorithm in the C + + layer through the JNI interface so as to realize any image compression method in the application; for example, when the image to be compressed is in JPEG format, the image compression method may be implemented based on Lib JPEG compression.
In an optional embodiment, in order to implement compression processing on intermediate data, on the basis of fig. 2, taking the example that image data further includes width information and height information, please refer to fig. 4, and fig. 4 is a schematic flow chart of another image compression method provided in this embodiment of the present application. The above S202 may include:
and S2021, acquiring pixel information of the target compressed image according to the height information and the width information.
The pixel information includes the number of pixels of the target compressed image and the position information of each pixel. It can be understood that, the pixel information of the target compressed image is determined according to the original height and width information of the image to be compressed, so that the compression distortion rate can be effectively reduced, and the influence on the image viewing experience of a user due to the serious distortion of the height and width information of the original image (the image to be compressed) and the target compressed image is avoided.
S2022, performing Huffman calculation on the intermediate data to obtain a Huffman coding tree corresponding to each pixel point.
S2023, recoding the intermediate data according to the Huffman coding trees of all the pixel points to obtain a target compressed image.
It should be understood that the huffman calculation is performed on the intermediate data obtained after the α channel data in the image to be compressed are removed, the huffman coding tree corresponding to each pixel point is obtained, the RGB data corresponding to each pixel point can be effectively re-encoded, the browsing quality of the target compressed image is improved, and meanwhile, the compression ratio of the target compressed image is considered.
In an alternative embodiment, in order to determine the relevant parameters of the target compressed image, please refer to fig. 5, where S2021 shown in fig. 4 is a possible implementation manner, and fig. 5 is a schematic flowchart of another image compression method provided in this embodiment of the present application. The above S2021 may include:
s2021a, acquiring target compression parameters of the image to be compressed according to the height information and the width information.
The target compression parameters may include a target width and a target height. Taking an image to be compressed as a JPEG format as an example, a JPEG compression structure object may be created according to the Height information and the Width information of the image to be compressed, and compression related parameters (i.e. target compression parameters, such as Width, Height, In Color Space, Input components, etc.) may be determined; it should be understood that the target compression parameter may be obtained by processing the height and width of the image to be compressed through a preset condition, or may be set by a user through customization.
S2021b, determining pixel information according to the target compression parameter.
As can be understood, the pixel information of the target compressed image, including the number and position of pixel points, can be determined by the target width and the target height in the target compression parameters; the target compression parameters may also include information such as the number of color channels, color space, compression quality, etc., which may determine other relevant information of the target compressed image.
It should be understood that by determining the compression parameters and pixel information of the target compressed image, the quality of the target compressed image can be improved, and the problem of loading distortion can be reduced, so that the compression rate and other related parameters of the target compressed image meet some special project requirements.
In an alternative embodiment, in order to improve the efficiency of image compression, a possible implementation is given on the basis of fig. 4, please refer to fig. 6, and fig. 6 is a schematic flow chart of another image compression method provided in this embodiment of the present application. Prior to S2021, S202 may further include:
and S2020, storing the intermediate data into a memory space matched with the width information and the height information.
For example, a temporary pointer may be created that may point to a memory space that matches the width and height information of the image to be compressed, which may be, but is not limited to, a cache space in a cache or cloud, etc. It should be appreciated that when storing intermediate data, the intermediate data may be stored in an order to improve the efficiency of image compression, such as in an order of different dimensions like time series, height series, width series, etc.
Accordingly, the above S2022 may include:
s2022a, scanning intermediate data in the memory space, and acquiring a Huffman coding tree corresponding to each pixel point.
For example, the image compression related module may scan intermediate data in a memory space (a cache or a cloud cache space) to obtain a huffman code tree of each pixel.
It should be understood that by setting a memory space to store the intermediate data, the one-stop processing of image compression in the prior art is avoided, and the image compression efficiency can be effectively improved. It is foreseeable that after the image compression process is completed each time, the intermediate data of the last image compression in the memory space may be deleted, so as to improve the utilization rate of the storage space of the user equipment or the cloud.
In an alternative embodiment, in order to generate a target compressed image, a possible implementation is given on the basis of fig. 4, please refer to fig. 7, and fig. 7 is a flowchart illustrating another image compression method provided in an embodiment of the present application. The above S2023 may include:
s2023a, recoding the intermediate data according to the Huffman coding tree of all the pixel points to obtain compressed data.
The compressed data includes image data of the target compressed image and image parameter information.
S2023b, reading the compressed data to generate a target compressed image.
It can be understood that each line of data of the compressed data needs to be read, including image data (RGB data of each pixel point) and image parameter information (such as size information of the target compressed image), so as to generate the target compressed image, so as to improve the consistency between the target compressed image and the image to be compressed, and reduce distortion. It is foreseeable that the generated target compressed image may be stored in a memory of the user equipment, or may be sent to an external memory or a cloud terminal through a corresponding communication module or an external memory interface, where the storage location of the generated target compressed image is not limited in the present application.
To implement any of the image compression methods described above, an image compression apparatus is provided in an embodiment of the present application, please refer to fig. 8, and fig. 8 is a block diagram of an image compression apparatus provided in an embodiment of the present application. The image compression apparatus 40 includes: a processing module 41 and a compression module 42.
The processing module 41 is used for acquiring image data of an image to be compressed, the image data comprises α channel information of the image to be compressed, α channel information is used for determining α channel number of the image to be compressed, and the processing module 41 is further used for removing all α channel data of the image to be compressed according to the image data to acquire intermediate data.
The compression module 42 is used for acquiring a target compressed image after compressing the intermediate data.
It is to be understood that the processing module 41 may implement S200 and S201 described above, and the compression module 42 may implement S202 described above.
In an alternative embodiment, in order to implement compression of an image, taking as an example that image data further includes width information and height information: the compression module 42 is further configured to obtain pixel information of the target compressed image according to the height information and the width information; the pixel information includes the number of pixels of the target compressed image and the position information of each pixel. The compression module 42 is further configured to perform huffman calculation on the intermediate data to obtain a huffman coding tree corresponding to each pixel point. The compression module 42 is further configured to re-encode the intermediate data according to the huffman coding tree of all the pixel points to obtain a target compressed image. It should be understood that compression module 42 may also implement S2021-S2023 described above.
In an optional embodiment, to implement compression on the image, the compression module 42 is further configured to re-encode the intermediate data according to the huffman coding trees of all the pixel points to obtain compressed data; the compressed data comprises image data of a target compressed image and image parameter information; the compression module 42 is also used to read the compressed data to generate a target compressed image. It should be appreciated that compression module 42 may implement S2023a and S2023b described above.
It is understood that the processing module 41 and the compression module 42 may cooperate to implement the relevant steps of any of the image compression methods described above.
Embodiments of the present application further provide a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the image compression method according to any one of the foregoing embodiments. The computer readable storage medium may be, but is not limited to, various media that can store program codes, such as a U disk, a removable hard disk, a ROM, a RAM, a PROM, an EPROM, an EEPROM, a magnetic or optical disk, etc.
In summary, the image compression method is applied to user equipment and comprises the steps of obtaining image data of an image to be compressed, wherein the image data comprises α channel information of the image to be compressed, α channel information is used for determining α channel number of the image to be compressed, removing all α channel data of the image to be compressed according to the image data to obtain intermediate data, obtaining a target compressed image after the intermediate data is compressed, performing image compression by using the image compression method provided by the application, deleting α channel data in the image to be compressed, reducing the memory size occupied by the compressed image under the condition of not influencing user experience, and improving the compression rate of the image.
The above description is only for various embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of changes or substitutions within the technical scope of the present application, and all such changes or substitutions are included in the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. An image compression method applied to a user equipment, the method comprising:
the method comprises the steps of obtaining image data of an image to be compressed, wherein the image data comprises α channel information of the image to be compressed, and the α channel information is used for determining α channel number of the image to be compressed;
removing all α channel data of the image to be compressed according to the image data to obtain intermediate data;
and acquiring a target compressed image obtained after the intermediate data is compressed.
2. The method according to claim 1, wherein the image data further includes width information and height information, and the obtaining of the target compressed image after the intermediate data compression processing includes:
acquiring pixel information of the target compressed image according to the height information and the width information; the pixel information comprises the number of pixel points of the target compressed image and the position information of each pixel point;
performing Huffman calculation on the intermediate data to obtain a Huffman coding tree corresponding to each pixel point;
and recoding the intermediate data according to the Huffman coding trees of all the pixel points to obtain the target compressed image.
3. The method according to claim 2, wherein the obtaining pixel information of the target compressed image according to the height information and the width information comprises:
acquiring target compression parameters of the image to be compressed according to the height information and the width information; the target compression parameters comprise a target width and a target height;
and determining the pixel information according to the target compression parameter.
4. The method according to claim 2 or 3, wherein the obtaining of the target compressed image after the intermediate data compression processing is performed before the obtaining of the pixel information of the target compressed image according to the height information and the width information, further comprises:
storing the intermediate data to a memory space matched with the width information and the height information;
the performing huffman calculation on the intermediate data to obtain the huffman coding tree corresponding to each pixel point includes:
and scanning the intermediate data in the memory space to obtain the Huffman coding tree corresponding to each pixel point.
5. The method of claim 2, wherein said re-encoding said intermediate data according to said huffman code tree of all said pixel points to obtain a target compressed image comprises:
recoding the intermediate data according to the Huffman coding trees of all the pixel points to obtain compressed data; the compressed data comprises image data of the target compressed image and image parameter information;
reading the compressed data to generate the target compressed image.
6. An image compression apparatus, comprising: a processing module and a compression module;
the processing module is used for acquiring image data of an image to be compressed, wherein the image data comprises α channel information of the image to be compressed, and the α channel information is used for determining α channel number of the image to be compressed;
the processing module is further used for removing all α channel data of the image to be compressed according to the image data to obtain intermediate data;
and the compression module is used for acquiring a target compressed image obtained by compressing the intermediate data.
7. The apparatus of claim 6, wherein the image data further comprises width information and height information; the compression module is further used for acquiring pixel information of the target compressed image according to the height information and the width information; the pixel information comprises the number of pixel points of the target compressed image and the position information of each pixel point;
the compression module is further used for performing Huffman calculation on the intermediate data to obtain a Huffman coding tree corresponding to each pixel point;
and the compression module is also used for recoding the intermediate data according to the Huffman coding trees of all the pixel points to acquire the target compressed image.
8. The apparatus of claim 7, wherein the compression module is further configured to re-encode the intermediate data according to the Huffman coding trees of all the pixel points to obtain compressed data; the compressed data comprises image data of the target compressed image and image parameter information;
the compression module is further configured to read the compressed data to generate the target compressed image.
9. A user device comprising a processor and a memory, the memory storing machine executable instructions executable by the processor to implement the image compression method of any one of claims 1 to 5.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the image compression method according to any one of claims 1 to 5.
CN202010000679.XA 2020-01-02 2020-01-02 Image compression method, device, user equipment and computer readable storage medium Pending CN111147861A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010000679.XA CN111147861A (en) 2020-01-02 2020-01-02 Image compression method, device, user equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010000679.XA CN111147861A (en) 2020-01-02 2020-01-02 Image compression method, device, user equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN111147861A true CN111147861A (en) 2020-05-12

Family

ID=70523251

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010000679.XA Pending CN111147861A (en) 2020-01-02 2020-01-02 Image compression method, device, user equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN111147861A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112565771A (en) * 2020-11-30 2021-03-26 上海博泰悦臻电子设备制造有限公司 Picture compression method and device, electronic equipment and medium
CN112929621A (en) * 2021-01-20 2021-06-08 深圳市瑞驰信息技术有限公司 Method for improving image compression transmission based on Huffman algorithm
CN112565771B (en) * 2020-11-30 2024-08-02 博泰车联网科技(上海)股份有限公司 Picture compression method and device, electronic equipment and medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100253556A1 (en) * 2009-04-06 2010-10-07 International Business Machines Corporation Method of constructing an approximated dynamic huffman table for use in data compression
CN107330947A (en) * 2017-06-29 2017-11-07 厦门游亨世纪科技有限公司 A kind of Memory Optimize Method of video cartoon picture storage
CN107968923A (en) * 2017-11-30 2018-04-27 腾讯科技(深圳)有限公司 A kind of image processing method, device, computing device and storage medium
CN108419086A (en) * 2018-05-08 2018-08-17 北京理工大学 A kind of method for compressing image based on huffman coding
CN110008192A (en) * 2019-04-12 2019-07-12 苏州浪潮智能科技有限公司 A kind of data file compression method, apparatus, equipment and readable storage medium storing program for executing
CN110443873A (en) * 2019-08-12 2019-11-12 苏州悠优互娱文化传媒有限公司 A kind of children's book equipped AR scene shows method, apparatus, storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100253556A1 (en) * 2009-04-06 2010-10-07 International Business Machines Corporation Method of constructing an approximated dynamic huffman table for use in data compression
CN107330947A (en) * 2017-06-29 2017-11-07 厦门游亨世纪科技有限公司 A kind of Memory Optimize Method of video cartoon picture storage
CN107968923A (en) * 2017-11-30 2018-04-27 腾讯科技(深圳)有限公司 A kind of image processing method, device, computing device and storage medium
CN108419086A (en) * 2018-05-08 2018-08-17 北京理工大学 A kind of method for compressing image based on huffman coding
CN110008192A (en) * 2019-04-12 2019-07-12 苏州浪潮智能科技有限公司 A kind of data file compression method, apparatus, equipment and readable storage medium storing program for executing
CN110443873A (en) * 2019-08-12 2019-11-12 苏州悠优互娱文化传媒有限公司 A kind of children's book equipped AR scene shows method, apparatus, storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112565771A (en) * 2020-11-30 2021-03-26 上海博泰悦臻电子设备制造有限公司 Picture compression method and device, electronic equipment and medium
CN112565771B (en) * 2020-11-30 2024-08-02 博泰车联网科技(上海)股份有限公司 Picture compression method and device, electronic equipment and medium
CN112929621A (en) * 2021-01-20 2021-06-08 深圳市瑞驰信息技术有限公司 Method for improving image compression transmission based on Huffman algorithm

Similar Documents

Publication Publication Date Title
EP3836021B1 (en) Ai model development method and device
CN113126939B (en) Display method, display control device, display and electronic equipment
CN114466134A (en) Method and electronic device for generating HDR image
CN114327312B (en) Screen throwing control method and device
CN113473013A (en) Display method and device for beautifying effect of image and terminal equipment
CN111147861A (en) Image compression method, device, user equipment and computer readable storage medium
CN114461375A (en) Memory resource management method and electronic equipment
CN116723415B (en) Thumbnail generation method and terminal equipment
CN115546858B (en) Face image processing method and electronic equipment
CN113810622B (en) Image processing method and device
CN115460343B (en) Image processing method, device and storage medium
EP4261739A1 (en) Qr code generation method and related device
CN111111188B (en) Game sound effect control method and related device
CN115113716A (en) Method for adjusting display parameters of information screen and terminal equipment
CN113099734B (en) Antenna switching method and device
CN115499900A (en) Link establishment method, electronic device and storage medium
CN114793283A (en) Image encoding method, image decoding method, terminal device, and readable storage medium
CN113421209B (en) Image processing method, system on chip, electronic device, and medium
CN111626931A (en) Image processing method, image processing apparatus, storage medium, and electronic device
CN117130765B (en) Configuration method of computing resources and electronic equipment
CN114845297B (en) Application program access method, electronic device and storage medium
EP4293539A1 (en) Webpage display method, device, and system
CN114449492B (en) Data transmission method and terminal equipment
CN113127072B (en) Method for controlling display of electronic equipment and display control device
CN117670646A (en) Application interface display method and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20200512