1. 使用3×3的核进行卷积实现浮雕效果
-1 , -1 ,0
-1 , 0 , 1
0 , 1 ,1
double[,] h = { { -1, -1, 0 }, { -1, 0, 1 }, { 0, 1, 1 } };
private Image<Bgr,byte> Juanji(Image<Bgr,byte>pic)
{
Image<Bgr, byte> output = new Image<Bgr, byte>(pic.Size);
double[,] h = { { -1, -1, 0 }, { -1, 0, 1 }, { 0, 1, 1 } };
double b = 0, g = 0, r = 0;
for (int i=1;i<pic.Width-1;i++)
{
for(int j = 1; j < pic.Height-1; j++)
{
b = 0;g = 0;r = 0;
for(int m = -1; m <= 1; m++)
{
for(int n = -1; n <= 1; n++)
{
b += pic[j+m, i+n].Blue * h[m + 1, n + 1];
g += pic[j + m, i + n].Green * h[m + 1, n + 1];
r += pic[j + m, i + n].Red * h[m + 1, n + 1];
}
}
output[j, i] = new Bgr(b,g,r);
}
}
return output;
}