我不明白关于使用 opencv 进行 dft 的一些事情

I don't understand something about use taking dft with opencv

我是使用 opencv 库的新手。这些天我正在尝试使用dft(),但是在使用dft()之前和使用dft()之后我有些不明白。你能帮我理解一下吗?

我看了一些关于那个的 youtube 视频,但我还是不太明白。

 Mat padded;                          
int m = getOptimalDFTSize( I.rows );
int n = getOptimalDFTSize( I.cols );
copyMakeBorder(I, padded, 0, m - I.rows, 0, n - I.cols, BORDER_CONSTANT, Scalar::all(0)); //here we are expanding the photo but i dont understand the operation in here



 Mat q0(magI, Rect(0, 0, cx, cy));   
    Mat q1(magI, Rect(cx, 0, cx, cy));  
    Mat q2(magI, Rect(0, cy, cx, cy));  
    Mat q3(magI, Rect(cx, cy, cx, cy)); 

    Mat tmp;                           
    q0.copyTo(tmp);
    q3.copyTo(q0);  //here we are rearring the quadrants but how
    tmp.copyTo(q3);

    q1.copyTo(tmp);                    
    q2.copyTo(q1);
    tmp.copyTo(q2);

copyMakeBorder 用于使图像大小适合最佳 dft 计算。如果在最佳尺寸的图像上执行 dft 可以更快地执行,文档可用 here

象限被重新排列为 fftshift 操作的一部分,matlab and numpy 两者都有执行此操作的功能。目的只是为了帮助视觉分析,fftshift 将低频移动到图像的中心,更清楚地揭示 dft 大小的对称性。