作業說明:
在 frequency domain apply 一個 gaussian low pass filter
並且得到 input 的 magnitude 以及 phase (shift 過的)
執行環境:
- Arch Linux x86_64
- Python 3.9.2
- Python venv
- OpenCV 4.5.1
實作方式:
- step 1 : read image in grayscale
- step 2 : zero padding to 2Mx2N
- step 3 : multiply f(x,y) by (-1)^(x+y)
- step 4 : compute dft of the image
- step 4-1 : getting magnitude and phase
- step 5 : generate filter function and form the product
- step 6 : obtain the processed image
- step 7 : obtain g(x,y) by extracting the MxN region
- step 7-1 : save images
執行結果:
由上而下分別為
1. 原圖
2. 灰階
3. 頻譜
4. 相位譜
5. 結果 (d0=30) 較糢糊
6. 結果 (d0=120) 較清晰
參考資料:
How to get accurate idft result from opencv?
Create a matrix from a function
numpy.fromfunction — NumPy v1.20 Manual
numpy.mgrid — NumPy v1.20 Manual
Adding borders to your images - OpenCV
Discrete Fourier Transform - OpenCV
numpy.fromfunction — NumPy v1.20 Manual
numpy.mgrid — NumPy v1.20 Manual
Adding borders to your images - OpenCV
Discrete Fourier Transform - OpenCV
沒有留言:
張貼留言