Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/tesseract/src/wordrec/gradechop.cpp @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 /****************************************************************************** | |
| 2 * | |
| 3 * File: gradechop.cpp (Formerly gradechop.c) | |
| 4 * Description: | |
| 5 * Author: Mark Seaman, OCR Technology | |
| 6 * | |
| 7 * (c) Copyright 1987, Hewlett-Packard Company. | |
| 8 ** Licensed under the Apache License, Version 2.0 (the "License"); | |
| 9 ** you may not use this file except in compliance with the License. | |
| 10 ** You may obtain a copy of the License at | |
| 11 ** http://www.apache.org/licenses/LICENSE-2.0 | |
| 12 ** Unless required by applicable law or agreed to in writing, software | |
| 13 ** distributed under the License is distributed on an "AS IS" BASIS, | |
| 14 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 15 ** See the License for the specific language governing permissions and | |
| 16 ** limitations under the License. | |
| 17 * | |
| 18 *****************************************************************************/ | |
| 19 /*---------------------------------------------------------------------- | |
| 20 I n c l u d e s | |
| 21 ----------------------------------------------------------------------*/ | |
| 22 | |
| 23 #include <algorithm> | |
| 24 #include <cmath> | |
| 25 #include "chop.h" | |
| 26 #include "wordrec.h" | |
| 27 | |
| 28 /*---------------------------------------------------------------------- | |
| 29 M a c r o s | |
| 30 ----------------------------------------------------------------------*/ | |
| 31 | |
| 32 namespace tesseract { | |
| 33 | |
| 34 /*---------------------------------------------------------------------- | |
| 35 F u n c t i o n s | |
| 36 ----------------------------------------------------------------------*/ | |
| 37 | |
| 38 /********************************************************************** | |
| 39 * grade_split_length | |
| 40 * | |
| 41 * Return a grade for the length of this split. | |
| 42 * 0 = "perfect" | |
| 43 * 100 = "no way jay" | |
| 44 **********************************************************************/ | |
| 45 PRIORITY Wordrec::grade_split_length(SPLIT *split) { | |
| 46 PRIORITY grade; | |
| 47 float split_length; | |
| 48 | |
| 49 split_length = split->point1->WeightedDistance(*split->point2, chop_x_y_weight); | |
| 50 | |
| 51 if (split_length <= 0) { | |
| 52 grade = 0; | |
| 53 } else { | |
| 54 grade = std::sqrt(split_length) * chop_split_dist_knob; | |
| 55 } | |
| 56 | |
| 57 return (std::max(0.0f, grade)); | |
| 58 } | |
| 59 | |
| 60 /********************************************************************** | |
| 61 * grade_sharpness | |
| 62 * | |
| 63 * Return a grade for the sharpness of this split. | |
| 64 * 0 = "perfect" | |
| 65 * 100 = "no way jay" | |
| 66 **********************************************************************/ | |
| 67 PRIORITY Wordrec::grade_sharpness(SPLIT *split) { | |
| 68 PRIORITY grade; | |
| 69 | |
| 70 grade = point_priority(split->point1) + point_priority(split->point2); | |
| 71 | |
| 72 if (grade < -360.0) { | |
| 73 grade = 0; | |
| 74 } else { | |
| 75 grade += 360.0; | |
| 76 } | |
| 77 | |
| 78 grade *= chop_sharpness_knob; /* Values 0 to -360 */ | |
| 79 | |
| 80 return (grade); | |
| 81 } | |
| 82 | |
| 83 } // namespace tesseract |
