# Filter - Spatial Domain Versus Frequency Domain

Note: This is a followup question of

Suppose, I have an equation of a filter as follows,

$$h(x, y) = \frac{1}{1 + 0.414 (x + y)^{2n}}$$

I know that this is an equation in the spatial domain.

So, this is how I obtain a filtered image:

1. I create a, say, $3\times 3$ kernel using that equation where ($x$: from $0$ to $2$) and ($y$: from $0$ to $2$).

2. I pad the kernel and the image to the same size.

3. I apply FFT to kernel and the image.

4. Multiply them element by element and apply I-FFT to the result.

5. Convert the result to an image format like Bmp and so on.

.

Now, suppose, I have the following equation,

$$H(u, v) = \frac{1}{1 + 0.414(u + v)^{2n}}$$

I know that this is an equation in the frequency domain.

• So, how am I going to create the kernel?

In the previous case, ($x$: $0$ to $2$) and ($y$: $0$ to $2$).

• What would be the starting and ending values of $u$ and $v$ in the loop?
• What would be the procedure to apply the kernel to an image?
• How should I multiply the kernel and the image?
• re: 2. step. You pad them to the same size, right? – Marcus Müller Sep 3 '16 at 10:31
• @MarcusMüller, Yes. – user18425 Sep 3 '16 at 10:31
• @MarcusMüller, No answer !? – user18425 Sep 3 '16 at 14:51

In contrast convolution filter is essentially convolving 2 signals. $$y(t) = \int_{\tau = 0}^{\inf} h(\tau)x(t-\tau)d\tau$$ In 2D, if we have a 3x3 filter kernel, we first multiply the first 3x3 block of the input with the kernel and then shift the kernel by one column. Then we multiply the next 3x3 with kernel and add the overlapping pixel values.