2

enter image description here

I have a x, y coordinates set, that build up a English alphabetical letter/Shape like as in the image. They are not in straight lines because coordinates are captured when a user write them.

I want to find out through a Java application using the coordinates

  • How many straight lines are there
  • How many lines are horizontal
  • How many lines are vertical
  • How many lines are diagonal

For example, for the following image we can see there are approximately 4 straight lines where one is vertical and three is horizontal.

How could I do this? Is there a term/name for this kind of problem?

1 Answers1

2

This problem can be classified either as OCR (Optical Character Recognition; Java has libraries for this) or Edge detection. If you want to implement it yourself you have basicaly 2 main choices:

  • Neural nets
  • Standard von Neumann algorithm

If you are not into neural nets then the easiest way is to use tolerance values. E.g.:

Horizontal line is iff any 2 points are at most x pixels apart and angle of their line is at most y degrees off of the horizontal line.

Possibly relative answer: https://stackoverflow.com/a/3261532/4663542

Community
  • 1
  • 1
cdm
  • 1,360
  • 11
  • 18
  • Recognize the letter is not needed for me. Just want the count of the lines. Seems like "tolerance value" example is a answer for me. What does that technique called, so I can search for a sample code. – Upekha Vandebona Nov 09 '15 at 10:25
  • 1
    I don't think there is a specific term for the technique. The idea is to use a tolerance value or range when comparing two numbers: `a>b-range && a<=b+range` in it's easiest form. But the range can be a function based on some statistical distribution, like Gaussian distribution: https://en.wikipedia.org/wiki/Normal_distribution – cdm Nov 09 '15 at 10:42