In order to effectively use digital images, they must be efficiently stored and transferred, and compression encoding of image data is an indispensable technique. As a method of compressing image data, a method of segmenting image data to be compressed into blocks, generating a difference signal by inter-frame prediction using motion compensation as needed in case of a moving image, and transforming blocks into orthogonal transformation coefficients (to be referred to as DCT coefficients hereinafter) using orthogonal transformation such as discrete cosine transformation (to be referred to as DCT hereinafter) to attain entropy encoding is generally known (e.g., JPEG (Joint Photographic Experts Group) and MPEG (Motion Picture Experts Group) as standard image encoding methods). This method positively utilizes the correlation of an image, i.e., the concentrated distribution of an image signal with strong correlation in a low-frequency range upon orthogonal transformation.
For example, in JPEG and MPEG, an original image is normally segmented into 8×8 pixel blocks, and two-dimensional (2D) DCTs are computed for respective blocks. In order to reduce the code size, DCT coefficients are quantized using a quantization table and quantization scale value. In this case, in consideration of the human visual characteristics, visually sensitive low-frequency components are quantized using a small quantization table value, and insensitive high-frequency components are quantized using a large quantization table value, thus achieving efficient quantization that suffers less visual deterioration to obtain DCT coefficients that have been quantized (to be referred to as quantized DCT coefficients hereinafter). In order to make the code size of an image to be output fall within a predetermined range, a method of quantizing using a quantization scale value that changes according to the current bit rate or total code size is generally used.
When a high-resolution moving image or still image is stored in a storage device with a limited capacity such as a flash memory or the like for a long period of time (a large number of images in case of a still image), the bit rate as a data size per unit time must be lowered by increasing the compression ratio.
As a method of lowering the bit rate, a method of increasing quantized DCT coefficients that assume zero by increasing a quantization scale value is generally used. With this quantization process, more efficient compression can be attained in entropy encoding.
However, since DCT coefficients that have undergone frequency transformation for respective blocks are quantized, if coarse quantization is made by increasing a quantization scale value, serious distortion, i.e., so-called block distortion, is produced at block boundaries, resulting in conspicuous image quality deterioration. As a method of eliminating such block distortion, a method using a filter such as a low-pass filter (to be referred to as an LPF hereinafter) or the like is generally used. When the LPF is applied to the output from a decoder, this block distortion can be effectively eliminated. However, such process in the decoder deviates from the contents of the image encoding international standards such as JPEG, MPEG, and the like, and can be implemented by only a specific decoder. Assuming that processes are done by a decoder which is implemented by general software complying with the image encoding international standards such as JPEG, MPEG, and the like, another process for suppressing production of any block distortion must be done in the encoder.
As means for suppressing production of any block distortion in the encoder, a method of adaptively changing a quantization parameter, and a method of changing the filter characteristics of a filter processor in an image processing unit located on the input side of encoding are generally used.
As the method of adaptively changing a quantization parameter, a method of suppressing production of block distortion while realizing a desired bit rate by detecting block distortion in one image, decreasing a quantization scale value of a region that suffers block distortion, and increasing a quantization scale value of a region that suffers less block distortion is generally used. When the quantization parameter is changed in this way, block distortion must be accurately detected. If a detection error has occurred, block distortion may increase unwantedly.
When the filter processor in the image processing unit which is located on the input side of an encoder is used to eliminate block distortion, an LPF is normally used as a filter. This is because block distortion normally includes many high-frequency components, and high-frequency components at which block distortion is produced are reduced in advance using the LPF. At the same time, quantized DCT coefficients with nonzero high-frequency components can be reduced, and the encoding efficiency of entropy encoding can be improved. In this way, using the LPF, block distortion of a decoded image can be eliminated.
As problems posed when the LPF is used in an encoder, if the LPF is applied when no block distortion is produced, a problem of unsharp image quality since high-frequency components of an original image are cut off, and a problem of image quality deterioration compared to a case without any filter process since the boundary lacks smoothness at the edge of an object, i.e., so-called mosquito noise is produced are posed.
For these reasons, in order to minimize image quality deterioration at a low bit rate, image deterioration due to block distortion must undergo accurate quantitative evaluation, and a quantization parameter and filter characteristics must be adaptively determined based on the evaluation result.
As a first conventional method of a block distortion detection method, a method of predicting appearance of block distortion or the like based on a quantization parameter upon encoding is known (e.g., Japanese Patent Laid-Open No. 2003-018600). As a second conventional method, a method of detecting block distortion by comparing a difference value between neighboring pixels in a block with that between neighboring pixels at a block boundary in a decoded image in a post-process filter control method in a video codec is known (e.g., Japanese Patent Laid-Open No. 7-38762). As a third conventional method, an error between an original image and decoded image is calculated, and if the error is equal to or smaller than a given threshold value, it is determined to be zero. If the error is equal to or larger than a given value, a difference value between neighboring pixels is calculated at a block boundary, and the square mean of the differences for the length of a block side is calculated for each block boundary. In consideration of the human visual characteristics, the ratio between the square mean and the variance of luminance values in a block is used as a quantitative evaluation scale of block distortion in each block (e.g., Japanese Patent Laid-Open No. 5-219384).
However, in the first conventional method, since block distortion has different values depending on target images, it is difficult to accurately predict the relationship between the quantization scale value and production of block distortion. Hence, when production of block distortion is predicted based on the quantization scale value, a prediction error occurs. If such prediction error has occurred, image quality may worsen upon changing the quantization parameter or filter characteristics.
In the second conventional method, since block distortion is detected based on only the decoded image, if the block boundary matches an object edge, the object edge is erroneously detected as block distortion although no block distortion is produced.
In the third conventional method, since block distortion is detected based on only block boundary values, it is difficult to determine whether the entire frame suffers deterioration or block distortion is conspicuously produced only at the block boundary. Since the square mean is calculated, and the ratio to the luminance variance in a block is calculated, complicated calculations are required, and hardware implementation is difficult.