When I was trying to OCR screenshots a few years ago, I collected a directory full of snippets of the possible characters, and then wrote a helper script to find which pixels to sample to eliminate the most possibilities at each step and save the results into a HoHoHo...H search tree/dictionary (each leaf node being the character found, and other nodes containing pixel coordinates to check and a pair of hashrefs to follow depending on the pixel color).

That way the characters could be determined from 5-10 samples instead of a full comparison, and variable width characters were supported. Sampling a pixel further right than a potential character's size could not eliminate it as a possibility; the tree would eventually prefer a pixel that could eliminate the narrower characters.

All my images were downsampled to 1-bit per pixel to keep it simple, and the start position was known relative to the window coordinates, so that helped a bunch.

Perhaps you could try doing a search for a known character and then scan outwards from that? Something vaguely like /01110.{$img_width_minus5}10001.{$img_width_minus5}10001.{$img_width_minus5}01110/ to search for an 'o' shape anywhere in the image. Once you've found one character, then you've found the grid.


In reply to Re: Subimage replacement script by SuicideJunkie
in thread Subimage replacement script by ohcamacj

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.