1 /********************************************************************** 2 * File: edgblob.h (Formerly edgeloop.h) 3 * Description: Functions to clean up an outline before approximation. 4 * Author: Ray Smith 5 * Created: Tue Mar 26 16:56:25 GMT 1991 6 * 7 * (C) Copyright 1991, Hewlett-Packard Ltd. 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 #ifndef EDGBLOB_H 21 #define EDGBLOB_H 22 23 #include "scrollview.h" 24 #include "varable.h" 25 #include "img.h" 26 #include "ocrblock.h" 27 #include "coutln.h" 28 #include "crakedge.h" 29 #include "notdll.h" 30 31 #define BUCKETSIZE 16 32 33 class OL_BUCKETS 34 { 35 public: 36 OL_BUCKETS( //constructor 37 ICOORD bleft, //corners 38 ICOORD tright); 39 ~OL_BUCKETS()40 ~OL_BUCKETS () { //cleanup 41 delete[]buckets; 42 } 43 C_OUTLINE_LIST *operator () (//array access 44 inT16 x, //image coords 45 inT16 y); 46 //first non-empty bucket start_scan()47 C_OUTLINE_LIST *start_scan() { 48 for (index = 0; buckets[index].empty () && index < bxdim * bydim - 1; 49 index++); 50 return &buckets[index]; 51 } 52 //next non-empty bucket scan_next()53 C_OUTLINE_LIST *scan_next() { 54 for (; buckets[index].empty () && index < bxdim * bydim - 1; index++); 55 return &buckets[index]; 56 } 57 inT32 count_children( //recursive sum 58 C_OUTLINE *outline, //parent outline 59 inT32 max_count); //max output 60 inT32 outline_complexity( // new version of count_children 61 C_OUTLINE *outline, // parent outline 62 inT32 max_count, // max output 63 inT16 depth); // level of recursion 64 void extract_children( //single level get 65 C_OUTLINE *outline, //parent outline 66 C_OUTLINE_IT *it); //destination iterator 67 68 private: 69 C_OUTLINE_LIST * buckets; //array of buckets 70 inT16 bxdim; //size of array 71 inT16 bydim; 72 ICOORD bl; //corners 73 ICOORD tr; 74 inT32 index; //for extraction scan 75 }; 76 77 void extract_edges( //find blobs 78 #ifndef GRAPHICS_DISABLED 79 ScrollView* window, //window for output 80 #endif 81 IMAGE *image, //image to scan 82 IMAGE *t_image, //thresholded image 83 ICOORD page_tr, //corner of page 84 BLOCK *block //block to scan 85 ); 86 void outlines_to_blobs( //find blobs 87 BLOCK *block, //block to scan 88 ICOORD bleft, //block box //outlines in block 89 ICOORD tright, 90 C_OUTLINE_LIST *outlines); 91 void fill_buckets( //find blobs 92 C_OUTLINE_LIST *outlines, //outlines in block 93 OL_BUCKETS *buckets //output buckets 94 ); 95 void empty_buckets( //find blobs 96 BLOCK *block, //block to scan 97 OL_BUCKETS *buckets //output buckets 98 ); 99 BOOL8 capture_children( //find children 100 OL_BUCKETS *buckets, //bucket sort clanss 101 C_BLOB_IT *reject_it, //dead grandchildren 102 C_OUTLINE_IT *blob_it //output outlines 103 ); 104 #endif 105