# Demo iaconvteo

Illustrate the discrete convolution theorem.

# Description

In this demonstration, the convolution theorem is illustrated by comparing the result of the convolution with its equivalent filtering in frequency domain. The convolution used is the periodic discrete convolution with kernel origin at the array origin.

# Script

The image is read and displayed

```1. import ia636 as ia
2.

## Convolution with the Laplacian kernel

The image is convolved (periodicaly) with the 3x3 diagonal gradient:

```1. fd = fin.astype(float)
2. h = array([[-2,-1,0],
3.            [-1, 0,1],
4.            [ 0, 1,2]])
5. g = ia.iapconv2(fd,h)

## Equivalent filter in frequency domain

The 3x3 kernel is zero padded to the size of the input image. Its spectrum is visualized.

```1. hx = zeros(fd.shape)
2. hx[:h.shape[0],:h.shape[1]] = h

## Filtering in the frequency domain

The image is filtered by multiplying its DFT by the frequency mask computed in the previous step.

```1. F = ia.iadft(fd)
2. G = F * H
3. print "Is symmetrical:", ia.iaisdftsym(G)
```Is symmetrical: True
```1. e = abs(g - g_aux)
```Max error: 6.03213447903e-06