2d convolution via frequency domain multiplication
I spent this morning tangoing with convolution and the discrete fourier transform. My goal when I first came in was to see if applying a linear filter to a Markov field gives you another Markov field (intuitively, it seems like it should give you one with neighborhoods of larger width). Since applying a linear filter is the same as convolution, I needed a nice way to handle the application of an energy function to convolution products– this seemed like the good time to apply the oft quoted ‘convolution is multiplication in the frequency domain’ trick: since we’re dealing with finite everything (the field is on a finite graph, and has finite states), I could use matrix multiplication to express the convolution.
Surprisingly, I couldn’t find a single reference which had a matrix formulation of the DFT; I’m recording it here for anyone who might find it useful. Let
be the
-th primitive root of unity, and define the Fourier matrix
by
, then the (2d) DFT of the matrix
is

and the IDFT is
That is one step in finding a matrix formulation of convolution. Assume we have convolution kernel
and we’d like to calculate
where
is an image, and
as is usual. If we naively take the DFTs, then
and
are not compatible, but notice that convolving with
is the same as convolving with a bigger kernel
, where we define the zero-padding operator to satisfy
A further point to notice is that we need to worry about aliasing, since we are dealing with discrete sums of frequencies. In particular, if when we multiply in the frequency domain we get frequencies
that don’t fit in the range
, when we attempt to reconstruct, we’ll get higher frequencies masquerading as lower frequencies. The solution is to see that the highest frequencies you can get are the sum of the highest frequencies in both the kernel and the matrix. So if you zeropad the two matrices appropriately and then perform the frequency domain multiplication, you should be set.
Possibly relevant posts:
- Exactness of differential forms (7/28/2007)
- Inner products (6/7/2006)
- Systems of Sets (10/7/2005)
I would like to discuss this with you if you have the time. I have an application in adaptive optics where I use convolutions and FT’s and I would like to put them in matrix notation (I need to invert certain relationships in order to solve for a bigger problem).
Amir Give’on
Comment by Amir Give'on — 10/18/2006 @ 12:34 am