/ocr/ocrservice/jni/hydrogen/include/leptonica/ccbord.h

http://eyes-free.googlecode.com/ · 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. #ifndef LEPTONICA_CCBORD_H
  16. #define LEPTONICA_CCBORD_H
  17. /*
  18. * ccbord.h
  19. *
  20. * CCBord: represents a single connected component
  21. * CCBorda: an array of CCBord
  22. */
  23. /* Use in ccbaStepChainsToPixCoords() */
  24. enum {
  25. CCB_LOCAL_COORDS = 1,
  26. CCB_GLOBAL_COORDS = 2
  27. };
  28. /* Use in ccbaGenerateSPGlobalLocs() */
  29. enum {
  30. CCB_SAVE_ALL_PTS = 1,
  31. CCB_SAVE_TURNING_PTS = 2
  32. };
  33. /* CCBord contains:
  34. *
  35. * (1) a minimally-clipped bitmap of the component (pix),
  36. * (2) a boxa consisting of:
  37. * for the primary component:
  38. * (xul, yul) pixel location in global coords
  39. * (w, h) of the bitmap
  40. * for the hole components:
  41. * (x, y) in relative coordinates in primary component
  42. * (w, h) of the hole border (which is 2 pixels
  43. * larger in each direction than the hole itself)
  44. * (3) a pta ('start') of the initial border pixel location for each
  45. * closed curve, all in relative coordinates of the primary
  46. * component. This is given for the primary component,
  47. * followed by the hole components, if any.
  48. * (4) a refcount of the ccbord; used internally when a ccbord
  49. * is accessed from a ccborda (array of ccbord)
  50. * (5) a ptaa for the chain code for the border in relative
  51. * coordinates, where the first pta is the exterior border
  52. * and all other pta are for interior borders (holes)
  53. * (6) a ptaa for the global pixel loc rendition of the border,
  54. * where the first pta is the exterior border and all other
  55. * pta are for interior borders (holes).
  56. * This is derived from the local or step chain code.
  57. * (7) a numaa for the chain code for the border as orientation
  58. * directions between successive border pixels, where
  59. * the first numa is the exterior border and all other
  60. * numa are for interior borders (holes). This is derived
  61. * from the local chain code. The 8 directions are 0 - 7.
  62. * (8) a pta for a single chain for each c.c., comprised of outer
  63. * and hole borders, plus cut paths between them, all in
  64. * local coords.
  65. * (9) a pta for a single chain for each c.c., comprised of outer
  66. * and hole borders, plus cut paths between them, all in
  67. * global coords.
  68. */
  69. struct CCBord
  70. {
  71. struct Pix *pix; /* component bitmap (min size) */
  72. struct Boxa *boxa; /* regions of each closed curve */
  73. struct Pta *start; /* initial border pixel locations */
  74. l_int32 refcount; /* number of handles; start at 1 */
  75. struct Ptaa *local; /* ptaa of chain pixels (local) */
  76. struct Ptaa *global; /* ptaa of chain pixels (global) */
  77. struct Numaa *step; /* numaa of chain code (step dir) */
  78. struct Pta *splocal; /* pta of single chain (local) */
  79. struct Pta *spglobal; /* pta of single chain (global) */
  80. };
  81. typedef struct CCBord CCBORD;
  82. struct CCBorda
  83. {
  84. struct Pix *pix; /* input pix (may be null) */
  85. l_int32 w; /* width of pix */
  86. l_int32 h; /* height of pix */
  87. l_int32 n; /* number of ccbord in ptr array */
  88. l_int32 nalloc; /* number of ccbord ptrs allocated */
  89. struct CCBord **ccb; /* ccb ptr array */
  90. };
  91. typedef struct CCBorda CCBORDA;
  92. #endif /* LEPTONICA_CCBORD_H */