import numpy as np
from numpy.fft import fft2, fftshift, ifft2, ifftshift
import matplotlib.pyplot as plt
from skimage import io, util
import skimage.filters.rank as sfr
from scipy.signal import correlate2d
f = io.imread('aerial_view.tif')
F = fftshift(fft2(f))
[r,c] = F.shape;
u = np.arange(r).reshape((-1,1)) - np.ceil(r/2)
v = np.arange(c)-np.ceil(c/2)
k = 0.0025
H = np.exp(-k*(u*u+v*v)**(5/6));
G = F*H
g = np.uint8(np.real(ifft2(ifftshift(G))));
plt.figure(figsize=(12,6))
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.subplot(121), io.imshow(f), plt.axis('off'), plt.title('鸟瞰图')
plt.subplot(122), io.imshow(g), plt.axis('off'), plt.title('严重湍流的影响')
plt.show()
# 几何平均滤波
g_log = np.log(np.double(g)+1);
g2 = np.exp(correlate2d(g_log, np.ones((3,3)),mode='same'))**(1/9)-1;
g2 = np.uint8(g2);
plt.figure(figsize=(12,12
自选一幅灰度图像,对其模拟大气湍流造成的模糊;然后用几何均值滤波器对其复原。
最新推荐文章于 2022-12-24 16:51:26 发布