我想使用opencv平滑或模糊图像边缘。我在stackoverflow上关注了一些链接,但没有得到准确的结果。
这是我试过的
int lowThreshold = 100;
int ratio = 3;
int kernelSize = 3;
Mat srcGray, cannyEdges, blurred;
cvtColor(input, srcGray, CV_BGR2GRAY);
blur(srcGray, cannyEdges, Size(3, 3));
Canny(cannyEdges, cannyEdges, lowThreshold, lowThreshold * ratio, kernelSize);
int dilation_size = 5;
Mat element = getStructuringElement(MORPH_CROSS,
Size(2 * dilation_size + 1, 2 * dilation_size + 1),
Point(dilation_size, dilation_size));
dilate(cannyEdges, cannyEdges, element);
input.copyTo(blurred);
blur(blurred, blurred, Size(3, 3));
blurred.copyTo(output, cannyEdges);
我使用此图片作为输入