In [26]:
from pylab import *
import ocrolib
from scipy.ndimage import filters,interpolation
from scipy import stats
from ocrolib import lineest
reload(lineest)


Out[26]:
<module 'ocrolib.lineest' from 'ocrolib/lineest.pyc'>

Generate Distorted Image


In [27]:
figsize(8,8)
image = 1-ocrolib.read_image_gray("010036.bin.png")
image = interpolation.affine_transform(image,array([[1,0.03],[0,1]]),offset=(-30,0),output_shape=(100,700),order=0)
imshow(image,cmap=cm.gray)
h,w = image.shape


MvNormalizer


In [28]:
reload(lineest)
mv = lineest.MvNormalizer()
mv.measure(image)

In [29]:
imshow(mv.normalize(image,order=0),cmap=cm.gray)


Out[29]:
<matplotlib.image.AxesImage at 0x607ae50>

Lineest Normalizer


In [30]:
reload(lineest)
le = lineest.load_normalizer("en-mixed.lineest")
le


Out[30]:
<ocrolib.lineest.LineestNormalizer instance at 0x5ed8050>

In [31]:
le.measure(image)

In [32]:
imshow(le.normalize(image),cmap=cm.gray,interpolation='nearest')


Out[32]:
<matplotlib.image.AxesImage at 0x66fbf50>

In [33]:
imshow(le.normalize(image,order=0)[:,:40],cmap=cm.gray,interpolation='nearest')


Out[33]:
<matplotlib.image.AxesImage at 0x6bf08d0>

Saved MvNormalizer


In [34]:
reload(lineest)
le = lineest.load_normalizer("../models/mvnorm-24.lnorm")
le.measure(image)
imshow(le.normalize(image),cmap=cm.gray)
le.target_height


Out[34]:
24

Saved Gradnorm (NB: no deskewing)


In [35]:
reload(lineest)
le = lineest.load_normalizer("../models/gradnorm-48.lnorm")
le.measure(image)
imshow(le.normalize(image),cmap=cm.gray)
le.target_height


Out[35]:
48

In [35]: