Convolution theorem in Fourier transform
머신비전, 영상처리 분야의 Convolution theorem에 대해 알아보겠습니다.
1. Overview
Convoluttion Theorem은 다음과 같습니다.
핵심은 이미지와 필터에 대한 covolution의 결과와
이미지와 필터를 FFT를 한 후, element-wise product을 수행 후 inverse FFT를 수행하면 결과가 같다는 것입니다.
http://www.cs.virginia.edu/~vicente/vision/slides/lecture06.pdf
이러한 결과는 아래와 같이 활용가능합니다.
covolution 결과는 연산에 시간이 오래 걸리기 때문에,
FFT를 이용하여 빠르게 같은 결과를 얻을 수 있습니다.
또한, Deep Learning에서는
Convolution연산을 통해 결과를 얻는 경우가 많으므로,
이 부분에 대해서도 참고할 수 있습니다.
Hands-On Image Processing with Python
Application of the convolution theorem The convolution theorem says that convolution in an image domain is equivalent to a simple multiplication in the frequency domain: Following diagram shows … - Selection from Hands-On Image Processing with Python [
www.oreilly.com
2. Python 구현
사용한 라이브러리는 아래와 같습니다.
먼저, 사용할 이미지를 불러와
FFT와 FFT shift를 사용하면 다음과 같습니다.
sobel 마스크에 대해서
FFT, FFT shift를 수행하면 다음과 같습니다.
FFT를 수행한 이미지와 필터에 대해
element-wise product은 다음과 같습니다.
위 결과를
inverse FFT의 결과는 다음과 같습니다.
Convolution 연산을 통해 얻은 결과는 다음과 같습니다.
두 결과를 비교하면,
결과가 어느정도 비슷함을 알 수 있습니다.
하지만, 여러가지 시도를 해보았지만
완전히 똑같은 결과를 얻어내지는 못하였습니다.
해당 소스는 아래의 링크에서 확인할 수 있습니다.
https://github.com/jstar0525/MachineVision/tree/main/08%20Convolution%20theorem
jstar0525/MachineVision
Machine Vision Algorithm. Contribute to jstar0525/MachineVision development by creating an account on GitHub.
github.com