2
$\begingroup$

I have the following problem with convolution operators. I know that if I have a filter $g$, then the adjoint filter would be given by $h(x,y)=g(-x,-y)$, so that $\langle g * u,v \rangle = \langle u,f *v\rangle $ holds for the $\mathbb{R}^2$ scalar product.

I also know that $Ff(-\omega) = \overline{Ff(\omega)}$ for real $f$. So it seems I should hold that

$ h(x,y) = F^{-1}\overline{Fg} = F^{-1}Fg(-x,-y) = g(-x,-y)$

However when I compare

g = ifft2(fft2(g))

( for some gaussian kernel, e.g matlab: g = padarray(fspecial('gaussian',11,2),[5,5]) )

and

h = ifft2(conj(fft2(g))

I get the expected result for g Normal Gaussian

But when I compute h, which should be equal to g because g is gaussian

the result is shifted by (1,1) Shifted Gaussian

which is somewhat unexpected.
I wonder if there is some subtlety in the discrete <-> continuous conversion that I have missed ?

$\endgroup$
3
$\begingroup$

Complex conjugation in the discrete Fourier domain should result in spatial domain horizontal and vertical mirroring around the origin. The origin happens to be at row 1 column 1, as is evident from MATLAB's definition of FFT, with Y = fft(X):

$$Y(k)= \sum^n_{j=1} X(j) e^{−2πi(j−1)​(k−1)/n}$$

For $j = 1$ the phase is zero for all $k$ so anything on column 1 or on row 1 will stay there through complex conjugation. Column 11 and row 11 are each 10 steps from the origin horizontally or vertically, as are column 12 and row 12 if you measure the distance across the border. So the reversal swaps the data between columns 11 and 12, and between rows 11 and 12. Figure 1 below illustrates the mirroring.

Row/column indices to phases
Figure 1. Row or column indices and the corresponding phases of frequency $k = 2$ plotted as angles on the circle.

If the dimensions of your data were even rather than odd as they are now, there would be a middle row and a middle column that would be at equal distance from the origin both directly and across the border.

$\endgroup$
2
  • $\begingroup$ Thank you for commenting :) I think I am starting to understand. So in case of odd-sized data I should pad one row/column less to account for the fact that the origin really is at (1,1). For even-sized data, interestingly the same approach (padding one row/column less) works and gives the right result, but I have to admit I do not understand why. If I consider the "wheel" you posted, then having 22 rows/cols should work out just fine without uneven padding ? $\endgroup$ – mirrormere Jun 21 '16 at 9:21
  • $\begingroup$ Your last statement is correct. This is all complementary to an odd-sized DFT having no Nyquist frequency (sampling frequency / 2) bin, and even-sized DFT having it, just the domains have been swapped. $\endgroup$ – Olli Niemitalo Jun 21 '16 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.