title: Removing points and small lines in opencv
body: <p><br>Is there any function or algorithm to remove points and small/short lines from the image. I have made a metric map for robot. I have used algorithm to make a skeleton from the image. What I need is, to remove small/short lines and point to get smooth lines- see the <a href="http://www.ulozisko.sk/obrazky/608556/pic.png" rel="nofollow">picture</a>. I am new in opencv, so maybe it is simple problem.</p>
  
  <p>Any suggestion? Thanks.</p>
  
  <p>To make skeleton I use this code</p>
  
  <pre><code>#include "opencv2/imgproc/imgproc.hpp"
  #include "opencv2/highgui/highgui.hpp"
  #include "highgui.h"
  #include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  
  using namespace cv;
  
  int main( int argc, char** argv )
  {
  
  cv::Mat img = cv::imread("test4.png", 0);
  
  cv::Mat skel(img.size(), CV_8UC1, cv::Scalar(0));
  
  cv::Mat temp(img.size(), CV_8UC1);
  
  cv::Mat sub_mat = Mat::ones(img.size(), img.type())*255;
  
  cv::Mat eroded;
  
  cv::Mat element = cv::getStructuringElement(cv::MORPH_CROSS, 
  
  cv::Size(3, 3));
  
  cv::subtract(sub_mat, img, img);
  
  
  bool done;      
  do
  {
    cv::erode(img, eroded, element);
    cv::dilate(eroded, temp, element); // temp = open(img)
    cv::subtract(img, temp, temp);
    cv::bitwise_or(skel, temp, skel);
    eroded.copyTo(img);
  
    done = (cv::countNonZero(img) == 0);
  } while (!done);
  
  
  cv::subtract(sub_mat, skel, skel);
  
  cv:imwrite("skelet.png",skel);
  
  cv::imshow("Skeleton", skel);
  
  cv::waitKey(0);
  
  return 0;
  }
  </code></pre>