Skip to content

Commit

Permalink
Merge pull request #340 from amitdo/fix-292
Browse files Browse the repository at this point in the history
Bypass Leptonica error message with pixGenHalftoneMask()
  • Loading branch information
amitdo committed Jun 7, 2016
2 parents 1958b3b + 3dcb5c2 commit 86acff5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions textord/imagefind.cpp
Expand Up @@ -67,11 +67,21 @@ Pix* ImageFind::FindImages(Pix* pix) {
if (pixGetWidth(pix) < kMinImageFindSize ||
pixGetHeight(pix) < kMinImageFindSize)
return pixCreate(pixGetWidth(pix), pixGetHeight(pix), 1);

// Reduce by factor 2.
Pix *pixr = pixReduceRankBinaryCascade(pix, 1, 0, 0, 0);
pixDisplayWrite(pixr, textord_tabfind_show_images);

// Get the halftone mask directly from Leptonica.
//
// Leptonica will print an error message and return NULL if we call
// pixGenHalftoneMask(pixr, NULL, ...) with too small image, so we
// want to bypass that.
if (pixGetWidth(pixr) < kMinImageFindSize ||
pixGetHeight(pixr) < kMinImageFindSize) {
pixDestroy(&pixr);
return pixCreate(pixGetWidth(pix), pixGetHeight(pix), 1);
}
l_int32 ht_found = 0;
Pix *pixht2 = pixGenHalftoneMask(pixr, NULL, &ht_found,
textord_tabfind_show_images);
Expand Down

0 comments on commit 86acff5

Please sign in to comment.