Page 281
In [2]:
%run ../../common.ipynb
image = imread('../mp.tif')
F = fft2(image)
In [4]:
y,x = F.shape
X,Y = meshgrid(range(x), range(y))
mask = sqrt((X-x/2)**2 + (Y-x/2)**2) < 100
F = fftshift(F)
F[mask] = 0
F = ifftshift(F)
f = ifft2(F).real
In [5]:
gimshow(f)
In [28]:
f[f < 0] = 0 # cut off negative values
imsave('hp-ideal.tif', f.astype(np.uint8))