Skip to content

Commit

Permalink
Merge branch 'tesseract-ocr:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
zdenop authored Dec 16, 2024
2 parents d913df9 + 3299901 commit 7548407
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake-win64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

env:
ILOC: d:/a/local
png_ver: 1643
png_ver: 1644

jobs:
build:
Expand Down
32 changes: 13 additions & 19 deletions src/ccmain/thresholder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,30 +283,24 @@ bool ImageThresholder::ThresholdToPix(Image *pix) {
tprintf("Image too large: (%d, %d)\n", image_width_, image_height_);
return false;
}
Image original = GetPixRect();
// Handle binary image
if (pix_channels_ == 0) {
// We have a binary image, but it still has to be copied, as this API
// allows the caller to modify the output.
Image original = GetPixRect();
*pix = original.copy();
} else {
if (pixGetColormap(original)) {
Image tmp;
Image without_cmap =
pixRemoveColormap(original, REMOVE_CMAP_BASED_ON_SRC);
int depth = pixGetDepth(without_cmap);
if (depth > 1 && depth < 8) {
tmp = pixConvertTo8(without_cmap, false);
} else {
tmp = without_cmap.copy();
}
without_cmap.destroy();
OtsuThresholdRectToPix(tmp, pix);
tmp.destroy();
} else {
OtsuThresholdRectToPix(pix_, pix);
}
original.destroy();
return true;
}
// Handle colormaps
Image src = pix_;
if (pixGetColormap(src)) {
src = pixRemoveColormap(src, REMOVE_CMAP_BASED_ON_SRC);
}
OtsuThresholdRectToPix(src, pix);
if (src != pix_) {
src.destroy();
}
original.destroy();
return true;
}

Expand Down

0 comments on commit 7548407

Please sign in to comment.