mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-24 11:09:06 +08:00
Fix compiler warning in binarization code (uninitialized local variable)
Simplify the code also a little bit. Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
bf84fb9f2d
commit
a0cf117c5d
@ -187,7 +187,6 @@ void ImageThresholder::SetImage(const Image pix) {
|
|||||||
|
|
||||||
std::tuple<bool, Image, Image, Image> ImageThresholder::Threshold(
|
std::tuple<bool, Image, Image, Image> ImageThresholder::Threshold(
|
||||||
ThresholdMethod method) {
|
ThresholdMethod method) {
|
||||||
Image pix_grey = nullptr;
|
|
||||||
Image pix_binary = nullptr;
|
Image pix_binary = nullptr;
|
||||||
Image pix_thresholds = nullptr;
|
Image pix_thresholds = nullptr;
|
||||||
|
|
||||||
@ -205,22 +204,19 @@ std::tuple<bool, Image, Image, Image> ImageThresholder::Threshold(
|
|||||||
return std::make_tuple(false, nullptr, pix_binary, nullptr);
|
return std::make_tuple(false, nullptr, pix_binary, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
pix_grey = GetPixRectGrey();
|
auto pix_grey = GetPixRectGrey();
|
||||||
|
|
||||||
if (method == ThresholdMethod::Otsu || method >= ThresholdMethod::Max) {
|
|
||||||
method = ThresholdMethod::AdaptiveOtsu;
|
|
||||||
}
|
|
||||||
|
|
||||||
int r;
|
int r;
|
||||||
if (method == ThresholdMethod::AdaptiveOtsu) {
|
if (method == ThresholdMethod::TiledSauvola) {
|
||||||
r = pixOtsuAdaptiveThreshold(pix_grey, 300, 300, 0, 0, 0.1,
|
|
||||||
pix_thresholds, pix_binary);
|
|
||||||
} else if (method == ThresholdMethod::TiledSauvola) {
|
|
||||||
r = pixSauvolaBinarizeTiled(pix_grey, 25, 0.40, 300, 300, pix_thresholds,
|
r = pixSauvolaBinarizeTiled(pix_grey, 25, 0.40, 300, 300, pix_thresholds,
|
||||||
pix_binary);
|
pix_binary);
|
||||||
|
} else {
|
||||||
|
// AdaptiveOtsu.
|
||||||
|
r = pixOtsuAdaptiveThreshold(pix_grey, 300, 300, 0, 0, 0.1,
|
||||||
|
pix_thresholds, pix_binary);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ok = r == 0 ? true : false;
|
bool ok = (r == 0);
|
||||||
return std::make_tuple(ok, pix_grey, pix_binary, pix_thresholds);
|
return std::make_tuple(ok, pix_grey, pix_binary, pix_thresholds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user