python用opencv 圖像傅里葉變換
傅里葉變換dft = cv.dft(np.float32(img),flags = cv.DFT_COMPLEX_OUTPUT)傅里葉逆變換img_back = cv.idft(f_ishift)
實驗:將圖像轉(zhuǎn)換到頻率域,低通濾波,將頻率域轉(zhuǎn)回到時域,顯示圖像
import numpy as npimport cv2 as cvfrom matplotlib import pyplot as pltimg = cv.imread(’d:/paojie_g.jpg’,0)rows, cols = img.shapecrow, ccol = rows//2 , cols//2dft = cv.dft(np.float32(img),flags = cv.DFT_COMPLEX_OUTPUT)dft_shift = np.fft.fftshift(dft)# create a mask first, center square is 1, remaining all zerosmask = np.zeros((rows,cols,2),np.uint8)mask[crow-30:crow+31, ccol-30:ccol+31, :] = 1# apply mask and inverse DFTfshift = dft_shift*maskf_ishift = np.fft.ifftshift(fshift)img_back = cv.idft(f_ishift)img_back = cv.magnitude(img_back[:,:,0],img_back[:,:,1])plt.subplot(121),plt.imshow(img, cmap = ’gray’)plt.title(’Input Image’), plt.xticks([]), plt.yticks([])plt.subplot(122),plt.imshow(img_back, cmap = ’gray’)plt.title(’Low Pass Filter’), plt.xticks([]), plt.yticks([])plt.show()
相關(guān)文章:
1. ASP常用日期格式化函數(shù) FormatDate()2. chat.asp聊天程序的編寫方法3. CSS 使用Sprites技術(shù)實現(xiàn)圓角效果4. phpstudy apache開啟ssi使用詳解5. 詳解瀏覽器的緩存機制6. ASP中if語句、select 、while循環(huán)的使用方法7. 怎樣才能用js生成xmldom對象,并且在firefox中也實現(xiàn)xml數(shù)據(jù)島?8. HTML中的XML數(shù)據(jù)島記錄編輯與添加9. 利用FastReport傳遞圖片參數(shù)在報表上展示簽名信息的實現(xiàn)方法10. 推薦一個好看Table表格的css樣式代碼詳解
