原图:
高斯模糊:
双边模糊:
掩膜:
代码:
//高斯模糊
//高斯双边模糊
//图像掩膜
void TestBlur() {
bgImage = imread("人像原图.jpg", IMREAD_UNCHANGED);
Mat dst(bgImage.size(), bgImage.type());
cv::GaussianBlur(bgImage, dst, Size(11, 11), 5, 5);
imshow("高斯模糊",dst);
Mat dst2(bgImage.size(), bgImage.type());
cv::bilateralFilter(bgImage, dst2, 15, 100, 5);
imshow("双边模糊", dst2);
Mat kernel = (Mat_<char>(3, 3) << 0, -1, 0, -1, 5, -1, 0, -1, 0);
cv::filter2D(dst2, dst2, dst2.depth(),kernel);
imshow("掩膜", dst2);
waitKey(0);
}