[Up] [iacircle] | Image Creation |
Implemented in Python.
fsize | Image. Gray-scale (uint8 or uint16) or binary image (logical).
Filter size: a col vector: first element: rows, second: cols, etc. uses same convention as the return of size. |
tc | Double. Cutoff period. |
n | Double. Filter order. |
option | String. Filter options. Possible values: 'circle' or 'square'. Default:
|
H | Image. Gray-scale (uint8 or uint16) or binary image (logical).
DFT mask filter, with H(0,0) as (u,v)=(0,0) |
This function generates a frequency domain Low Pass Butterworth Filter with cutoff period
tc
and order
n
. At the cutoff period the filter amplitude is about 0.7 of the amplitude at H(0,0). This function returns the mask filter with H(0,0). As the larger the filter order, sharper will be the amplitude transition at cutoff period. The minimum cutoff period is always 2 pixels, despite of the size of the frequency filter.
>>> H2_10 = iabwlp([100,100],2,10) # cutoff period: 2 pixels, order: 10
>>> iashow(iadftview(H2_10))
(100, 100) Min= 0 Max= 255 Mean=213.734 Std=73.38
>>> H4_1 = iabwlp([100,100],4,1) # cutoff period: 4, order: 1
>>> iashow(iadftview(H4_1))
(100, 100) Min= 76 Max= 255 Mean=154.060 Std=43.27
>>> H8_100 = iabwlp([100,100],8,100) # cutoff period: 8, order: 100
>>> iashow(iadftview(H8_100))
(100, 100) Min= 0 Max= 255 Mean=12.650 Std=55.11
>>> H4_1box = iabwlp([100,100],4,1,'square') # cutoff period: 4, order: 1
>>> iashow(iadftview(H4_1box))
(100, 100) Min= 117 Max= 255 Mean=168.055 Std=38.03
iadftview(H2_10) | iadftview(H4_1) | iadftview(H8_100) | iadftview(H4_1box) |
>>> import Numeric
>>> import FFT
>>> f = iaread('cookies.pgm')
>>> iashow(f)
(174, 314) Min= 16 Max= 205 Mean=94.752 Std=57.61
>>> F = FFT.fft2d(f)
>>> iashow(iadftview(F))
(174, 314) Min= 25 Max= 255 Mean=111.508 Std=15.92
>>> H = iabwlp(F.shape,16,6)
>>> iashow(iadftview(H))
(174, 314) Min= 0 Max= 255 Mean=3.996 Std=28.86
>>> G = F * H
>>> iashow(iadftview(G))
(174, 314) Min= 0 Max= 255 Mean=4.862 Std=23.62
>>> g = FFT.inverse_fft2d(G)
>>> g = abs(g).astype(Numeric.UnsignedInt8)
>>> iashow(g)
(174, 314) Min= 16 Max= 192 Mean=94.254 Std=56.85
f | iadftview(F) |
iadftview(H) | iadftview(G) |
g |
def iabwlp(fsize, tc, n, option='circle'): from Numeric import arange, sqrt, maximum, ravel, reshape import string def test_exp(x, y): try: return x**(2*y) except: return 1E300 # Infinito! rows, cols = fsize[0], fsize[1] mh, mw = rows/2, cols/2 y, x = iameshgrid(arange(-mw,cols-mw), arange(-mh,rows-mh)) # center if string.find(string.upper(option), 'SQUARE') != -1: H=1./(1.+(sqrt(2)-1)*(maximum(abs(1.*x/rows) , abs(1.*y/cols))*tc)**(2*n)) else: aux1 = ravel(sqrt(((1.*x)/rows)**2 + ((1.*y)/cols)**2)*tc) aux2 = 0.*aux1 + n aux = reshape(map(test_exp, aux1, aux2), x.shape) H=1./(1+(sqrt(2)-1)*aux) H=iafftshift(H) return H
iacos | Create a cossenoidal image. |
iagaussian | Generate a 2D Gaussian image. |
ialog | Laplacian of Gaussian image. |
[Up] [iacircle] | |