내 자신의 질문 ... thesetwo 참조의 도움으로
응답, 난 전혀 DFT를 사용 하지을 종료하지만 OpenCV의의 cv::dct()
및 cv::idct()
대신 사용.
cv::dct(img, resFFT); // fwd dct. This is like Matlab's dct2()
resFFT *= (4 * sqrt(float(img.rows/2)) * sqrt(float(img.cols/2)));
resFFT.row(0) *= sqrt(2.f);
resFFT.col(0) *= sqrt(2.f);
이 FFTW_REDFT01
와 역은과 같이 수행 할 수 있습니다 :
// First re-scale the data for idct():
resFFT /= (4 * sqrt(float(img.rows/2)) * sqrt(float(img.cols/2)));
resFFT.row(0) /= sqrt(2.f);
resFFT.col(0) /= sqrt(2.f);
cv::idct(resFFT, outImg); // this will return the input exactly
// However, the transforms computed by FFTW are unnormalized, exactly like the corresponding,
// so computing a transform followed by its inverse yields the original array scaled by N, where N is the logical DFT size.
// The logical DFT size: Logical N=2*n for each axis, this is th implicit symmetrization
// of the image: reflect right and then reflect both halves down.
int logicalSizeN = (2*img.rows) * (2*img.cols);
outImg *= logicalSizeN; // scale to be like FFTW result
더 유용한 링크 here을
질문에 대답하기 위해, fftwf_plan_r2r_2d(...,FFTW_REDFT10, FFTW_REDFT10,...)
은 추가 스케일링이 OpenCV의 코드에 의해 대체 될 수 있습니다 및 here.
OpenCV는 짝수 개의 행과 열이있는 이미지 만 지원합니다. FFTW_DESTROY_INPUT |이에 대한 많은, 나는 최근에이 정확한 문제에 발견
덕분에, 나는 또한 포트에 함수 fftwf_plan_r2r_2d (..., ..., ..., ..., FFTW_REDFT00, FFTW_REDFT00, FFTW_ESTIMATE 필요))) 어떤 아이디어? – Kachinsky