numpyで画像のFFTを行う。
まずグレースケールで基本を抑える。
まずグレースケールで基本を抑える。
import numpy as np
import Image
if __name__ == "__main__":
img = Image.open("pngs/image0-0.png").convert('L') #open and convert to grayscale
img = np.array(img) #convert to numpy array
ft = np.fft.fft2(img) #fft
Pow = np.abs(ft)**2 #get power spectrum
Pow = np.log10(Pow) #adjust scale to log
Pmax = np.max(Pow) #ajust to 8-bit scale
Pow = Pow / Pmax * 255
pow_img = Image.fromarray(np.uint8(np.fft.fftshift(Pow))) #convert to Image
#fftshift makes DC componets to the origin
pow_img.show() #display

0 件のコメント:
コメントを投稿