diff --git a/ccmain/tesseractclass.h b/ccmain/tesseractclass.h index 0ac5978332..431b9aed32 100644 --- a/ccmain/tesseractclass.h +++ b/ccmain/tesseractclass.h @@ -206,14 +206,22 @@ class Tesseract : public Wordrec { sub_langs_[i]->set_pix_original(original_pix ? pixClone(original_pix) : nullptr); } - // Returns a pointer to a Pix representing the best available (original) image - // of the page. Can be of any bit depth, but never color-mapped, as that has - // always been dealt with. Note that in grey and color, 0 is black and 255 is + // Returns a pointer to a Pix representing the best available resolution image + // of the page, with best available bit depth as second priority. Result can + // be of any bit depth, but never color-mapped, as that has always been + // removed. Note that in grey and color, 0 is black and 255 is // white. If the input was binary, then black is 1 and white is 0. // To tell the difference pixGetDepth() will return 32, 8 or 1. // In any case, the return value is a borrowed Pix, and should not be // deleted or pixDestroyed. - Pix* BestPix() const { return pix_original_; } + Pix* BestPix() const { + if (pixGetWidth(pix_original_) == ImageWidth()) + return pix_original_; + else if (pix_grey_ != NULL) + return pix_grey_; + else + return pix_binary_; + } void set_pix_thresholds(Pix* thresholds) { pixDestroy(&pix_thresholds_); pix_thresholds_ = thresholds;