00001 00002 // File: strokewidth.h 00003 // Description: Subclass of BBGrid to find uniformity of strokewidth. 00004 // Author: Ray Smith 00005 // Created: Mon Mar 31 16:17:01 PST 2008 00006 // 00007 // (C) Copyright 2008, Google Inc. 00008 // Licensed under the Apache License, Version 2.0 (the "License"); 00009 // you may not use this file except in compliance with the License. 00010 // You may obtain a copy of the License at 00011 // http://www.apache.org/licenses/LICENSE-2.0 00012 // Unless required by applicable law or agreed to in writing, software 00013 // distributed under the License is distributed on an "AS IS" BASIS, 00014 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 // See the License for the specific language governing permissions and 00016 // limitations under the License. 00017 // 00019 00020 #ifndef TESSERACT_TEXTORD_STROKEWIDTH_H__ 00021 #define TESSERACT_TEXTORD_STROKEWIDTH_H__ 00022 00023 #include "bbgrid.h" // Base class. 00024 #include "tabvector.h" // For BLOBNBOX_CLIST. 00025 00026 class TO_BLOCK; 00027 class ScrollView; 00028 00029 namespace tesseract { 00030 00031 class TabFind; 00032 00033 // The StrokeWidth class holds all the normal and large blobs. 00034 // It is used to find good large blobs and move them to the normal blobs 00035 // by virtue of having a reasonable strokewidth compatible neighbour. 00036 class StrokeWidth : public BBGrid<BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT> { 00037 public: 00038 StrokeWidth(int gridsize, const ICOORD& bleft, const ICOORD& tright); 00039 virtual ~StrokeWidth(); 00040 00041 // Puts the block blobs (normal and large) into the grid. 00042 void InsertBlobs(TO_BLOCK* block, TabFind* line_grid); 00043 00044 // Moves the large blobs that have good stroke-width neighbours to the normal 00045 // blobs list. 00046 void MoveGoodLargeBlobs(int resolution, TO_BLOCK* block); 00047 00048 // Displays the blobs green or red according to whether they are good or not. 00049 ScrollView* DisplayGoodBlobs(const char* window_name, ScrollView* tab_win); 00050 00051 // Handles a click event in a display window. 00052 virtual void HandleClick(int x, int y); 00053 00054 private: 00055 // Returns true if there is at least one side neighbour that has a similar 00056 // stroke width. 00057 bool GoodTextBlob(BLOBNBOX* blob); 00058 }; 00059 00060 } // namespace tesseract. 00061 00062 #endif // TESSERACT_TEXTORD_STROKEWIDTH_H__ 00063