Ask Your Question
0

Smooth or blur image edges using opencv

asked 2016-12-01 01:35:43 -0600

OmerAslam gravatar image

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);
input.copyTo(blurred);
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

edit retag flag offensive close merge delete

Comments

Have you find any solution yet??

abdullah yasin gravatar imageabdullah yasin ( 2018-11-10 01:28:55 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-12-01 03:29:55 -0600

LBerger gravatar image

You can try :

  1. blur all your image
  2. apply DistanceTransform to your mask
  3. use Addweighted with original and blur image with a weight function of distance transform results (may be a threshold like 20 )
edit flag offensive delete link more

Comments

LBerger can u give me some code

OmerAslam gravatar imageOmerAslam ( 2016-12-01 03:36:05 -0600 )edit

with your my output is not equal Mat output. read this post too

LBerger gravatar imageLBerger ( 2016-12-01 05:49:34 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-12-01 01:34:31 -0600

Seen: 3,494 times

Last updated: Dec 01 '16