/ocr/ocrservice/jni/hydrogen/include/leptonica/ccbord.h
C++ Header | 103 lines | 34 code | 11 blank | 58 comment | 0 complexity | dc0761671a60849c089722f8f1154fba MD5 | raw file
1/*====================================================================* 2 - Copyright (C) 2001 Leptonica. All rights reserved. 3 - This software is distributed in the hope that it will be 4 - useful, but with NO WARRANTY OF ANY KIND. 5 - No author or distributor accepts responsibility to anyone for the 6 - consequences of using this software, or for whether it serves any 7 - particular purpose or works at all, unless he or she says so in 8 - writing. Everyone is granted permission to copy, modify and 9 - redistribute this source code, for commercial or non-commercial 10 - purposes, with the following restrictions: (1) the origin of this 11 - source code must not be misrepresented; (2) modified versions must 12 - be plainly marked as such; and (3) this notice may not be removed 13 - or altered from any source or modified source distribution. 14 *====================================================================*/ 15 16#ifndef LEPTONICA_CCBORD_H 17#define LEPTONICA_CCBORD_H 18 19/* 20 * ccbord.h 21 * 22 * CCBord: represents a single connected component 23 * CCBorda: an array of CCBord 24 */ 25 26 /* Use in ccbaStepChainsToPixCoords() */ 27enum { 28 CCB_LOCAL_COORDS = 1, 29 CCB_GLOBAL_COORDS = 2 30}; 31 32 /* Use in ccbaGenerateSPGlobalLocs() */ 33enum { 34 CCB_SAVE_ALL_PTS = 1, 35 CCB_SAVE_TURNING_PTS = 2 36}; 37 38 39 /* CCBord contains: 40 * 41 * (1) a minimally-clipped bitmap of the component (pix), 42 * (2) a boxa consisting of: 43 * for the primary component: 44 * (xul, yul) pixel location in global coords 45 * (w, h) of the bitmap 46 * for the hole components: 47 * (x, y) in relative coordinates in primary component 48 * (w, h) of the hole border (which is 2 pixels 49 * larger in each direction than the hole itself) 50 * (3) a pta ('start') of the initial border pixel location for each 51 * closed curve, all in relative coordinates of the primary 52 * component. This is given for the primary component, 53 * followed by the hole components, if any. 54 * (4) a refcount of the ccbord; used internally when a ccbord 55 * is accessed from a ccborda (array of ccbord) 56 * (5) a ptaa for the chain code for the border in relative 57 * coordinates, where the first pta is the exterior border 58 * and all other pta are for interior borders (holes) 59 * (6) a ptaa for the global pixel loc rendition of the border, 60 * where the first pta is the exterior border and all other 61 * pta are for interior borders (holes). 62 * This is derived from the local or step chain code. 63 * (7) a numaa for the chain code for the border as orientation 64 * directions between successive border pixels, where 65 * the first numa is the exterior border and all other 66 * numa are for interior borders (holes). This is derived 67 * from the local chain code. The 8 directions are 0 - 7. 68 * (8) a pta for a single chain for each c.c., comprised of outer 69 * and hole borders, plus cut paths between them, all in 70 * local coords. 71 * (9) a pta for a single chain for each c.c., comprised of outer 72 * and hole borders, plus cut paths between them, all in 73 * global coords. 74 */ 75struct CCBord 76{ 77 struct Pix *pix; /* component bitmap (min size) */ 78 struct Boxa *boxa; /* regions of each closed curve */ 79 struct Pta *start; /* initial border pixel locations */ 80 l_int32 refcount; /* number of handles; start at 1 */ 81 struct Ptaa *local; /* ptaa of chain pixels (local) */ 82 struct Ptaa *global; /* ptaa of chain pixels (global) */ 83 struct Numaa *step; /* numaa of chain code (step dir) */ 84 struct Pta *splocal; /* pta of single chain (local) */ 85 struct Pta *spglobal; /* pta of single chain (global) */ 86}; 87typedef struct CCBord CCBORD; 88 89 90struct CCBorda 91{ 92 struct Pix *pix; /* input pix (may be null) */ 93 l_int32 w; /* width of pix */ 94 l_int32 h; /* height of pix */ 95 l_int32 n; /* number of ccbord in ptr array */ 96 l_int32 nalloc; /* number of ccbord ptrs allocated */ 97 struct CCBord **ccb; /* ccb ptr array */ 98}; 99typedef struct CCBorda CCBORDA; 100 101 102#endif /* LEPTONICA_CCBORD_H */ 103