ccbord.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*====================================================================*
  2. - Copyright (C) 2001 Leptonica. All rights reserved.
  3. -
  4. - Redistribution and use in source and binary forms, with or without
  5. - modification, are permitted provided that the following conditions
  6. - are met:
  7. - 1. Redistributions of source code must retain the above copyright
  8. - notice, this list of conditions and the following disclaimer.
  9. - 2. Redistributions in binary form must reproduce the above
  10. - copyright notice, this list of conditions and the following
  11. - disclaimer in the documentation and/or other materials
  12. - provided with the distribution.
  13. -
  14. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  15. - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  16. - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
  18. - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  19. - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  20. - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  21. - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  22. - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  23. - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. *====================================================================*/
  26. #ifndef LEPTONICA_CCBORD_H
  27. #define LEPTONICA_CCBORD_H
  28. /*!
  29. * \file ccbord.h
  30. *
  31. * <pre>
  32. * CCBord: represents a single connected component
  33. * CCBorda: an array of CCBord
  34. * </pre>
  35. */
  36. /*! Use in ccbaStepChainsToPixCoords() */
  37. enum {
  38. CCB_LOCAL_COORDS = 1,
  39. CCB_GLOBAL_COORDS = 2
  40. };
  41. /*! Use in ccbaGenerateSPGlobalLocs() */
  42. enum {
  43. CCB_SAVE_ALL_PTS = 1,
  44. CCB_SAVE_TURNING_PTS = 2
  45. };
  46. /*!
  47. * <pre>
  48. * CCBord contains:
  49. *
  50. * (1) a minimally-clipped bitmap of the component (pix),
  51. * (2) a boxa consisting of:
  52. * for the primary component:
  53. * (xul, yul) pixel location in global coords
  54. * (w, h) of the bitmap
  55. * for the hole components:
  56. * (x, y) in relative coordinates in primary component
  57. * (w, h) of the hole border (which is 2 pixels
  58. * larger in each direction than the hole itself)
  59. * (3) a pta ('start') of the initial border pixel location for each
  60. * closed curve, all in relative coordinates of the primary
  61. * component. This is given for the primary component,
  62. * followed by the hole components, if any.
  63. * (4) a refcount of the ccbord; used internally when a ccbord
  64. * is accessed from a ccborda (array of ccbord)
  65. * (5) a ptaa for the chain code for the border in relative
  66. * coordinates, where the first pta is the exterior border
  67. * and all other pta are for interior borders (holes)
  68. * (6) a ptaa for the global pixel loc rendition of the border,
  69. * where the first pta is the exterior border and all other
  70. * pta are for interior borders (holes).
  71. * This is derived from the local or step chain code.
  72. * (7) a numaa for the chain code for the border as orientation
  73. * directions between successive border pixels, where
  74. * the first numa is the exterior border and all other
  75. * numa are for interior borders (holes). This is derived
  76. * from the local chain code. The 8 directions are 0 - 7.
  77. * (8) a pta for a single chain for each c.c., comprised of outer
  78. * and hole borders, plus cut paths between them, all in
  79. * local coords.
  80. * (9) a pta for a single chain for each c.c., comprised of outer
  81. * and hole borders, plus cut paths between them, all in
  82. * global coords.
  83. * </pre>
  84. */
  85. struct CCBord
  86. {
  87. struct Pix *pix; /*!< component bitmap (min size) */
  88. struct Boxa *boxa; /*!< regions of each closed curve */
  89. struct Pta *start; /*!< initial border pixel locations */
  90. l_int32 refcount; /*!< number of handles; start at 1 */
  91. struct Ptaa *local; /*!< ptaa of chain pixels (local) */
  92. struct Ptaa *global; /*!< ptaa of chain pixels (global) */
  93. struct Numaa *step; /*!< numaa of chain code (step dir) */
  94. struct Pta *splocal; /*!< pta of single chain (local) */
  95. struct Pta *spglobal; /*!< pta of single chain (global) */
  96. };
  97. typedef struct CCBord CCBORD;
  98. /*! Array of CCBord */
  99. struct CCBorda
  100. {
  101. struct Pix *pix; /*!< input pix (may be null) */
  102. l_int32 w; /*!< width of pix */
  103. l_int32 h; /*!< height of pix */
  104. l_int32 n; /*!< number of ccbord in ptr array */
  105. l_int32 nalloc; /*!< number of ccbord ptrs allocated */
  106. struct CCBord **ccb; /*!< ccb ptr array */
  107. };
  108. typedef struct CCBorda CCBORDA;
  109. #endif /* LEPTONICA_CCBORD_H */