및 여기서 편의상 복사 시프트된다 : I는 A (512 × 512)로서 레나 이미지 식별 필터를 사용 OpenCV의 DFT 기반의 컨볼 루션은
void convolveDFT(InputArray A, InputArray B, OutputArray C)
{
C.create(abs(A.rows - B.rows)+1, abs(A.cols - B.cols)+1, A.type());
Size dftSize;
// calculate the size of DFT transform
dftSize.width = getOptimalDFTSize(A.cols + B.cols - 1);
dftSize.height = getOptimalDFTSize(A.rows + B.rows - 1);
// allocate temporary buffers and initialize them with 0's
Mat tempA(dftSize, A.type(), Scalar::all(0));
Mat tempB(dftSize, B.type(), Scalar::all(0));
// copy A and B to the top-left corners of tempA and tempB, respectively
Mat roiA(tempA, Rect(0,0,A.cols,A.rows));
A.copyTo(roiA);
Mat roiB(tempB, Rect(0,0,B.cols,B.rows));
B.copyTo(roiB);
// now transform the padded A & B in-place;
// use "nonzeroRows" hint for faster processing
dft(tempA, tempA, 0, A.rows);
dft(tempB, tempB, 0, B.rows);
// multiply the spectrums;
// the function handles packed spectrum representations well
mulSpectrums(tempA, tempB, tempA);
// transform the product back from the frequency domain.
// Even though all the result rows will be non-zero,
// you need only the first C.rows of them, and thus you
// pass nonzeroRows == C.rows
dft(tempA, tempA, DFT_INVERSE + DFT_SCALE, C.rows);
// now copy the result back to C.
tempA(Rect(0, 0, C.cols, C.rows)).copyTo(C);
}
(모든 항목은 가운데 하나를 제외하고 0으로 설정 됨) B (41x41).
하단 이미지의 오른쪽 부분이 잘린 것 같다. 또한 SO 포맷으로 인해 여기에서 볼 수는 없지만 필터링 된 이미지는 원본보다 작습니다 (함수의 첫 번째 줄 때문에).
filter2D 함수처럼 이미지를 필터링하도록 코드를 수정하려면 어떻게해야합니까? 따라서이 경우 결과는 원본 이미지가됩니다.