First, the introduction
DCT transform is an important transform in digital image processing, many important image algorithms and image applications are based on DCT transform, such as JPEG image coding. For large size two-dimensional numerical matrices, if the ordinary DCT transform is used, the time spent will be unbearable or even impossible to achieve practical. To overcome this difficulty, the fast algorithm of DCT transform is very attractive.
For now, the fast algorithm of DCT transform has the following two ways:
1. As the FFT algorithm is used, it is relatively easy to use FFT to realize the fast algorithm of DCT transform. But there is also a shortage of this approach: the computational process involves complex numbers. Since the data before and after the DCT transform is real, in the calculation, the plural is introduced, and the addition of a pair of complex numbers equals the addition of two pairs of real numbers, and the multiplication of a pair of complex numbers equals the multiplication of four to real numbers and the addition of two to real numbers, which obviously increases the computational volume and puts forward higher requirements for hardware storage.
2. Fast transform of DCT directly in real field. Obviously, this method is better than the former in terms of both computational and hardware requirements.
In view of this, this paper uses the second method to realize the fast algorithm of DCT transform.
Second, theoretical deduction
Limited to space, this can not be listed, the specific derivation process can be seen in the new DCT fast algorithm and filter structure research and wavelet transform domain image denoising Research, South China University of Technology doctoral dissertation.
III. implementation of the procedure
Fast transform of DCT
Considering that the coefficients in the DCT transform are to be repeated, the lookup table can be used to improve the efficiency of the operation, so long as the DCT transform can be computed once before the DCT transform, it is possible to find only without calculating coefficients.
void initDCTParam(int deg)
{
// deg 为DCT变换数据长度的幂
if(bHasInit)
{
return; //不用再计算查找表
}
int total, halftotal, i, group, endstart, factor;
total = 1 << deg;
if(C != NULL) delete []C;
C = (double *)new double[total];
halftotal = total >> 1;
for(i=0; i < halftotal; i++)
C[total-i-1]=(double)(2*i+1);
for(group=0; group < deg-1; group++)
{
endstart=1 << (deg-1-group);
int len = endstart >> 1;
factor=1 << (group+1);
for(int j = 0;j < len; j++)
C[endstart-j-1] = factor*C[total-j-1];
}
for(i=1; i < total; i++)
C[i] = 2.0*cos(C[i]*PI/(total << 1)); ///C[0]空着,没使用
bHasInit=true;
}