Jimwalks
Jimwalks

Reputation: 335

OpenCV - Extracting arrows from chart

I'm trying to perform OpenCV on a flow chart to extract the structure (image 1). All images are computer generated. I can extract the blocks fine, and remove them from the image so we are just left with the arrows (image 3).

The issue is I'm unsure how to extract the connections. I.e. when I apply HoughLinesP there is large number of lines generated for each arrow (image 2). Does anyone know a method of extracting the lines such that I only get one 'line' for each arrow extracted?

Original image HoughLinesP applied to arrows Arrows segmented from image

Upvotes: 3

Views: 1367

Answers (1)

Photon
Photon

Reputation: 3222

Since the image has no noise, using Hough transform is not optimal.

I would binarize the image so that I get all non-white pixels from the image. Then, using a matched filter, I would find vertical and horizontal line segments. Arrows in any of the four directions can be found in a similar fashion.

Filter for a line of 2 pixels thickness can be something like:

0 0 0 0 0 0
0 0 0 0 0 0
1 1 1 1 1 1
1 1 1 1 1 1
0 0 0 0 0 0
0 0 0 0 0 0

Upvotes: 3

Related Questions