使用opencv平滑或模糊图像边缘

时间:2016-11-30 12:53:27

标签: c++ image opencv smooth edges

我想使用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);

这是我输入的图像,我的输出和所需的结果 See this

我使用此图片作为输入

Input Image

0 个答案:

没有答案