PageRenderTime 23ms CodeModel.GetById 11ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

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