1
$\begingroup$

In Matlab, how can I calculate the discrete-space Fourier transform of a mean which takes the average of 4 adjacent points, with this kernel

$$\begin{pmatrix} 0 &1& 0\\ 1 &0& 1\\ 0 &1& 0\\ \end{pmatrix}$$

$\endgroup$
  • 1
    $\begingroup$ not quite sure what you mean, here. Assuming you mean the 2D-DFT: Matlab documentation, "2D-DFT", will lead you to the right function. NB: probably not the info you're looking for, unless you're only planning to average 3×3 images. $\endgroup$ – Marcus Müller Nov 21 '18 at 18:36
0
$\begingroup$

The 2D FIR 3x3 filter kernel you have provided is not finding the mean but the sum of samples. So you have to divide by 4 to get the mean. Furthermore it does not sum adjacent samples but diagonal ones.

Then if you create a 3x3 matrix h = [0,1,0 ; 1,0,1; 0,1,0] in matlab and you wish to perform a 2D-DFT on that matix h, then the following function call H = fft2(h) will return you the 3x3 discrete Fourier transform $H[k_1,k_2]$ (k1 rows, k2 columns) samples of the filter $h[n_1,n_2]$ as:

$$ H[k_1,k_2] = e^{ -j \frac{2\pi}{3} k_1} + e^{ -j \frac{2\pi}{3} k_2} + e^{ -j \frac{2\pi}{3} 2 k_1}e^{ -j \frac{2\pi}{3} k_2} + e^{ -j \frac{2\pi}{3} k_1}e^{ -j \frac{2\pi}{3} 2 k_2} $$ for $k_1,k_2 = 0,1,2$.

If you want to compute a larger $N \times N$ 2D-DFT on $h[n_1,n_2]$, then the following call H = fft2(h,N,N) will return you an $N \times N$ result as: $$ H[k_1,k_2] = e^{ -j \frac{2\pi}{N} k_1} + e^{ -j \frac{2\pi}{N} k_2} + e^{ -j \frac{2\pi}{N} 2 k_1}e^{ -j \frac{2\pi}{N} k_2} + e^{ -j \frac{2\pi}{N} k_1}e^{ -j \frac{2\pi}{N} 2 k_2} $$ for $k_1,k_2 = 0,1,...,N-1$.

$\endgroup$

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.