DFT(離散傅里葉變換)的計算時間不是一個隨着數組大小增大而增大的單調函數,而是與數組大小密切相關。當數組的大小是2的級數(2,4,8,16......)和 N = 2 p * 3 q * 5 r 時,計算的速率明顯提高。所以首先需要變換一下數組大小,或者爲圖片填充一些數據,使圖片的尺寸滿足上面要求。
int getOptimalDFTSize(int vecsize)//獲取最佳尺寸。
oid copyMakeBorder(InputArray src, OutputArray dst, int top, int bottom, int left,
int right, int borderType, const Scalar&value=Scalar() )//圖像加寬和變高。
src – Source image.
dst – Destination image of the same type as src and the
size Size(src.cols+left+right, src.rows+top+bottom) .