0

check this picture out before I explain further: enter image description here How can I count the amount of lines there are from the yellow line to line #5? OCR sounds like overkill, because I don't really care what the text says.

3

Rough outline:

  • scan your image horizontally, pixel-line wise
  • each pixel line eithers contains only black pixels, or some white/yellow pixels: store this information in a boolean array.
  • group the pixel line numbers together, each sequence of non-empty lines and each sequence of empty lines form a group. The non-empty line groups represent the word lines, and the empty-line groups represent the space between the word lines.
  • so what remains is simply counting the groups

To deal with aliasing effects, you will probably have to refine this a little bit, for example, by interpreting pixel lines as empty when they contain only a few number of white pixels, or by expecting a minimum size for any group (see Lars Viklund's comment) . You will have to adapt this to the quality and resolution of your images.

2
  • A reason for a minimum group size may be diacritics adjacent to but not connected to the base glyph of the grapheme. Even in the US alphabet, you've got lowercase i. – Lars Viklund Aug 11 '15 at 10:56
  • @LarsViklund Unless you have some degenerate case (ijijij), it is likely that there is at least one pixel on each line. – user40980 Aug 11 '15 at 13:06

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.