Skip to content

Commit

Permalink
Bypass Leptonica error message with pixGenHalftoneMask()
Browse files Browse the repository at this point in the history
Fixes #292
  • Loading branch information
scottb89 authored and amitdo committed Jun 5, 2016
1 parent 1958b3b commit 3dcb5c2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions textord/imagefind.cpp
Original file line number Diff line number Diff line change
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 3dcb5c2

Please sign in to comment.