Optimize code for binarization

Some code is only needed for Otsu or even not at all.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2021-05-15 10:59:53 +02:00
parent 4b5dd25b84
commit bf84fb9f2d

View File

@ -2107,15 +2107,12 @@ bool TessBaseAPI::Threshold(Pix **pix) {
}
thresholder_->SetSourceYResolution(kMinCredibleResolution);
}
auto pageseg_mode = static_cast<PageSegMode>(static_cast<int>(tesseract_->tessedit_pageseg_mode));
Image pix_binary(*pix);
Image pix_grey;
Image pix_thresholds;
auto thresholding_method = static_cast<ThresholdMethod>(static_cast<int>(tesseract_->thresholding_method));
if (thresholding_method == ThresholdMethod::Otsu) {
auto pageseg_mode = static_cast<PageSegMode>(static_cast<int>(tesseract_->tessedit_pageseg_mode));
Image pix_binary(*pix);
if (!thresholder_->ThresholdToPix(pageseg_mode, &pix_binary)) {
return false;
}