-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gauss.cs
29 lines (26 loc) · 813 Bytes
/
Gauss.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
namespace Lab1_kg_
{
internal class Gauss : MatrixFilter
{
public Gauss()
{
createGaussKernel(3, 2);
}
public void createGaussKernel(int radius, float sigma)
{
int size = 2 * radius + 1;
kernel = new float[size, size];
float norm = 0;
for (int i = -radius; i <= radius; i++)
for (int j = -radius; j <= radius; j++)
{
kernel[i + radius, j + radius] = (float)(Math.Exp(-(i * i + j * j) / (sigma * sigma)));
norm += kernel[i + radius, j + radius];
}
for (int i = 0; i < size; i++)
for (int j = 0; j < size; j++)
kernel[i, j] /= norm;
}
}
}