title: Image edge smoothing with opencv
body: <p>I am trying to smooth output image edges using opencv framework, I am trying following steps. Steps took from here <a href="https://stackoverflow.com/a/17175381/790842">https://stackoverflow.com/a/17175381/790842</a></p>
  
  <pre><code>int lowThreshold = 10.0;
  int ratio = 3;
  int kernel_size = 3;
  
  Mat src_gray,detected_edges,dst,blurred;
  
  /// Convert the image to grayscale
  cvtColor( result, src_gray, CV_BGR2GRAY );
  
  /// Reduce noise with a kernel 3x3
  cv::blur( src_gray, detected_edges, cv::Size(5,5) );
  
  /// Canny detector
  cv::Canny( detected_edges, detected_edges, lowThreshold, lowThreshold*ratio, kernel_size );
  
  //Works fine upto here I am getting perfect edge mask    
  
  cv::dilate(detected_edges, blurred, result);
  
  //I get Assertion failed (src.channels() == 1 &amp;&amp; func != 0) in countNonZero ERROR while doing dilate
  
  result.copyTo(blurred, blurred);
  
  cv::blur(blurred, blurred, cv::Size(3.0,3.0));
  
  blurred.copyTo(result, detected_edges);
  
  UIImage *image = [UIImageCVMatConverter UIImageFromCVMat:result];
  </code></pre>
  
  <p>I want help whether if I am going in right way, or what am I missing?</p>
  
  <p>Thanks for any suggestion and help.</p>
  
  <p><strong>Updated:</strong></p>
  
  <p>I have got an image like below got from <strong>grabcut</strong> algorithm, now I want to apply edge smoothening to the image, as you can see the image is not smooth.
  <img src="https://i.stack.imgur.com/Ro98n.png" alt="enter image description here"></p>