#include "mfcpch.h"
#include "blobs.h"
#include "cutil.h"
#include "emalloc.h"
#include "structures.h"
Go to the source code of this file.
Compute the bounding_box of a compound blob, define to be the max coordinate value of the bounding boxes of all the top-level outlines in the box.
Definition at line 55 of file blobs.cpp.
Referenced by blob_origin(), blobs_bounding_box(), blobs_widths(), choose_best_seam(), ComputeBlobCenter(), get_match(), LargeSpeckle(), put_match(), record_blob_bounds(), start_seam_list(), and total_containment().
00057 { 00058 register TESSLINE *outline; /*current outline */ 00059 00060 if (blob == NULL || blob->outlines == NULL) { 00061 topleft->x = topleft->y = 0; 00062 *botright = *topleft; /*default value */ 00063 } 00064 else { 00065 outline = blob->outlines; 00066 *topleft = outline->topleft; 00067 *botright = outline->botright; 00068 for (outline = outline->next; outline != NULL; outline = outline->next) { 00069 if (outline->topleft.x < topleft->x) 00070 /*find extremes */ 00071 topleft->x = outline->topleft.x; 00072 if (outline->botright.x > botright->x) 00073 /*find extremes */ 00074 botright->x = outline->botright.x; 00075 if (outline->topleft.y > topleft->y) 00076 /*find extremes */ 00077 topleft->y = outline->topleft.y; 00078 if (outline->botright.y < botright->y) 00079 /*find extremes */ 00080 botright->y = outline->botright.y; 00081 } 00082 } 00083 }
Compute the origin of a compound blob, define to be the centre of the bounding box.
Definition at line 37 of file blobs.cpp.
References blob_bounding_box(), TPOINT::x, and TPOINT::y.
Referenced by correct_blob_order(), and display_blob().
00038 { /*return value */ 00039 TPOINT topleft; /*bounding box */ 00040 TPOINT botright; 00041 00042 /*find bounding box */ 00043 blob_bounding_box(blob, &topleft, &botright); 00044 /*centre of box */ 00045 origin->x = (topleft.x + botright.x) / 2; 00046 origin->y = (topleft.y + botright.y) / 2; 00047 }
Return the smallest extreme point that contain this word.
Definition at line 89 of file blobs.cpp.
References blob_bounding_box(), iterate_blobs, TPOINT::x, and TPOINT::y.
Referenced by blobs_origin().
00089 { 00090 TPOINT tl; 00091 TPOINT br; 00092 TBLOB *blob; 00093 /* Start with first blob */ 00094 blob_bounding_box(blobs, topleft, botright); 00095 00096 iterate_blobs(blob, blobs) { 00097 blob_bounding_box(blob, &tl, &br); 00098 00099 if (tl.x < topleft->x) 00100 topleft->x = tl.x; 00101 if (tl.y > topleft->y) 00102 topleft->y = tl.y; 00103 if (br.x > botright->x) 00104 botright->x = br.x; 00105 if (br.y < botright->y) 00106 botright->y = br.y; 00107 } 00108 }
Compute the origin of a compound blob, define to be the centre of the bounding box.
Definition at line 115 of file blobs.cpp.
References blobs_bounding_box(), TPOINT::x, and TPOINT::y.
Referenced by render_segmentation().
00116 { /*return value */ 00117 TPOINT topleft; /*bounding box */ 00118 TPOINT botright; 00119 00120 /*find bounding box */ 00121 blobs_bounding_box(blobs, &topleft, &botright); 00122 /*center of box */ 00123 origin->x = (topleft.x + botright.x) / 2; 00124 origin->y = (topleft.y + botright.y) / 2; 00125 }
WIDTH_RECORD* blobs_widths | ( | TBLOB * | blobs | ) |
Compute the widths of a list of blobs.
Return an array of the widths and gaps.
Definition at line 133 of file blobs.cpp.
References blob_bounding_box(), count_blobs(), iterate_blobs, memalloc(), blobstruct::next, WIDTH_RECORD::num_chars, WIDTH_RECORD::widths, and TPOINT::x.
Referenced by word_associator().
00133 { /*blob to compute on */ 00134 WIDTH_RECORD *width_record; 00135 TPOINT topleft; /*bounding box */ 00136 TPOINT botright; 00137 TBLOB *blob; /*blob to compute on */ 00138 int i = 0; 00139 int blob_end; 00140 int num_blobs = count_blobs (blobs); 00141 00142 /* Get memory */ 00143 width_record = (WIDTH_RECORD *) memalloc (sizeof (int) * num_blobs * 2); 00144 width_record->num_chars = num_blobs; 00145 00146 blob_bounding_box(blobs, &topleft, &botright); 00147 width_record->widths[i++] = botright.x - topleft.x; 00148 /* First width */ 00149 blob_end = botright.x; 00150 00151 iterate_blobs (blob, blobs->next) { 00152 blob_bounding_box(blob, &topleft, &botright); 00153 width_record->widths[i++] = topleft.x - blob_end; 00154 width_record->widths[i++] = botright.x - topleft.x; 00155 blob_end = botright.x; 00156 } 00157 return (width_record); 00158 }
int count_blobs | ( | TBLOB * | blobs | ) |
Return a count of the number of blobs attached to this one.
Definition at line 164 of file blobs.cpp.
References iterate_blobs.
Referenced by blobs_widths(), evaluate_chunks(), improve_by_chopping(), rebuild_current_state(), record_blob_bounds(), and record_piece_ratings().
00164 { 00165 TBLOB *b; 00166 int x = 0; 00167 00168 iterate_blobs (b, blobs) x++; 00169 return (x); 00170 }
void delete_edgepts | ( | register EDGEPT * | edgepts | ) |
Delete a list of EDGEPT structures.
Definition at line 213 of file blobs.cpp.
References edgeptstruct::next, NULL, and oldedgept().
Referenced by delete_word().
00213 { 00214 register EDGEPT *this_edge; 00215 register EDGEPT *next_edge; 00216 00217 if (edgepts == NULL) 00218 return; 00219 00220 this_edge = edgepts; 00221 do { 00222 next_edge = this_edge->next; 00223 oldedgept(this_edge); 00224 this_edge = next_edge; 00225 } 00226 while (this_edge != edgepts); 00227 }
void delete_word | ( | TWERD * | word | ) |
Reclaim the memory taken by this word structure and all of its lower level structures.
Definition at line 177 of file blobs.cpp.
References wordstruct::blobs, olinestruct::child, wordstruct::correct, delete_edgepts(), olinestruct::loop, blobstruct::next, olinestruct::next, NULL, oldblob(), oldoutline, oldword(), blobstruct::outlines, and strfree.
Referenced by recog_word_recursive(), tess_adaptable_word(), tess_adapter(), unrej_good_chs(), word_blob_quality(), and word_char_quality().
00177 { 00178 TBLOB *blob; 00179 TBLOB *nextblob; 00180 TESSLINE *outline; 00181 TESSLINE *nextoutline; 00182 TESSLINE *child; 00183 TESSLINE *nextchild; 00184 00185 for (blob = word->blobs; blob; blob = nextblob) { 00186 nextblob = blob->next; 00187 00188 for (outline = blob->outlines; outline; outline = nextoutline) { 00189 nextoutline = outline->next; 00190 00191 delete_edgepts (outline->loop); 00192 00193 for (child = outline->child; child; child = nextchild) { 00194 nextchild = child->next; 00195 00196 delete_edgepts (child->loop); 00197 00198 oldoutline(child); 00199 } 00200 oldoutline(outline); 00201 } 00202 oldblob(blob); 00203 } 00204 if (word->correct != NULL) 00205 strfree (word->correct); /* Reclaim memory */ 00206 oldword(word); 00207 }