[iaihwt] [Up] [ialogfilter] | Image Transformation |
Verify if a complex array show the conjugate simmetry. Due to numerical precision, this comparison is not exact but with within a small tolerance (10E-4). This comparison is useful to verify if the result of a filtering in the frequency domain is correct. Before taking the inverse DCT, the Fourier transform must be conjugate symmetric so that its inverse is a real function (an image).
>>> import FFT, MLab
>>> print iaisdftsym(FFT.fft2d(MLab.rand(100,100)))
1
>>> print iaisdftsym(FFT.fft2d(MLab.rand(101,100)))
1
>>> print iaisdftsym(FFT.fft2d(MLab.rand(101,101)))
1
>>> print iaisdftsym(iabwlp([10,10], 8, 5))
1
>>> print iaisdftsym(iabwlp([11,11], 8, 5))
0
def iaisdftsym(F): from Numeric import asarray, Complex64, NewAxis, reshape, take, ravel, conjugate, alltrue F = (asarray(F)).astype(Complex64) if len(F.shape) == 1: F = F[NewAxis,:] global rows, cols (rows, cols) = F.shape (x, y) = iameshgrid(range(cols), range(rows)) yx = iasub2ind(F.shape, y, x) aux1 = reshape(map(lambda k:k%rows, -ravel(y)), (rows, cols)) aux2 = reshape(map(lambda k:k%cols, -ravel(x)), (rows, cols)) myx = iasub2ind(F.shape, aux1, aux2) is_ = abs( take(ravel(F), yx) - \ conjugate(take(ravel(F), myx)) ) < 10E-4 b = alltrue(ravel(is_)) return b
[iaihwt] [Up] [ialogfilter] | |