This filter will set [0,0] to zero in frequency domain, effectivly removing DC components.
In [1]:
%run ../common.ipynb
In [2]:
image = imread('../MP.tiff')
In [3]:
image.shape
Out[3]:
In [4]:
imshow(image, figure=figure(figsize=(12,12)), cmap='gray')
Out[4]:
In [5]:
F = fft2(image)
In [6]:
F[0,0] = 0
In [11]:
f = ifft2(F).real
In [12]:
imshow(f)
Out[12]:
In [13]:
imshow(f, figure=figure(figsize=(12,12)), cmap='gray')
Out[13]:
In [14]:
f.real[100:110,100:110]
Out[14]:
In [15]:
# as figure 4.30 page 258, set negative values to zero
mask = f < 0
f[mask] = 0
In [16]:
imshow(f, figure=figure(figsize=(12,12)), cmap='gray')
Out[16]:
In [17]:
imsave('dc.tif', uint8(f))
In [20]:
histshow(image)
histshow(f.astype(np.uint8)[f>0])
In [21]:
image.mean?
In [ ]: