如何通过torch.fft分离图像的低频和高频分量?

2024-10-08 23:18:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我想通过torch.fft来分离图像的低频和高频分量

最好给我一个这样的样品:

import cv2 as cv
import numpy as np

img = cv.imread('messi5.jpg',0)
f = np.fft.fft2(img)
fshift = np.fft.fftshift(f)

rows, cols = img.shape
crow,ccol = rows/2 , cols/2
fshift[crow-30:crow+30, ccol-30:ccol+30] = 0
f_ishift = np.fft.ifftshift(fshift)
img_back = np.fft.ifft2(f_ishift)
img_back = np.abs(img_back)

Tags: 图像importfftimgasnpbacktorch

热门问题