1. Field of the Invention
The present invention relates to a method of image compression and a device thereof, and more particularly, to dynamically adjust a quantization value according to the information of the previous image.
2. Description of Related Art
Image compression means to reduce a data size of a digital image to a level that can be supported by storage or transmission medium. Data are the carriers transmitting information, and the equal amount of information can be represented by different data size. For example, if a story is said by different persons, amount of the language used by different persons for describing the same story are quite different, wherein the information interested in is the story and the data representing the information is the language. The data providing the information unconcerned with or the known information repeatedly said are called the data redundancy. The data redundancy can be quantitatively determined in mathematics, such as Rd=1−1/Cr, wherein Rd is the data redundancy and Cr is the compression ratio.
The compression ratio Cr equals N1/N2, wherein N1 and N2 are the data size before and after image compression, respectively. The compression ratio Cr is used instead of bit rate to characterize the capability of the compression system. As for lossy compression, the compression ratio Cr getting higher means the data redundancy is highly eliminated, but in the other hand, the distortion of the compressed image also gets higher. In order to make balance between eliminating the data redundancy and reducing the distortion of the compressed image, the compression ratio Cr needs to be well controlled.
The quantization parameter QP is extremely related to the compression ratio Cr. In the past, the image is compressed by a fixed compression ratio Cr. For an instance of the image having 240×320 pixels, if each pixel has components of three primary colors of light called red, green and blue, and eight bits is used to represent each primary color, the total bits of the image are 240×320×3×8. For the fixed compression ratio Cr=2, the total bits of the compressed image are (240×320×3×8)/2 and the average bit rate equals twelve. Therefore, a rate control process is needed for adjusting the quantization parameter QP according to the average bit rate of the compressed image and maintaining the fixed compression ration Cr.
Besides, the scene complexity is non-uniform distributed in the image. scene complexity of the previous image. Therefore, not only the compression ratio of the image can be controlled within the proper range, but also the bandwidth of the transmission medium can be efficiently utilized to enhance the image quality. The device of image compression is carried out according to this method.
A method of image compression is provided in the present invention. First, an image having a plurality of regions is received and a quantization process is performed on a specific region which is one of the regions according to a quantization value. Next, a first average bit rate of the specific region of the image after an encoding process is calculated. Next, the quantization value of the corresponding specific region of the next received image is adjusted according to the first average bit rate of the specific region of the image.
A device of image compression comprising a receiver module, a quantization module, an encode module and a control module is provided in the present invention. The receiver module is used for receiving an image having a plurality of regions. The quantization module is coupled to the receiver module and is used for performing a quantization process on a specific region of the image according to a quantization value, wherein the specific region is one of the regions. The encode module is coupled to the quantization module and is used for performing an encoding process on the specific region of the image. The control module is coupled to the encode module and is used for calculating a first average bit rate of the specific region of the image after the encoding process and adjusting the quantization value of the corresponding specific region of the next received image according to the first average bit rate of the specific region of the image.
The present invention provides a method of image compression and a When the scene complexity of the image is low, the encoding process comprising quantizing and coding can almost be seen as lossless compression and the compression ratio Cr does not decrease. On the contrary, when the scene complexity of the image is high, in order to controlling the compression ratio Cr to be fixed, the distortion of the compressed image needs to increase to exchange for less bit number. For this reason, the image quality and the compression ratio Cr can not be given consideration simultaneously.
Furthermore, for a whole image, the compression order of the image is from top to bottom. When a location of the image is encoded presently, the information having been encoded can be realized, but the information having not been encoded yet can not be predicted. Therefore, if the scene complexity of the upper part in the image is higher and the scene complexity of the under part in the image is lower, the distortion of the upper part increases for maintaining the compression ratio Cr of the upper part not to decrease. Due to the scene complexity of the under part in the image can not be predicted, the under part may be quantized according to the same quantization parameter QP and then the compression ratio Cr of the under part increases. When the compression ratio Cr is higher than a presetting value, the redundant bandwidth can not be efficiently utilized to decreases the distortion and to enhance the peak signal-to-noise ratio (PSNR) of the upper part.
Accordingly, the present invention provides a method of image compression and a device thereof. Because the continuous images have correlation mutually, the quantization value for quantizing is dynamically adjusted according to the scene thereof which dynamically adjust the quantization value of one region of the next received image for quantizing according to the first average bit rate of the corresponding one region of the previously compressed image, wherein the first average can respond to the scene complexity of the image. Because continuous images often have high correlation mutually, by this way of adjusting the quantization value, the present invention can make the bandwidth being utilized efficiently and decrease the distortion degree of the compressed image according to its scene complexity.
In order to make the features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
It is to be understood that both the foregoing general description and the following detailed description are exemplary, and are intended to provide further explanation of the invention as claimed.
The accompanying drawings are included to provide a further understanding of the invention, and are incorporated in and constitute a part of this specification. The drawings illustrate embodiments of the invention and, together with the description, serve to explain the principles of the invention.
In one embodiment of the present invention, a scene complexity of an image is recorded to improve the encoding manner of the next image and to reduce the distortion degree of the next image.
After the quantization process, the encode module 230 performs the encoding process, such as a variable length coding (VLC), on the specific region of the image. Then, after the encoding process, the control module 240 calculates the first average bit rate Br of the specific region of the compressed image 310. The first average bit rate Br can respond to the scene complexity of the specific region of the image. Referring to
If each pixel of the received image has three color components and eight bits is used to represent each color component, for a compression ratio equaling two, a second average bit rate of the compressed image should be twelve. Referring to
To reason by analogy, the control module 240 also adjusts the quantization value Q of the corresponding region 312 of the next received image to be lower so that the bit number percentage P and the first average bit rate Br of the corresponding region 312 of the next compressed image 320 respectively increases to 26.4% and 12.5 bit/second. Due to the lower scene complexity of the regions 313 and 314 of the compressed image 310, the control module 240 may adjust the quantization value Q of the regions 313 and 314 of the next received image to be higher or does not adjusts them. Therefore, the bit number percentage P and the first average bit rate Br of the corresponding region 313 of the next compressed image 320 are respectively 12.5% and 6 bit/second, and the bit number percentage P and the first average bit rate Br of the corresponding region 314 of the next compressed image 320 are respectively 10% and 4.5 bit/second.
Referring to
It is note that the number and size of the regions should not be limited and people ordinary skilled in the art can apply any compression standards into the image compression device of the embodiment, such as standard of Joint Photographic Experts Group (JPEG) or H.26X video compression standard provided from International Telecommunication Union (ITU-T) etc, according to the teaching of the embodiment of the present invention. For example, the image compression of JPEG is based on block with 8×8 pixels so that the regions can be any size of blocks forming the image. Besides, the quantization value Q in the embodiment of the present invention is supposed relating to the step size for quantizing, but in another embodiment of the invention, the quantization value Q relates to the step number for quantizing so that the higher the quantization value Q is, the lower distortion of the compressed image is.
According to the embodiment described above, the steps of the following method could be generalized.
In summary, the embodiment of the present invention provides a method of image compression and a device thereof which dynamically adjust the quantization value according to the scene complexity of the previous image. When an image having a plurality of regions is compressed, the first average bit rate of one region of the compressed image can respond to the scene complexity of the one region and the second average bit rate of the compressed image can be applied to control the compression ratio. The embodiment of the present invention utilizes the first average bit rate of the one region of the compressed image to adjust the quantization value of the corresponding one region of the next received image and controls the second average bit rate within a predetermined value for maintaining a regular compression ratio. Hence, under the regular compression ratio, the quantization value is dynamically adjusted to enhance the quality of the compressed image and to efficiently utilize the bandwidth.
Though the present invention has been disclosed above by the preferred embodiments, they are not intended to limit the present invention. Anybody skilled in the art can make some modifications and variations without departing from the spirit and scope of the present invention. Therefore, the protecting range of the present invention falls in the appended claims.