Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added additional output options to ocropus-binarize added sanity checks to output of binarization
- Loading branch information
tmb
committed
Mar 19, 2010
1 parent
b1c04d8
commit b38390b
Showing
12 changed files
with
269 additions
and
32 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/python | ||
import code,pickle,sys,os,re,ocropy | ||
from ocropy import dbtables,binnednn | ||
from pylab import * | ||
from optparse import OptionParser | ||
|
||
parser = OptionParser(""" | ||
usage: %prog [options] clusters.db | ||
""") | ||
|
||
parser.add_option("-D","--display",help="display chars",action="store_true") | ||
parser.add_option("-v","--verbose",help="verbose output",action="store_true") | ||
|
||
(options,args) = parser.parse_args() | ||
|
||
if len(args)!=2: | ||
parser.print_help() | ||
sys.exit(0) | ||
|
||
input = args[0] | ||
output = args[1] | ||
|
||
ion() | ||
show() | ||
|
||
table = dbtables.Table(input,"chars") | ||
table.converter("image",dbtables.SmallImage()) | ||
table.create(image="blob",count="integer",cls="text",classes="text",key="text") | ||
|
||
classes = [row[0] for row in table.query("select distinct(cls) from chars order by cls")] | ||
|
||
total = 0 | ||
for cls in classes: | ||
print "# clustering",cls | ||
binned = binnednn.BinnedNN() | ||
total = 0 | ||
for row in table.get(cls=cls): | ||
raw = row.image | ||
if raw.shape[0]>255 or raw.shape[1]>255: continue | ||
raw = raw/float(amax(raw)) | ||
binned.add(raw,cls) | ||
total+=1 | ||
if total%1000==0: | ||
print total,"chars" | ||
print binned.stats() | ||
binned.save(output) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ | |
from simplerec import CmodelLineRecognizer | ||
from ocropus import * | ||
from iulib import * | ||
|
||
from quickcheck import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import matplotlib | ||
matplotlib.use('GTK') | ||
|
||
import gtk | ||
def gtk_yield(): | ||
while gtk.events_pending(): | ||
gtk.main_iteration(False) |
Oops, something went wrong.