Scilab Home page | Wiki | Bug tracker | Forge | Mailing list archives | ATOMS | File exchange
Scilab-Branch-6.1-GIT
Change language to: English - Português - 日本語 - Русский

# convol2d

discrete 2-D convolution, using fft.

### Syntax

`C = convol2d(A, B)`

### Parameters

A

a real or complex 2-D array.

B

a real or complex 2-D array.

C

a real or complex 2-D array.

### Description

`convol2d` uses fft to compute the full two-dimensional discrete convolution. The dimensions of the result `C` are given by `size(A)+size(B)-1`. The indices of the center element of `B` are defined as `floor((size(B)+1)/2)`.

### Examples

```s = [1 2 1; 0 0 0; -1 -2 -1] // Sobel horizontal edge kernel
A = zeros(10,10); A(3:7,3:7) = 1
C = convol2d(s, A);
clean(C)```
```--> s = [1 2 1; 0 0 0; -1 -2 -1] // Sobel horizontal edge kernel
s  =
1.   2.   1.
0.   0.   0.
-1.  -2.  -1.

--> A = zeros(10,10); A(3:7,3:7) = 1
A  =
0.   0.   0.   0.   0.   0.   0.   0.   0.   0.
0.   0.   0.   0.   0.   0.   0.   0.   0.   0.
0.   0.   1.   1.   1.   1.   1.   0.   0.   0.
0.   0.   1.   1.   1.   1.   1.   0.   0.   0.
0.   0.   1.   1.   1.   1.   1.   0.   0.   0.
0.   0.   1.   1.   1.   1.   1.   0.   0.   0.
0.   0.   1.   1.   1.   1.   1.   0.   0.   0.
0.   0.   0.   0.   0.   0.   0.   0.   0.   0.
0.   0.   0.   0.   0.   0.   0.   0.   0.   0.
0.   0.   0.   0.   0.   0.   0.   0.   0.   0.

--> C = convol2d(s, A);
--> clean(C)
ans  =
0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.
0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.
0.   0.   1.   3.   4.   4.   4.   3.   1.   0.   0.   0.
0.   0.   1.   3.   4.   4.   4.   3.   1.   0.   0.   0.
0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.
0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.
0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.
0.   0.  -1.  -3.  -4.  -4.  -4.  -3.  -1.   0.   0.   0.
0.   0.  -1.  -3.  -4.  -4.  -4.  -3.  -1.   0.   0.   0.
0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.
0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.
0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.
```

• conv2 — discrete 2-D convolution.
• conv — discrete 1-D convolution.
• convol — convolution
• real — partie réelle de nombres, polynômes ou fractions complexes
• clean — nettoie une matrice (arrondi à zéro des termes très petits)

### History

 Version Description 5.4.0 Function convol2d introduced.