Disclosure of Invention
The following disclosure is illustrative only and is not intended to be limiting in any way. In addition to the illustrative aspects, embodiments, and features, other aspects, embodiments, and features will be apparent by reference to the drawings and the following detailed description. That is, the following disclosure is provided to introduce concepts, points, benefits and novel and non-obvious technical advantages described herein. Selected, but not all embodiments are described in further detail below. Accordingly, the following disclosure is not intended to identify essential features of the claimed subject matter, nor is it intended to be used in determining the scope of the claimed subject matter.
It is therefore a primary objective of the claimed invention to provide a method and apparatus for image compression to overcome the above-mentioned shortcomings.
In a preferred embodiment, the present invention provides a method of image compression, comprising: receiving an image; dividing the image into a plurality of blocks (blocks) with a fixed size, wherein each pixel in each Block is defined by three color channel values; obtaining a reconstructed value of a first color channel value of the three color channels of each pixel in each block according to a first quantization level; obtaining a first data difference between the reconstructed value of the first color channel value in each pixel and a second color channel value of the three color channel values, and a second data difference between the reconstructed value of the first color channel value in each pixel and a third color channel value of the three color channels; and performing compression coding and transmission on the reconstruction value, the first data difference value and the second data difference value in each block.
In some embodiments, the above-mentioned reconstructed value is generated according to the following formula:
Precon=Pmin+m×(Pmax-Pmin)/(2 n -1)
wherein Precon is the reconstructed value of the first color channel, pmin is the minimum value of the first color channel in a block, pmax is the maximum value of the first color channel in the block, 2 n For the purpose of the first quantization level described above,and m is an index value ranging from 0 to 2 n -an integer of 1.
In some embodiments, the first quantization level in each block is a fixed value.
In some embodiments, the first quantization level in each block is determined according to a minimum value of the first color channel in the block and a maximum value of the first color channel in the block.
In some embodiments, the method further comprises: grouping the values of the reconstruction values in each block; assigning an index value to each group in addition to the maximum and minimum values of the reconstructed values; and performing compression encoding and transmission on the maximum value, the minimum value, the index value, the first data difference value and the second data difference value of the reconstruction value in each block.
In some embodiments, the three color channels are red (R), green (G), and blue (B) channels.
In a preferred embodiment, the present invention provides an apparatus for image compression, comprising: one or more processors; and one or more computer storage media storing computer-readable instructions, wherein the processor uses the computer storage media to perform: receiving an image; dividing the image into a plurality of blocks (blocks) with a fixed size, wherein each pixel in each Block is defined by three color channel values; obtaining a reconstructed value of a first color channel value of the three color channels of each pixel in each block according to a first quantization level; obtaining a first data difference between the reconstructed value of the first color channel value in each pixel and a second color channel value of the three color channel values, and a second data difference between the reconstructed value of the first color channel value in each pixel and a third color channel value of the three color channels; and performing compression coding and transmission on the reconstruction value, the first data difference value and the second data difference value in each block.
Detailed Description
Aspects of the present disclosure are described more fully hereinafter with reference to the accompanying drawings. This disclosure may, however, be embodied in many different forms and should not be construed as limited to any specific structure or function presented throughout this disclosure. Rather, these aspects are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art. Based on the teachings herein one skilled in the art should appreciate that the scope of the present disclosure is intended to encompass any aspect disclosed herein, whether alone or in combination with any other aspect of the present disclosure to achieve any aspect disclosed herein. For example, any number of apparatus or methods of execution may be implemented as set forth herein. In addition, the scope of the present disclosure is intended to cover apparatuses or methods implemented using other structure, functionality, or structure and functionality in addition to or other than the aspects of the present disclosure set forth herein. It is to be understood that any aspect disclosed herein may be embodied by one or more components of a claim.
The word "exemplary" is used herein to mean "serving as an example, instance, or illustration. Any aspect of the present disclosure or design described herein as "exemplary" is not necessarily to be construed as preferred or advantageous over other aspects of the present disclosure or design. Moreover, like numerals refer to like elements throughout the several views, and the articles "a" and "an" comprise multiple references unless otherwise specified in the description.
It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may be present. In contrast, when an element is referred to as being "directly connected" or "directly coupled" to another element, there are no intervening elements present. Other words used to describe the relationship between components should be interpreted in a similar manner (e.g., "between 823030; and" directly between 8230; and "adjacent" and "directly adjacent" etc.).
FIG. 1 shows a flow diagram of a method 100 of image compression according to an embodiment of the invention. This method 100 may be implemented in an electronic device, wherein the types of electronic devices range from small handheld devices (e.g., mobile phones/portable computers) to large mainframe systems (e.g., mainframe computers). Examples of portable computers include Personal Digital Assistants (PDAs), notebook computers, and the like.
In step S105, the electronic device can receive an image, wherein the image is to be compressed. In one embodiment, the image to be compressed may be an image to be uploaded to another terminal device. Before uploading the image to other terminal devices, the image compression method provided by the embodiment is used for compression, so that the network traffic resource required by uploading the image is reduced, and meanwhile, the storage burden of other terminal devices is also reduced. In another embodiment, the image to be compressed may be an image stored locally in the electronic device, and after the image is compressed by using the image compression method provided in this embodiment, the local storage load of the electronic device is reduced.
In step S110, the electronic device divides the image into a plurality of blocks (blocks) with a fixed size, wherein each pixel in each Block is defined by three color channel values. The three color channels are red (R), green (G) and blue (B) channels, respectively. The color channel values may be represented by numbers within a range of values, for example, the color channel values of the colors red (R), green (G), and blue (B) are represented by 0 to 255. Thus, the color channel value of each pixel can be directly obtained, for example, if the color of a pixel is (120; the color channel value for green is 25; the color channel value for blue is 255.
In step S115, the electronic device obtains a reconstruction value of a first color channel value of the three color channels of each pixel in each block according to a first quantization level, wherein the reconstruction value is generated according to the following formula (1):
Precon=Pmin+m×(Pmax-Pmin)/(2 n -1) (1)
where Precon is the reconstructed value of the first color channel, pmin is the minimum value of the first color channel in a block, pmax is the maximum value of the first color channel in the block, and 2 n Is a first quantization level, and m is an index value ranging from 0 to 2 n -an integer of 1. In one embodiment, n can be preset by a user. Clearly, if n is larger, it indicates a finer division between the first color channel minimum and maximum, the error is smaller.
In step S120, the electronic device obtains a first data difference between the reconstructed value of the first color channel value in each pixel and a second color channel value of the three color channel values, and a second data difference between the reconstructed value of the first color channel value in each pixel and a third color channel value of the three color channels.
In step S125, the electronic device performs compression encoding and transmission on the reconstructed value, the first data difference value and the second data difference value in each block.
In an embodiment, in each block of an image, a first quantization level used for reconstructing the reconstruction value of the first color channel may be a first fixed value, and a second quantization level used for reconstructing the first data difference value and the second data difference value may be a second fixed value. For example, assume that an image is an image having 1920 × 1080 pixels. The electronics divide the image into a plurality of blocks having a fixed size of 8 x 2 pixels. FIG. 2 is a diagram illustrating a trend of color channel variation of a block having 8 × 2 pixels according to an embodiment of the present invention.
As can be seen from FIG. 2, there is a strong dependency between the three color channels of this block. The color channel values for each pixel of this block are shown in Table 1.
Table 1
Assume that the first color channel is a red (R) channel, the second color channel is a green (G) channel, and the third color channel is a blue (B) channel. The first quantization level of the reconstructed value for reconstructing the red (R) channel is 32. The reconstructed value Rrecon for the red (R) channel can be obtained by equation (1). A first data difference (Rrecon-G) between the reconstruction value Rrecon and the green (G) channel value of each pixel of the block and a second data difference (Rrecon-B) between the reconstruction value Rrecon and the blue (B) channel value are obtained by utilizing the reconstruction value Rrecon. The reconstructed values Rrecon, the first data difference values (Rrecon-G) and the second data difference values (Rrecon-B) are shown in table 2.
Table 2
As shown in Table 2, the first data difference value (Rrecon-G) and the second data difference value (Rrecon-B) have only one value, 11 and 15. Assume that the second quantization level used to reconstruct the first data difference value (Rrecon-G) and the second data difference value (Rrecon-B) is 4. Obviously, since the first data difference value (Rrecon-G) and the second data difference value (Rrecon-B) both have only one value, and the number of values is less than the second quantization level 4, the green (G) channel value and the blue (B) channel value can also be reconstructed without loss.
Table 3 shows the data structure of the encoded information in this example, as follows.
Table 3
Where Rmin represents the minimum value of the red (R) channel value and Rmax represents the maximum value of the red (R) channel value. The R quantization level indicates a quantization level used for red (R) channel reconstruction values. (Rrecon-G) min represents the minimum value of the first data difference value between the red (R) channel reconstruction value and the green (G) channel value. (Rrecon-G) max represents the maximum value of the first data difference between the red (R) channel reconstruction value and the green (G) channel value. The (Rrecon-G) quantization level represents a quantization level of the first data difference value between the red (R) channel reconstruction value and the green (G) channel value. The definition of Rrecon-B on the right of Table 3 is consistent with the representation of Rrecon-G, and is not repeated herein. As shown in table 3, the block originally has to use 384 bits (bits) for compression encoding, and in this way, the block can be compressed and encoded only by using 192 bits (bits), which improves the compression rate.
In another embodiment, in each block of an image, a first quantization level for reconstructing the reconstructed value of the first color channel may be determined according to a minimum value of the first color channel and a maximum value of the first color channel. Similarly, a second quantization level for reconstructing the first data difference value may be determined according to a minimum value of the first data difference value and a maximum value of the first data difference value; a third quantization level for reconstructing the second data difference value may be determined based on a minimum value of the second data difference value and a maximum value of the second data difference value.
As an example, if the number of different values in the first color channel value is less than or equal to 2, the first quantization level is selected to be 2; if the number of different values in the first color channel value is larger than 2, the difference value (Pmax-Pmin) between the maximum value and the minimum value of the first color channel is determined. When the difference value between the maximum value and the minimum value of the first color channel is less than or equal to 3 (Pmax-Pmin < = 3), selecting a first quantization level as 4; when the difference value of the maximum value and the minimum value of the first color channel is less than or equal to 7 (Pmax-Pmin < = 7), selecting the first quantization level as 8; when the difference value between the maximum value and the minimum value of the first color channel is less than or equal to 15 (Pmax-Pmin < = 15), selecting a first quantization level as 16; when the difference between the maximum value and the minimum value of the first color channel is less than or equal to 31 (Pmax-Pmin < = 31), the first quantization level is selected to be 32. Obviously, the fewer the color channel quantization levels of the pixels processed first, the fewer the number of coded bits (bits) and possibly different numbers of coded bits per block. Therefore, more bits can be reserved for the subsequent color channels, and more levels can be divided.
In yet another embodiment, in each block of an image, the electronic device may group the values of the reconstructed values in each block after obtaining the reconstructed values of the first color channel values in each pixel. Then, the electronic device assigns an index value to each group in addition to the maximum value and the minimum value of the reconstruction values. Finally, the electronic device performs compression coding and transmission on the maximum value, the minimum value, the index value, the first data difference value and the second data difference value of the reconstruction value in each block.
For example, assuming that the first color channel has 8 different reconstruction values, the electronic device groups the reconstruction values according to the different values, and assigns an index value to each group except for the maximum value and the minimum value of the reconstruction values. In this example, the electronic device needs 5 × 6=30 bits to reconstruct the remaining 6 values, in addition to the maximum and minimum values of the reconstructed values. Since the electronic device may use 3 bits to represent the index for each group, the electronic device only needs to use 16 x 3 bits to represent the index in a block.
As described above, the present invention statistically analyzes data in an image in units of blocks. Because more information redundancies exist among the color channels in the block, the invention fully utilizes the information redundancies among the color channels to compress the image. A first color channel is used as a reference channel, more bits are distributed to ensure that the first color channel has higher compression quality, and then the difference value between the color channels is coded by using less bits by utilizing the dependency between the color channels. Compared with the traditional compression method, the method provided by the invention can better compress the information redundancy among the color channels and has better compression quality guarantee.
With respect to the described embodiments of the present invention, an exemplary operating environment in which embodiments of the present invention may be implemented is described below. With specific reference to FIG. 3, FIG. 3 illustrates an exemplary operating environment for implementing embodiments of the present invention, which may generally be referred to as an electronic device 300. The electronic device 300 is only one example of a suitable computing environment and is not intended to suggest any limitation as to the scope of use or functionality of the invention. Neither should the electronic device 300 be interpreted as having any dependency or requirement relating to any one or combination of components illustrated.
The present invention may be implemented in computer program code or machine-useable instructions, such as computer-executable instructions of program modules, executed by a computer or other machine, such as a personal digital assistant or other portable device. Generally, program modules include routines, programs, objects, components, data structures, etc., and refer to program code that performs particular tasks or implements particular abstract data types. The invention may be implemented in a variety of system configurations, including portable devices, consumer electronics, general-purpose computers, more specialty computing devices, and the like. The invention may also be practiced in distributed computing environments where devices that are linked through a communications network are processed.
Refer to fig. 3. The electronic device 300 includes a bus 310, a memory 312, one or more processors 314, one or more display components 316, input/output (I/O) ports 318, input/output (I/O) components 320, and an illustrative power supply 322 that directly or indirectly couple the following devices. Bus 310 represents what may be one or more busses (such as an address bus, data bus, or combination thereof). Although the various blocks of FIG. 3 are shown with lines for the sake of brevity, in practice, the boundaries of the various components are not specific, e.g., the presentation component of the display device may be considered to be an I/O component; the processor may have a memory.
Electronic device 300 typically includes a variety of computer-readable media. Computer readable media can be any available media that can be accessed by electronic device 300 and includes both volatile and nonvolatile media, removable and non-removable media. By way of example, and not limitation, computer readable media may comprise computer storage media and communication media. Computer-readable media include both volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer-readable instructions, data structures, program modules or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital Versatile Disks (DVD) or other optical disk storage, magnetic disks, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by electronic device 300. Computer storage media itself does not include signals.
Communication media typically embodies computer readable instructions, data structures, program modules or other data in a modular data signal such as a carrier wave or other transport mechanism and includes any information delivery media. The term "modular data signal" refers to a signal that has one or more sets of characteristics or is otherwise altered in such a manner as to encode information in the signal. By way of example, and not limitation, communication media includes wired media such as a wired network or direct-wired connection, and wireless media such as audio, radio frequency, infrared and other wireless media. Combinations of the above are included within the scope of computer-readable media.
Memory 312 includes computer storage media in the form of volatile and nonvolatile memory. The memory may be removable, non-removable, or a combination of the two. Exemplary hardware devices include solid state memory, hard disk drives, optical disk drives, and the like. Electronic device 300 includes one or more processors that read data from entities such as memory 312 or I/O components 320. The display component 316 displays data indications to a user or other device. Exemplary display components include a display device, speakers, a printing component, a vibrating component, and the like.
The I/O ports 318 allow the electronic device 300 to be logically connected to other devices including I/O components 320, some of which are built-in devices. Exemplary components include a microphone, joystick, game pad, satellite dish signal receiver, scanner, printer, wireless device, and the like. The I/O component 320 may provide a natural user interface for processing user-generated gestures, sounds, or other physiological inputs. In some examples, these inputs may be transmitted to a suitable network component for further processing. The NUI may implement any combination of language recognition, touch and stylus recognition, facial recognition, biometric recognition, gesture recognition on and near the screen, air gestures, head and eye tracking, and touch recognition associated with display by the electronic device 300. The electronic device 300 may be equipped with a depth camera, such as a stereo camera system, an infrared camera system, an RGB camera system, and a combination of these systems, to detect and recognize gestures. Additionally, the electronic device 300 may be equipped with an accelerometer or gyroscope to detect motion. The output of the accelerometer or gyroscope may be provided to the electronic device 300 for display to present immersive augmented reality or virtual reality.
In addition, the processor 314 in the electronic device 300 can also execute the programs and instructions in the memory 312 to present the actions and steps described in the above embodiments, or other descriptions in the specification.
Any particular order or hierarchy of steps for processes disclosed herein is by way of example only. Based upon design preferences, it should be understood that any specific order or hierarchy of steps in the processes may be rearranged within the scope of the disclosures made in this document. The accompanying method claims present elements of the various steps in a sample order, and are therefore not to be limited to the specific order or hierarchy presented.
The use of ordinal terms such as "first," "second," "third," etc., to modify a component in the claims does not by itself connote any priority, precedence, or order of components or steps performed by the method, but are used merely as labels to distinguish one component from another component having a same name (but for use of a different ordinal term).
Although the present disclosure has been described with reference to particular embodiments, it will be apparent to one of ordinary skill in the art that changes and modifications can be made without departing from the spirit and scope of the disclosure, and the scope of the disclosure is therefore intended to be defined by the appended claims.
[ notation ] to show
100. Method of producing a composite material
S105, S110, S115, S120, S125
300. Electronic device
310. Bus line
312. Memory device
314. Processor with a memory for storing a plurality of data
316. Display assembly
318 I/O port
320 I/O component
322. A power supply.