cmatrix.gaussian

cmatrix.gaussian()

Generate Gaussian square base matrix.

Can be used as a generator of differents gaussian “filter type” matrix using an additionnal function mapped to each value (to convolve self matrix for example).

Two mode are avaible :

  • 0 => binomial distribution

  • 1 => regular distribution

In case of regular distribution, you have to instance an odd sized matrix

Parameters

Type

Description

size

int

the size of the square gaussain generated

mode

int

  • 1 : regular distribution

  • 0 : binomial distribution

norm

int

  • 1 : normalize the filter mask

  • 0 : don’t normalize

Returns
Matrix

The generated gaussian matrix

Examples

>>> print(gaussian(3,0,0))
| +1.000 | +2.000 | +1.000 |
| +2.000 | +4.000 | +2.000 |
| +1.000 | +2.000 | +1.000 |
printed
>>> print(gaussian(3,1,0))
| +1.000 | +2.000 | +1.000 |
| +2.000 | +4.000 | +2.000 |
| +1.000 | +2.000 | +1.000 |
printed
>>> print(gaussian(3,0,1))
| +0.062 | +0.125 | +0.062 |
| +0.125 | +0.250 | +0.125 |
| +0.062 | +0.125 | +0.062 |
printed
>>> print(gaussian(3,1,1))
| +0.062 | +0.125 | +0.062 |
| +0.125 | +0.250 | +0.125 |
| +0.062 | +0.125 | +0.062 |
printed