Skip to content

Commit

Permalink
Merge pull request #252 from jze/gpageseg
Browse files Browse the repository at this point in the history
Fix regression in ocropus-gpageseg #251
  • Loading branch information
zuphilip authored Oct 17, 2017
2 parents d823ba4 + c74d2be commit ebd8235
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ocropus-gpageseg
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ parser.add_argument('files',nargs='+')
args = parser.parse_args()
args.files = ocrolib.glob_all(args.files)


def find(condition):
"Return the indices where ravel(condition) is true"
res, = np.nonzero(np.ravel(condition))
return res

def norm_max(v):
return v/np.amax(v)

Expand Down Expand Up @@ -302,7 +306,7 @@ def compute_line_seeds(binary,bottom,top,colseps,scale):
seeds = np.zeros(binary.shape,'i')
delta = max(3,int(scale/2))
for x in range(bmarked.shape[1]):
transitions = sorted([(y,1) for y in np.where(bmarked[:,x])[0]]+[(y,0) for y in np.where(tmarked[:,x][0])])[::-1]
transitions = sorted([(y,1) for y in find(bmarked[:,x])]+[(y,0) for y in find(tmarked[:,x])])[::-1]
transitions += [(0,0)]
for l in range(len(transitions)-1):
y0,s0 = transitions[l]
Expand Down

0 comments on commit ebd8235

Please sign in to comment.