Re: ISO an algorithm



On Apr 12, 2:18 pm, Helmut Giese <hgi...@xxxxxxxxxxxxx> wrote:

The idea then, is that if your bit-grabbing process is exact (i.e.
screen capture, *not* paper scanning),

yes, this is exact. And I can isolate each digit so that it's all by
itself within its bounding box.

That's good news: no extra work needed to separate them :o)

the same method can be made
reasonably efficient thanks to the hashing step, so you can try many 1-
pixel shifts of your frame.

Sorry, but I don't grok the method. Care to elaborate a bit or do you
have a link maybe?

The idea is: given a precise rectangle in the image, the lookup of a
match (if any) is *fast*, since your font database is essentially a
hashtable whose keys are the complete bitstrings of the individual
characters.

But forget about the 1-pixel shifts, I realize they're useless since
you can always normalize your bitmaps to be anchored to (say) the top
and left borders of the rectangle, ie have at least one black pixel in
both borders.

To summarize:

(1) Database preparation:

set w [upper_bound_of_all_char_widths]
set h [upper_bound_of_all_char_heights]
foreach f $fonts {
foreach g $glyphs($f) {
set bmap [topleftnormalize [render $f $g $w $h]]
# $bmap could be a bignum, or a binary string,
# or your ascii display above, or even a hex string
set tab($bmap) [list $f $g]
}
}

(2) Lookup

foreach bmap [extract_isolated_chars] {
set bmap [pad_to_rect $w $h]
if {[info exists tab($bmap)]} {
puts "Found: $tab($bmap)"
} else {
puts "Not found: [pretty $bmap]
}
}

-Alex
.



Relevant Pages