3
$\begingroup$

How can I easily and efficiently detect hand-drawn arrows and their directions from an image?

They're probably drawn lightly, with something like a pencil, on a piece of paper.

If I had implemented a system for fitting straight lines to hand-drawn lines, I'd probably look for 3 lines that roughly shared an endpoint and that formed approximately 45 degree angles. However, this is only half a solution, and I don't know if it's a very good approach.

How should I approach this problem?

If possible, I'd like to have a simple solution over the most efficient solution because I'm a 9th grade math student with limited knowledge, but that's not a requirement

$\endgroup$
2
$\begingroup$

Well, the easiest way to approach this problem would be to obtain the Hough Transform and look for the "signature" of the arrows. In addition and because these lines are drawn on a piece of paper, some thinning might be required because the trace left by the pen will not be a perfect straight line but rather a set of somewhat straight, parallel lines.

OK, but what does all this mean?

The Hough Transform obtains the sum of all pixels in the original image along a profile ($\rho$) set at some angle ($\theta$). For instance, to produce the sum along the top-bottom direction, the algorithm would first add all the pixel values of the first column and produce one value. Then it would sum all values of the second column and produce yet another value and so on until a sum for each column has been produced. Each column's sum now represents one line of data in the transform's output image. This line of data corresponds to some angle ($\theta$). Then, the algorithm rotates the image by some $d\theta$ and repeats the process thus creating a second line of data at some angle $\theta + d\theta$ and so on. This is how this image is produced.

So, the end result of the Hough Transform is to transform lines to points.

Therefore, looking for an arrow now becomes the task of finding 1 "strong" pixel value at some angle $\theta$ and displacement $\rho$ (the middle line of the arrow) that denotes the angle that the arrow is pointing and 2 less "strong" pixel values at angles (approximately) $\theta \pm 45$ (these are the adjacent lines that form the point of the arrow). So, the Hough Transform of an image with 3 arrows is an image with 3 distinct triplets of points.

BUT! A scanned image of those arrows, is not going to be composed of just three lines. Having hand-drawn arrows means having imperfections. These imperfections "spoil" the output of the Hough Transform and instead of a sharp point where there is a line, what you get is a nice fat blob.

This is where thinning will help. Thinning is a morphological operator that will reduce a "fat" line to its thinest representation which will help a lot later on with the Hough Transform.

With this technique, you would have to scan the output of the Hough Transform once to find all the arrows in the image.

Please note that this assumes that the arrows are not co-linear. If you have more than one arrows pointing towards the same direction, along the same line, they will be contributing to the sum of the same accumulator and you would have to make assumptions on the length of each arrow to distinguish how many arrows are there along a line from its pixel value.

The Hough Transform is all about polar coordinates...and summation. The thinning is an improvement.

I guess that there might be ad-hoc ways of scanning the image until an "ink" area is found and then tracing that area with a set of constraints to decide if it is an arrow and which direction it is pointing towards but these would not be as straightforward as the Hough Transform approach.

$\endgroup$
  • $\begingroup$ Thanks a lot for the in-depth response! I'm sure I can understand what you're saying, I'll see what I can put together :) I think in my case, there might be collinear arrows, but never in the same direction. $\endgroup$ – Luke Taylor May 23 '16 at 1:06
  • $\begingroup$ Is this thinning the same as skeletonization? $\endgroup$ – Luke Taylor May 23 '16 at 1:09
  • 1
    $\begingroup$ Glad if you found the response helpful. Thinning is just part of skeletonization. $\endgroup$ – A_A May 23 '16 at 6:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.