From f5d7401de1a43a1714581b6478e25dc301148fc2 Mon Sep 17 00:00:00 2001 From: Alexander Golodkov <55749660+alexander1999-hub@users.noreply.github.com> Date: Tue, 26 Dec 2023 16:20:23 +0300 Subject: [PATCH] TLDR-547 changed orientation correction function (#16) Co-authored-by: Alexander Golodkov --- CHANGELOG.md | 4 ++++ VERSION | 2 +- dedocutils/preprocessing/skew_corrector.py | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8fc1a6..f72c2be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ Changelog ========= +v0.3.6 (2023-12-26) +------------------- +* Fix image orientation correction in `SkewCorrector` + v0.3.5 (2023-10-02) ------------------- * Delete `Serializable` class diff --git a/VERSION b/VERSION index 09e9157..53b61ec 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.5 \ No newline at end of file +0.3.6 \ No newline at end of file diff --git a/dedocutils/preprocessing/skew_corrector.py b/dedocutils/preprocessing/skew_corrector.py index 69d4ffb..ddd7dbd 100644 --- a/dedocutils/preprocessing/skew_corrector.py +++ b/dedocutils/preprocessing/skew_corrector.py @@ -22,7 +22,8 @@ def preprocess(self, image: np.ndarray, parameters: Optional[dict] = None) -> Tu orientation_angle = parameters.get("orientation_angle", 0) if orientation_angle: - image = rotate_image(image, orientation_angle) + rotation_nums = orientation_angle // 90 + image = np.rot90(image, rotation_nums) gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1]