
96
4 章 周波数と高速フーリエ変換
F_dim = F_dim * peaks.astype(int)
# Do the inverse Fourier transform to get back to an image.
# Since we started with a real image, we only look at the real part of
# the output.
逆フーリエ変換を行い画像に戻す。実数の画像を基にしたので、出力の実部だけを取り出す。
image_filtered = np.real(fftpack.ifft2(F_dim))
f, (ax0, ax1) = plt.subplots(2, 1, figsize=(4.8, 7))
ax0.imshow(np.log10(1 + np.abs(F_dim)), cmap='viridis')
ax0.set_title('Spectrum after suppression')
ax1.imshow(image_filtered)
ax1.set_title('Reconstructed image');
■
4.6.2
窓を掛ける
矩形パルスのフーリエ変換を調べると、スペクトル中にかなりのサイドローブが見えます。
x = np.zeros(500)
x[100:150] = 1
復元された画像
抑制後のスペクトル
図
4-13
フィルタをかけた月面上陸の画像とスペクトル