-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dilation.cs
35 lines (31 loc) · 932 Bytes
/
Dilation.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
30
31
32
33
34
35
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Filters
{
class Dilation : Filters
{
protected override Color сonvertPixel(Bitmap sourceMap, int x, int y)
{
int radiusX = 2;
int radiusY = 2;
Color[] arr =new Color[25];
int i = 0;
for (int l = -radiusY; l <= radiusY; l++)
for (int k = -radiusX; k <= radiusX; k++)
{
int idX = clamp(x + k, 0, sourceMap.Width - 1);
int idY = clamp(y + l, 0, sourceMap.Height - 1);
arr[i] = sourceMap.GetPixel(idX,idY);
i++;
}
IComparer com = new ColorComparer();
Array.Sort(arr, com);
return arr[24];
}
}
}