|
tesseract 3.04.01
|
00001 /* -*-C-*- 00002 ******************************************************************************** 00003 * 00004 * File: gradechop.c (Formerly gradechop.c) 00005 * Description: 00006 * Author: Mark Seaman, OCR Technology 00007 * Created: Fri Oct 16 14:37:00 1987 00008 * Modified: Tue Jul 30 16:06:27 1991 (Mark Seaman) marks@hpgrlt 00009 * Language: C 00010 * Package: N/A 00011 * Status: Reusable Software Component 00012 * 00013 * (c) Copyright 1987, Hewlett-Packard Company. 00014 ** Licensed under the Apache License, Version 2.0 (the "License"); 00015 ** you may not use this file except in compliance with the License. 00016 ** You may obtain a copy of the License at 00017 ** http://www.apache.org/licenses/LICENSE-2.0 00018 ** Unless required by applicable law or agreed to in writing, software 00019 ** distributed under the License is distributed on an "AS IS" BASIS, 00020 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00021 ** See the License for the specific language governing permissions and 00022 ** limitations under the License. 00023 * 00024 *********************************************************************************/ 00025 /*---------------------------------------------------------------------- 00026 I n c l u d e s 00027 ----------------------------------------------------------------------*/ 00028 #include "gradechop.h" 00029 #include "wordrec.h" 00030 #include "chop.h" 00031 #include "ndminx.h" 00032 #include <math.h> 00033 00034 /*---------------------------------------------------------------------- 00035 M a c r o s 00036 ----------------------------------------------------------------------*/ 00037 00038 namespace tesseract { 00039 00040 /*---------------------------------------------------------------------- 00041 F u n c t i o n s 00042 ----------------------------------------------------------------------*/ 00043 00044 /********************************************************************** 00045 * grade_split_length 00046 * 00047 * Return a grade for the length of this split. 00048 * 0 = "perfect" 00049 * 100 = "no way jay" 00050 **********************************************************************/ 00051 PRIORITY Wordrec::grade_split_length(register SPLIT *split) { 00052 PRIORITY grade; 00053 float split_length; 00054 00055 split_length = 00056 split->point1->WeightedDistance(*split->point2, chop_x_y_weight); 00057 00058 if (split_length <= 0) 00059 grade = 0; 00060 else 00061 grade = sqrt (split_length) * chop_split_dist_knob; 00062 00063 return (MAX (0.0, grade)); 00064 } 00065 00066 00067 /********************************************************************** 00068 * grade_sharpness 00069 * 00070 * Return a grade for the sharpness of this split. 00071 * 0 = "perfect" 00072 * 100 = "no way jay" 00073 **********************************************************************/ 00074 PRIORITY Wordrec::grade_sharpness(register SPLIT *split) { 00075 PRIORITY grade; 00076 00077 grade = point_priority (split->point1) + point_priority (split->point2); 00078 00079 if (grade < -360.0) 00080 grade = 0; 00081 else 00082 grade += 360.0; 00083 00084 grade *= chop_sharpness_knob; /* Values 0 to -360 */ 00085 00086 return (grade); 00087 } 00088 00089 00090 } // namespace tesseract