Permalink
Browse files

Merge pull request #133 from tmbdev/dewarp-padding2

Dewarp padding
  • Loading branch information...
zuphilip committed Apr 26, 2017
2 parents fc525cb + 86cf136 commit ec076353c385383c1e8fe3a1fae72f03d3e51750
Showing with 5 additions and 2 deletions.
  1. +5 −2 ocrolib/lineest.py
View
@@ -45,8 +45,11 @@ def measure(self,line):
def dewarp(self,img,cval=0,dtype=dtype('f')):
assert img.shape==self.shape
h,w = img.shape
- padded = vstack([cval*ones((h,w)),img,cval*ones((h,w))])
- center = self.center+h
+ # The actual image img is embedded into a larger image by
+ # adding vertical space on top and at the bottom (padding)
+ hpadding = self.r # this is large enough
+ padded = vstack([cval*ones((hpadding,w)),img,cval*ones((hpadding,w))])
+ center = self.center + hpadding
dewarped = [padded[center[i]-self.r:center[i]+self.r,i] for i in range(w)]
dewarped = array(dewarped,dtype=dtype).T
return dewarped

0 comments on commit ec07635

Please sign in to comment.