1. Field of the Invention
The present invention relates to a method and an electronic device for processing a digital image, and more particularly to a method and an electronic device for adjusting a compression ratio of a JPEG image.
2. Related Art
With the popularization of digital camera devices, more and more people have joined the photography activities. Generally, an ordinary digital camera device adopts an image format of Joint Photographic Experts Group (briefly referred to as JPEG hereinafter). The compression manner for the JPEG format falls within the scope of lossy compression, that is to say, a visible damage occurs to the quality of images during compression.
FIG. 1 is a schematic diagram of a conventional JPEG compression process. Referring to FIG. 1, a conventional JPEG compression process includes the following steps. A captured digital image is processed through a color space conversion (Step S110), so that the digital image is converted from a red-green-blue (RGB) color space into a different color space referred to as YCrCr, in which Y is a luminance signal, and CbCr is a chroma signal. Next, a discrete cosine transform (DCT) is performed (Step S120). Pixel blocks in a form of 8*8 pixel arrays without overlying are obtained one by one from the converted digital images. Then, a two dimensional discrete cosine transform (2D-DCT) is performed to convert each pixel block into a frequency space. Then, the quantization is executed (Step S130), and the pixel block that has already been converted through the 2D-DCT is divided by a quantization table (Step S140). Then, an entropy coding is executed (Step S150), so as to calculate an entropy value of the pixel block processed in Step S140 and to perform a length coding on the processed pixel block.
In order to adjust a file size of a digital image, a compression parameter is generally used to make a further processing on the quantization table. The larger the compression parameter is, the smaller file size the raw image is compressed into, and vice versa. But if the file size is rather small (that is, the compression ratio is quite large), several details of the digital image are sacrificed.