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

http://eyes-free.googlecode.com/ · C++ Header · 122 lines · 60 code · 12 blank · 50 comment · 0 complexity · 266f129828f28aeba14e46eb6dbdb9bc 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_JBCLASS_H
  16. #define LEPTONICA_JBCLASS_H
  17. /*
  18. * jbclass.h
  19. *
  20. * JbClasser
  21. * JbData
  22. */
  23. /* The JbClasser struct holds all the data accumulated during the
  24. * classification process that can be used for a compressed
  25. * jbig2-type representation of a set of images. This is created
  26. * in an initialization process and added to as the selected components
  27. * on each successive page are analyzed. */
  28. struct JbClasser
  29. {
  30. struct Sarray *safiles; /* input page image file names */
  31. l_int32 method; /* JB_RANKHAUS, JB_CORRELATION */
  32. l_int32 components; /* JB_CONN_COMPS, JB_CHARACTERS or */
  33. /* JB_WORDS */
  34. l_int32 maxwidth; /* max component width allowed */
  35. l_int32 maxheight; /* max component height allowed */
  36. l_int32 npages; /* number of pages already processed */
  37. l_int32 baseindex; /* number of components already processed */
  38. /* on fully processed pages */
  39. struct Numa *nacomps; /* number of components on each page */
  40. l_int32 sizehaus; /* size of square struct element for haus */
  41. l_float32 rankhaus; /* rank val of haus match, each way */
  42. l_float32 thresh; /* thresh value for correlation score */
  43. l_float32 weightfactor; /* corrects thresh value for heaver */
  44. /* components; use 0 for no correction */
  45. struct Numa *naarea; /* w * h of each template, without extra */
  46. /* border pixels */
  47. l_int32 w; /* max width of original src images */
  48. l_int32 h; /* max height of original src images */
  49. l_int32 nclass; /* current number of classes */
  50. l_int32 keep_pixaa; /* If zero, pixaa isn't filled */
  51. struct Pixaa *pixaa; /* instances for each class; unbordered */
  52. struct Pixa *pixat; /* templates for each class; bordered */
  53. /* and not dilated */
  54. struct Pixa *pixatd; /* templates for each class; bordered */
  55. /* and dilated */
  56. struct NumaHash *nahash; /* Hash table to find templates by size */
  57. struct Numa *nafgt; /* fg areas of undilated templates; */
  58. /* only used for rank < 1.0 */
  59. struct Pta *ptac; /* centroids of all bordered cc */
  60. struct Pta *ptact; /* centroids of all bordered template cc */
  61. struct Numa *naclass; /* array of class ids for each component */
  62. struct Numa *napage; /* array of page nums for each component */
  63. struct Pta *ptaul; /* array of UL corners at which the */
  64. /* template is to be placed for each */
  65. /* component */
  66. struct Pta *ptall; /* similar to ptaul, but for LL corners */
  67. };
  68. typedef struct JbClasser JBCLASSER;
  69. /* The JbData struct holds all the data required for
  70. * the compressed jbig-type representation of a set of images.
  71. * The data can be written to file, read back, and used
  72. * to regenerate an approximate version of the original,
  73. * which differs in two ways from the original:
  74. * (1) It uses a template image for each c.c. instead of the
  75. * original instance, for each occurrence on each page.
  76. * (2) It discards components with either a height or width larger
  77. * than the maximuma, given here by the lattice dimensions
  78. * used for storing the templates. */
  79. struct JbData
  80. {
  81. struct Pix *pix; /* template composite for all classes */
  82. l_int32 npages; /* number of pages */
  83. l_int32 w; /* max width of original page images */
  84. l_int32 h; /* max height of original page images */
  85. l_int32 nclass; /* number of classes */
  86. l_int32 latticew; /* lattice width for template composite */
  87. l_int32 latticeh; /* lattice height for template composite */
  88. struct Numa *naclass; /* array of class ids for each component */
  89. struct Numa *napage; /* array of page nums for each component */
  90. struct Pta *ptaul; /* array of UL corners at which the */
  91. /* template is to be placed for each */
  92. /* component */
  93. };
  94. typedef struct JbData JBDATA;
  95. /* Classifier methods */
  96. enum {
  97. JB_RANKHAUS = 0,
  98. JB_CORRELATION = 1
  99. };
  100. /* For jbGetComponents(): type of component to extract from images */
  101. enum {
  102. JB_CONN_COMPS = 0,
  103. JB_CHARACTERS = 1,
  104. JB_WORDS = 2
  105. };
  106. /* These parameters are used for naming the two files
  107. * in which the jbig2-like compressed data is stored. */
  108. #define JB_TEMPLATE_EXT ".templates.png"
  109. #define JB_DATA_EXT ".data"
  110. #endif /* LEPTONICA_JBCLASS_H */