Line detection in sketches
<p>I am looking for a way to find strokes in hand-drawn sketches. My actual approach is to apply adaptive thresholding and findContours from OpenCV. The issue with this is that findContours gives me the right hand side and the left hand side, the upper und lower contour of one single stroke. Is there any way to just derive one contour representation out of a hand-drawn stroke?</p>

<p>Thanks in advance</p>

<p>Edited:</p>

<p>Here is the code and an image of what I have achieved so far:</p>

<p>First I applied adaptive Thresholding to the initial image:</p>

<pre><code>Imgproc.GaussianBlur(image, image, new Size(5, 5), 3);
Mat thresholded = Mat.zeros(image.size(), CvType.CV_8U);
</code></pre>

<p>Then I applied findCountours on the thresholded image and additionally approxPolyDB on each contour. </p>

<pre><code>Imgproc.findContours(thresholded, contours, hierarchy, Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE, new Point(0,0));

List&lt;MatOfPoint&gt; refinedContours = new ArrayList&lt;MatOfPoint&gt;();
for (int i = 0; i &lt; contours.size(); i++) {
    MatOfPoint2f approx = new MatOfPoint2f();
    Imgproc.approxPolyDP(mop2mop2f(contours.get(i)), approx, 6, true);
}
</code></pre>

<p>Afterwards I splitter each contour at points where the angle is bigger than a fixed threshold. As a last step I deleted all contours that aren't longer than a given threshold.</p>

<p><a href="http://i.stack.imgur.com/DOdoI.jpg" rel="nofollow">In the picture you can see the thresholded image as the final contours</a></p>

<p>My aim is to avoid parallel contours in a way that there is only one contour for one stroke in the sketched image.</p>

<p>Thanks</p>