Fixed BestPix to always return the highest resolution available, even if a lower bit depth than the original

This commit is contained in:
Ray Smith 2017-07-19 16:28:26 -07:00
parent 66e686a0e6
commit cec1037260

View File

@ -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;