python opencv 低通,高通滤波器
2022/7/28 14:33:44
本文主要是介绍python opencv 低通,高通滤波器,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
import cv2 import numpy as np from matplotlib import pyplot as plt img = cv2.imread('8.jpg',0) img_float32 = np.float32(img) dft = cv2.dft(img_float32,flags=cv2.DFT_COMPLEX_OUTPUT) dft_shift = np.fft.fftshift(dft) rows,cols = img.shape crow,ccol = int(rows/2),int(cols/2) #低通滤波 # mask = np.zeros((rows,cols,2),np.uint8) # mask[crow-30:crow+30,ccol-30:ccol+30] = 1 #高通滤波 mask = np.ones((rows,cols,2),np.uint8) mask[crow-30:crow+30,ccol-30:ccol+30] = 1 #IDFT fshift = dft_shift*mask f_ishift = np.fft.fftshift(fshift) img_back = cv2.idft(f_ishift) img_back = cv2.magnitude(img_back[:,:,0],img_back[:,:,1]) plt.subplot(121),plt.imshow(img,cmap='gray') plt.title('INPUT'),plt.xticks([]),plt.yticks([]) plt.subplot(122),plt.imshow(img_back,cmap='gray') plt.title('Result'),plt.xticks([]),plt.yticks([]) plt.show()
这篇关于python opencv 低通,高通滤波器的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-08有遇到过吗?同样的规则 Excel 中 比Python 结果大
- 2024-03-30开始python成长之路
- 2024-03-29python optparse
- 2024-03-29python map 函数
- 2024-03-20invalid format specifier python
- 2024-03-18pool.map python
- 2024-03-18threads in python
- 2024-03-14python Ai 应用开发基础训练,字符串,字典,文件
- 2024-03-13id3 algorithm python
- 2024-03-13sum array elements python