sdfa
sdfa

Reputation: 1

FFTW fftwf_plan_r2r_2d() with FFTW_REDFT01 equivalent to idct2 in matlab

What's the proportional relation between idct2 in MATLAB and FFTW_REDFT01?

The answer in 'FFTW fftwf_plan_r2r_2d() with FFTW_REDFT01 equivalent'

The following relation seems incorrect:

resFFT /= (4 * sqrt(float(img.rows/2)) * sqrt(float(img.cols/2)));
resFFT.row(0) /= sqrt(2.f);
resFFT.col(0) /= sqrt(2.f);

Sorry for my poor english. In matlab, assume

X = [1 2 3; 4 5 6; 7 8 9]
Y1 = dct2(X)
Y1 = [15,-2.4495,0; -7.3485,0,0; 0,0,0]

With FFTW:

fftw_plan_r2r_2d(n1, n2, X, Y2, FFTW_REDFT10, FFTW_REDFT10, FFTW_MEASURE) 
Y2 = [180, -20.7846, 0; -62.3538, 0, 0; 0, 0, 0]

the proportional relation between Y1 and Y2 is as follows:

  1. an overall factor of 4 * sqrt(n1/2) * sqrt(n2/2)
  2. an additional factor of sqrt(2) in the first row and first column (and thus an additional factor of 2 in the upper-left output).

My question is: in MATLAB,

X = [1 2 3; 4 5 6; 7 8 9] 
Z1 = idct2(X) 
Z1 = [13.1813, -4.2621, 1.9295; -9.0617, 1.6193, -1.4571; 1.4512, -0.5999, 0.1994]

and with FFTW,

fftw_plan_r2r_2d(n1, n2, X, Z2, FFTW_REDFT01, FFTW_REDFT01, FFTW_MEASURE) 
Z2 = [69.641, -29.8564, 5; -52.2487, 17, -3.75129; 5, -2.1435, 0.3589]

what's the proportional relation between Z1 and Z2?

Upvotes: 0

Views: 51

Answers (0)

Related Questions