#图像锐化
拉普拉斯: 导数f(x,y)=f(x+1,y)+f(x−1,y)+f(x,y+1)+f(x,y−1)−4f(x,y)
可以扩展到8邻域:
Mat Sharpen(Mat input, int percent, int type)
{
Mat result;
Mat s = input.clone();
Mat kernel;
switch (type)
{
case 0:
kernel = (Mat_(3, 3) <<
0, -1, 0,
-1, 4, -1,
0, -1, 0
);
case 1:
kernel = (Mat_(3, 3) <<
-1, -1, -1,
-1, 8, -1,
-1, -1, -1
);
default:
kernel = (Mat_(3, 3) <<
0, -1, 0,
-1, 4, -1,
0, -1, 0
);
}
filter2D(s, s, s.depth(), kernel);
result = input + s * 0.01 * percent;
return result;
}