Optimized OCR black/white pixel algorithm

前端 未结 7 1906
被撕碎了的回忆
被撕碎了的回忆 2021-02-06 06:30

I am writing a simple OCR solution for a finite set of characters. That is, I know the exact way all 26 letters in the alphabet will look like. I am using C# and am able to easi

7条回答
  •  太阳男子
    2021-02-06 07:00

    One way would be to identify a pixel that's black in roughly half of the letters and white in the other set. This can then be used to split the letters into two groups, using the same algorithm on both halves recursively, until you have reached individual characters.

    If you can't find a single pixel that splits the sets into two, you may have to go to a group of two or more pixels, but hopefully using single pixels ought to be good enough.

    To find the pixel, start with an array of integers, the same size as your letters, initialize all elements to 0, then increment the elements if the corresponding pixel in a letter is (say) black. The ones you're interested in are the ones in the (roughly) 10≤sum≤16 range (for the top level, lower levels would need to use other bounds).

提交回复
热议问题