Commit 3399a593 authored by Théophile BORNON's avatar Théophile BORNON

Borders handling in filters

parent 72afd0b3
......@@ -348,8 +348,11 @@ namespace S04_Projet
int x = x0 + (i % size) - ((size - 1) / 2);
int y = y0 + (i / size) - ((size - 1) / 2);
if (x >= 0 && x < opt.width && y >= 0 && y < opt.height)
{
if (x < 0) x = 0;
else if (x >= opt.width) x = opt.width - 1;
if (y < 0) y = 0;
else if (y >= opt.height) y = opt.height - 1;
if (rgb == RGB.R)
matrix[(i % size), (i / size)] = Pixels[x, y].r;
else if (rgb == RGB.G)
......@@ -357,7 +360,6 @@ namespace S04_Projet
else if (rgb == RGB.B)
matrix[(i % size), (i / size)] = Pixels[x, y].b;
}
}
return matrix;
}
......
......@@ -54,7 +54,7 @@ namespace S04_Projet
{ 0, -1, 0 }
};
MyImage imgg = new MyImage("img/coco.bmp");
MyImage imgg = new MyImage("img/flocon.bmp");
imgg.ApplyConvFilter(identityFilter, 1).Save("id.bmp");
imgg.ApplyConvFilter(edgeDetect1Filter, 1).Save("edge1.bmp");
imgg.ApplyConvFilter(edgeDetect2Filter, 1).Save("edge2.bmp");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment