[MATRIX-SIG] convolution
MISS. K.L.COLLIER
c9603085@zeus.hud.ac.uk
Wed, 23 Jul 1997 11:22:35 +0100
I'm trying to calculate the convolution of two arrays (an image and a point
spread function) using
Numerical python as follows:
#!/usr/local/bin/python
from Numeric import *
from FFT import *
raw_a = array ( [ 1,2,0,3,4,0,0,0,0 ] )
raw_a.shape=(3,3)
raw_b = array ( [ -1,1,0,-2,2,0,0,0,0 ] )
raw_b.shape=(3,3)
freq_2a = fft2d(raw_a)
freq_2b = fft2d(raw_b)
fab=freq_2a*freq_2b
res = inverse_fft2d(fab)
print "res"
print res
but there doesn't seem to be an inverse_fft2d function. Is there one?
Would this work anyway?
Do I have to have the two images the same size, i.e. pad out
the smallest one with zeros. If so do I do this symmetrically or
fill the zeros on the rhs and bottom of the matrix?
Does python automatically handle the complex numbers ok in the multiplication
in the frequency domain?
Other options:
1. I also notice that there is a convolve function in Numeric but that it is only 1D. If my psf is a gaussian i.e. is symmetric, is there a
way of doing 2 1D convolutions to produce a 2D one?
2. I believe it can also be done in matrix form if the image is converted
to a vector and the psf converted to a block circulant form. If the psf is only 5*5 then the matrix would be 25*25, BUT don't I need to first
pad out the psf to the same size as the image (512*512)
in which case the matrix would be way too big!
Many questions I know, but does someone know the best way to do it?
Thanks,
Karen Collier c9603085@zeus.ac.hud.uk
_______________
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________