python用opencv 圖像傅里葉變換
傅里葉變換dft = cv.dft(np.float32(img),flags = cv.DFT_COMPLEX_OUTPUT)傅里葉逆變換img_back = cv.idft(f_ishift)
實(shí)驗(yàn):將圖像轉(zhuǎn)換到頻率域,低通濾波,將頻率域轉(zhuǎn)回到時(shí)域,顯示圖像
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. JavaScript實(shí)現(xiàn)簡(jiǎn)單的彈窗效果2. Java commons-httpclient如果實(shí)現(xiàn)get及post請(qǐng)求3. javascript實(shí)現(xiàn)貪吃蛇小練習(xí)4. 我所理解的JavaScript中的this指向5. Vue 實(shí)現(xiàn)對(duì)quill-editor組件中的工具欄添加title6. PHP驗(yàn)證碼工具-Securimage7. PHP單件模式和命令鏈模式的基礎(chǔ)知識(shí)8. 一文帶你徹底理解Java序列化和反序列化9. PHP利用curl發(fā)送HTTP請(qǐng)求的實(shí)例代碼10. js實(shí)現(xiàn)碰撞檢測(cè)

網(wǎng)公網(wǎng)安備