diff --git a/ocrolib/psegutils.py b/ocrolib/psegutils.py index cbe17f3a..7f4fdd91 100644 --- a/ocrolib/psegutils.py +++ b/ocrolib/psegutils.py @@ -90,17 +90,14 @@ def extract(image,y0,x0,y1,x1,mode='nearest',cval=0): try: r = interpolation.shift(sub,(y-y0,x-x0),mode=mode,cval=cval,order=0) if cw > w or ch > h: - n = ones((ch, cw), dtype=r.dtype) pady0, padx0 = max(-y0, 0), max(-x0, 0) - rh, rw = r.shape - n[pady0:rh+pady0,padx0:rw+padx0] = r - r = n + r = interpolation.affine_transform(r, eye(2), offset=(pady0, padx0), cval=1, output_shape=(ch, cw)) return r except RuntimeError: - # workaround for platform differences between 32bit and 64bit + # workaround for platform differences between 32bit and 64bit # scipy.ndimage - dtype = sub.dtype + dtype = sub.dtype sub = array(sub,dtype='float64') sub = interpolation.shift(sub,(y-y0,x-x0),mode=mode,cval=cval,order=0) sub = array(sub,dtype=dtype) diff --git a/tests/text-near-edge.bin.png b/tests/text-near-edge.bin.png new file mode 100644 index 00000000..1f75e7af Binary files /dev/null and b/tests/text-near-edge.bin.png differ