我有一个cv :: Mat,其中填充有1和0。它在白色背景的一条简单的弯曲的黑道路。 我想使用cv :: blur来模糊图像,如下所示:
cv::Mat result;
cv::blur(curvePath, result, cv::Size(10, 10));
弯曲路径的构造如下,其中completeBandPath是cinder :: Path2d实例,该实例包围了应该为黑色(或零)的区域:
Rectf bb = completeBandPath.calcPreciseBoundingBox();
const int matHeight = static_cast<int>(bb.getHeight());
const int matWidth = static_cast<int>(bb.getWidth());
cv::Mat curvePath = cv::Mat(matHeight, matWidth, CV_32F, 1);
for (int i = 0; i < matWidth; i++) {
for (int j = 0; j < matHeight; j++) {
if (completeBandPath.contains(vec2( i+bb.getUpperLeft().x, j+bb.getUpperLeft().y ))) {
curvePath.at<float>(j, i) = 0;
}
}
}
curvePath看起来像这样:
模糊后的结果看起来像这样(减去上边界,裁剪效果很差):
如何避免彩色边缘模糊以及边缘从黑到白过渡良好?
非常感谢