Ask Your Question

Revision history [back]

Smooth or blur image edges using opencv

I want to feathere smooth or blur image edges using opencv.

This is what i tried

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);
blur(blurred, blurred, Size(3, 3));
blurred.copyTo(output, cannyEdges);

This is the image of my input, my output and desired result image description

i am using this image as input image description