-
Notifications
You must be signed in to change notification settings - Fork 593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replaces multi-var str() concat with %-format #124
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -343,15 +343,15 @@ def process1(job): | |
binary = ocrolib.read_image_binary(fname) | ||
except IOError: | ||
if ocrolib.trace: traceback.print_exc() | ||
print_error("cannot open either " + base+".bin.png" + " or " + fname) | ||
print_error("cannot open either %s.bin.png or %s" % (base, fname)) | ||
return | ||
|
||
checktype(binary,ABINARY2) | ||
|
||
if not args.nocheck: | ||
check = check_page(amax(binary)-binary) | ||
if check is not None: | ||
print_error(fname + " SKIPPED " + check + " (use -n to disable this check)") | ||
print_error("%s SKIPPED %s (use -n to disable this check)" % (fname, check)) | ||
return | ||
|
||
if args.gray: | ||
|
@@ -365,22 +365,22 @@ def process1(job): | |
scale = psegutils.estimate_scale(binary) | ||
else: | ||
scale = args.scale | ||
print_info("scale " + str(scale)) | ||
print_info("scale %f" % (scale)) | ||
if isnan(scale) or scale>1000.0: | ||
print_error("%s: bad scale (%g); skipping\n"%(fname,str(scale))) | ||
print_error("%s: bad scale (%g); skipping\n" % (fname, scale)) | ||
return | ||
if scale<args.minscale: | ||
print_error("%s: scale (%s) less than --minscale; skipping\n"%(fname,str(scale))) | ||
print_error("%s: scale (%g) less than --minscale; skipping\n" % (fname, scale)) | ||
return | ||
|
||
# find columns and text lines | ||
|
||
if not args.quiet: print_info("computing segmentation") | ||
segmentation = compute_segmentation(binary,scale) | ||
if amax(segmentation)>args.maxlines: | ||
print_error(fname + ": too many lines" + str(amax(segmentation))) | ||
print_error("%s too many lines %g" % (fname, amax(segmentation))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Colon |
||
return | ||
if not args.quiet: print_info("number of lines"+ str(amax(segmentation))) | ||
if not args.quiet: print_info("number of lines %g" % amax(segmentation)) | ||
|
||
# compute the reading order | ||
|
||
|
@@ -410,7 +410,7 @@ def process1(job): | |
if args.gray: | ||
grayline = psegutils.extract_masked(gray,l,pad=args.pad,expand=args.expand) | ||
ocrolib.write_image_gray("%s/01%04x.nrm.png"%(outputdir,i+1),grayline) | ||
print_info("%6d "%i + fname + " %4.1f "% + scale + " " + str(len(lines))) | ||
print_info("%6d %s %4.1f %d" % (i, fname, scale, len(lines))) | ||
|
||
if len(args.files)==1 and os.path.isdir(args.files[0]): | ||
files = glob.glob(args.files[0]+"/????.png") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,15 +106,15 @@ def dshow(image,info): | |
|
||
def process1(job): | ||
fname,i = job | ||
print_info("#" + fname) | ||
if args.parallel<2: print_info("=== "+fname+ " " +str(i)) | ||
print_info("# %s" % (fname)) | ||
if args.parallel<2: print_info("=== %s%-3d" % (fname, i)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a space here again. This currently looks like
|
||
comment = "" | ||
raw = ocrolib.read_image_gray(fname) | ||
dshow(raw,"input") | ||
# perform image normalization | ||
image = raw-amin(raw) | ||
if amax(image)==amin(image): | ||
print_info("# image is empty" + fname) | ||
print_info("# image is empty: %s" % (fname)) | ||
return | ||
image /= amax(image) | ||
|
||
|
@@ -192,7 +192,7 @@ def process1(job): | |
bin = 1*(flat>args.threshold) | ||
|
||
# output the normalized grayscale and the thresholded images | ||
print_info(fname+" lo-hi (%.2f %.2f) angle %4.1f"%(lo,hi,angle) + comment) | ||
print_info("%s lo-hi (%.2f %.2f) angle %4.1f %s" % (fname, lo, hi, angle, comment)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This produces sometimes double spaces, e.g.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or is this just reserving enough space for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The first two spaces are because of |
||
if args.parallel<2: print_info("writing") | ||
if args.debug>0 or args.show: clf(); gray();imshow(bin); ginput(1,max(0.1,args.debug)) | ||
if args.output: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason you do here first a
%f
and not as in the subsequent lines%g
? (This looks inconsistent also it may not be changing much, because the numbers for scale are normally not that large.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%f
by default is more precise,19.493589
seemed preferable to19.4936
to me in this case. In the other instances, I just stuck with the original formatting since I couldn't test it. I'm not a big fan of exponential format.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, let us leave it as you have here then.