Leptonica 1.68
C Image Processing Library

jbclass.h

Go to the documentation of this file.
00001 /*====================================================================*
00002  -  Copyright (C) 2001 Leptonica.  All rights reserved.
00003  -  This software is distributed in the hope that it will be
00004  -  useful, but with NO WARRANTY OF ANY KIND.
00005  -  No author or distributor accepts responsibility to anyone for the
00006  -  consequences of using this software, or for whether it serves any
00007  -  particular purpose or works at all, unless he or she says so in
00008  -  writing.  Everyone is granted permission to copy, modify and
00009  -  redistribute this source code, for commercial or non-commercial
00010  -  purposes, with the following restrictions: (1) the origin of this
00011  -  source code must not be misrepresented; (2) modified versions must
00012  -  be plainly marked as such; and (3) this notice may not be removed
00013  -  or altered from any source or modified source distribution.
00014  *====================================================================*/
00015 
00016 #ifndef  LEPTONICA_JBCLASS_H
00017 #define  LEPTONICA_JBCLASS_H
00018 
00019 /*
00020  * jbclass.h
00021  *
00022  *       JbClasser
00023  *       JbData
00024  */
00025 
00026 
00027     /* The JbClasser struct holds all the data accumulated during the
00028      * classification process that can be used for a compressed
00029      * jbig2-type representation of a set of images.  This is created
00030      * in an initialization process and added to as the selected components
00031      * on each successive page are analyzed.   */
00032 struct JbClasser
00033 {
00034     struct Sarray   *safiles;      /* input page image file names            */
00035     l_int32          method;       /* JB_RANKHAUS, JB_CORRELATION            */
00036     l_int32          components;   /* JB_CONN_COMPS, JB_CHARACTERS or        */
00037                                    /* JB_WORDS                               */
00038     l_int32          maxwidth;     /* max component width allowed            */
00039     l_int32          maxheight;    /* max component height allowed           */
00040     l_int32          npages;       /* number of pages already processed      */
00041     l_int32          baseindex;    /* number of components already processed */
00042                                    /* on fully processed pages               */
00043     struct Numa     *nacomps;      /* number of components on each page      */
00044     l_int32          sizehaus;     /* size of square struct element for haus */
00045     l_float32        rankhaus;     /* rank val of haus match, each way       */
00046     l_float32        thresh;       /* thresh value for correlation score     */
00047     l_float32        weightfactor; /* corrects thresh value for heaver       */
00048                                    /* components; use 0 for no correction    */
00049     struct Numa     *naarea;       /* w * h of each template, without extra  */
00050                                    /* border pixels                          */
00051     l_int32          w;            /* max width of original src images       */
00052     l_int32          h;            /* max height of original src images      */
00053     l_int32          nclass;       /* current number of classes              */
00054     l_int32          keep_pixaa;   /* If zero, pixaa isn't filled            */
00055     struct Pixaa    *pixaa;        /* instances for each class; unbordered   */
00056     struct Pixa     *pixat;        /* templates for each class; bordered     */
00057                                    /* and not dilated                        */
00058     struct Pixa     *pixatd;       /* templates for each class; bordered     */
00059                                    /* and dilated                            */
00060     struct NumaHash *nahash;       /* Hash table to find templates by size   */
00061     struct Numa     *nafgt;        /* fg areas of undilated templates;       */
00062                                    /* only used for rank < 1.0               */
00063     struct Pta      *ptac;         /* centroids of all bordered cc           */
00064     struct Pta      *ptact;        /* centroids of all bordered template cc  */
00065     struct Numa     *naclass;      /* array of class ids for each component  */
00066     struct Numa     *napage;       /* array of page nums for each component  */
00067     struct Pta      *ptaul;        /* array of UL corners at which the       */
00068                                    /* template is to be placed for each      */
00069                                    /* component                              */
00070     struct Pta      *ptall;        /* similar to ptaul, but for LL corners   */
00071 };
00072 typedef struct JbClasser  JBCLASSER;
00073 
00074 
00075     /* The JbData struct holds all the data required for
00076      * the compressed jbig-type representation of a set of images.
00077      * The data can be written to file, read back, and used
00078      * to regenerate an approximate version of the original,
00079      * which differs in two ways from the original:
00080      *   (1) It uses a template image for each c.c. instead of the
00081      *       original instance, for each occurrence on each page.
00082      *   (2) It discards components with either a height or width larger
00083      *       than the maximuma, given here by the lattice dimensions
00084      *       used for storing the templates.   */
00085 struct JbData
00086 {
00087     struct Pix         *pix;        /* template composite for all classes    */
00088     l_int32             npages;     /* number of pages                       */
00089     l_int32             w;          /* max width of original page images     */
00090     l_int32             h;          /* max height of original page images    */
00091     l_int32             nclass;     /* number of classes                     */
00092     l_int32             latticew;   /* lattice width for template composite  */
00093     l_int32             latticeh;   /* lattice height for template composite */
00094     struct Numa        *naclass;    /* array of class ids for each component */
00095     struct Numa        *napage;     /* array of page nums for each component */
00096     struct Pta         *ptaul;      /* array of UL corners at which the      */
00097                                     /* template is to be placed for each     */
00098                                     /* component                             */
00099 };
00100 typedef struct JbData  JBDATA;
00101 
00102 
00103     /* Classifier methods */
00104 enum {
00105    JB_RANKHAUS = 0,
00106    JB_CORRELATION = 1
00107 };
00108 
00109     /* For jbGetComponents(): type of component to extract from images */
00110 enum {
00111    JB_CONN_COMPS = 0,
00112    JB_CHARACTERS = 1,
00113    JB_WORDS = 2
00114 };
00115 
00116     /* These parameters are used for naming the two files
00117      * in which the jbig2-like compressed data is stored.  */
00118 #define   JB_TEMPLATE_EXT      ".templates.png"
00119 #define   JB_DATA_EXT          ".data"
00120 
00121 
00122 #endif  /* LEPTONICA_JBCLASS_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines