@@ -206,14 +206,22 @@ class Tesseract : public Wordrec {
206
206
sub_langs_[i]->set_pix_original (original_pix ? pixClone (original_pix)
207
207
: nullptr );
208
208
}
209
- // Returns a pointer to a Pix representing the best available (original) image
210
- // of the page. Can be of any bit depth, but never color-mapped, as that has
211
- // always been dealt with. Note that in grey and color, 0 is black and 255 is
209
+ // Returns a pointer to a Pix representing the best available resolution image
210
+ // of the page, with best available bit depth as second priority. Result can
211
+ // be of any bit depth, but never color-mapped, as that has always been
212
+ // removed. Note that in grey and color, 0 is black and 255 is
212
213
// white. If the input was binary, then black is 1 and white is 0.
213
214
// To tell the difference pixGetDepth() will return 32, 8 or 1.
214
215
// In any case, the return value is a borrowed Pix, and should not be
215
216
// deleted or pixDestroyed.
216
- Pix* BestPix () const { return pix_original_; }
217
+ Pix* BestPix () const {
218
+ if (pixGetWidth (pix_original_) == ImageWidth ())
219
+ return pix_original_;
220
+ else if (pix_grey_ != NULL )
221
+ return pix_grey_;
222
+ else
223
+ return pix_binary_;
224
+ }
217
225
void set_pix_thresholds (Pix* thresholds) {
218
226
pixDestroy (&pix_thresholds_);
219
227
pix_thresholds_ = thresholds;
0 commit comments