classify/speckle.cpp

Go to the documentation of this file.
00001 
00020 /* =================
00021           Include Files and Type Defines
00022  ==================== */
00023 #include "speckle.h"
00024 #include "debug.h"
00025 #include "blobs.h"
00026 
00027 /* =================
00028  Global Data Definitions and Declarations
00029  ==================== */
00030 
00049 // define control knobs for adjusting definition of speckle
00050 make_float_var (MaxLargeSpeckleSize, 0.30, MakeMaxLargeSpeckleSize,
00051 16, 2, SetMaxLargeSpeckleSize, "Max Large Speckle Size ...");
00052 make_float_var (SmallSpecklePenalty, 10.0, MakeSmallSpecklePenalty,
00053 16, 3, SetSmallSpecklePenalty, "Small Speckle Penalty ...");
00054 make_float_var (LargeSpecklePenalty, 10.0, MakeLargeSpecklePenalty,
00055 16, 4, SetLargeSpecklePenalty, "Large Speckle Penalty ...");
00056 make_float_var (SmallSpeckleCertainty, -1.0, MakeSmallSpeckleCertainty,
00057 16, 5, SetSmallSpeckleCertainty, "Small Speckle Certainty ...");
00060 /* =================
00061      Public Code
00062  ==================== */
00080 LIST AddLargeSpeckleTo(LIST Choices) { 
00081   LIST WorstChoice;
00082 
00083   /* if there are no other choices, use the small speckle penalty plus
00084      the large speckle penalty */
00085   if (Choices == NIL)
00086     return (append_choice (NIL, "", SmallSpecklePenalty + LargeSpecklePenalty,
00087       SmallSpeckleCertainty, -1));
00088 
00089   /* if there are other choices,  add a null choice that is slightly worse
00090      than the worst choice so far */
00091   WorstChoice = last (Choices);
00092   return (append_choice (Choices, "",
00093     best_probability (WorstChoice) + LargeSpecklePenalty,
00094     best_certainty (WorstChoice), -1));
00095 
00096 }                                /* AddLargeSpeckleTo */
00097 
00098 
00099 /* =============================== */
00108 void InitSpeckleVars() { 
00109   MakeMaxLargeSpeckleSize(); 
00110   MakeSmallSpecklePenalty(); 
00111   MakeLargeSpecklePenalty(); 
00112   MakeSmallSpeckleCertainty(); 
00113 #ifdef TEXT_VERBOSE
00114   // gets a 'k', see ccmain/tesseractmain.dox
00115   cprintf("k");
00116 #endif
00117 }                                /* InitSpeckleVars */
00118 
00119 
00120 /* =============================== */
00132 BOOL8 LargeSpeckle(TBLOB *Blob, TEXTROW *Row) { 
00133   FLOAT32 SpeckleSize;
00134   TPOINT TopLeft;
00135   TPOINT BottomRight;
00136 
00137   SpeckleSize = RowHeight (Row) * MaxLargeSpeckleSize;
00138   blob_bounding_box(Blob, &TopLeft, &BottomRight); 
00139 
00140   if (TopLeft.y - BottomRight.y < SpeckleSize &&
00141     BottomRight.x - TopLeft.x < SpeckleSize)
00142     return (TRUE);
00143   else
00144     return (FALSE);
00145 }                                /* LargeSpeckle */

Generated on Wed Feb 28 19:49:10 2007 for Tesseract by  doxygen 1.5.1