Ideal highpass fourier filter.

Page 281


In [2]:
%run ../../common.ipynb
image = imread('../mp.tif')
F = fft2(image)


Populating the interactive namespace from numpy and matplotlib
/Users/arve/.virtualenvs/brew/lib/python2.7/site-packages/tifffile.py:1149: UserWarning: ome-xml: invalid TiffData index
  warnings.warn("ome-xml: invalid TiffData index")

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))