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

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

http://eyes-free.googlecode.com/
C++ Header | 218 lines | 94 code | 36 blank | 88 comment | 0 complexity | 499ef32aaa1c7f5669ef00295d325ebb 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_MORPH_H
 17#define  LEPTONICA_MORPH_H
 18
 19/* 
 20 *  morph.h
 21 *
 22 *  Contains the following structs:
 23 *      struct Sel
 24 *      struct Sela
 25 *      struct Kernel
 26 *
 27 *  Contains definitions for:
 28 *      morphological b.c. flags
 29 *      structuring element types
 30 *      runlength flags for granulometry
 31 *      direction flags for grayscale morphology
 32 *      morphological operation flags
 33 *      standard border size
 34 *      grayscale intensity scaling flags
 35 *      morphological tophat flags
 36 *      arithmetic and logical operator flags
 37 *      grayscale morphology selection flags
 38 *      distance function b.c. flags
 39 *      image comparison flags
 40 *      color content flags
 41 */
 42
 43/*-------------------------------------------------------------------------*
 44 *                             Sel and Sel array                           *
 45 *-------------------------------------------------------------------------*/
 46#define  SEL_VERSION_NUMBER    1
 47
 48struct Sel
 49{
 50    l_int32       sy;          /* sel height                               */
 51    l_int32       sx;          /* sel width                                */
 52    l_int32       cy;          /* y location of sel origin                 */
 53    l_int32       cx;          /* x location of sel origin                 */
 54    l_int32     **data;        /* {0,1,2}; data[i][j] in [row][col] order  */
 55    char         *name;        /* used to find sel by name                 */
 56};
 57typedef struct Sel SEL;
 58
 59struct Sela
 60{
 61    l_int32          n;         /* number of sel actually stored           */
 62    l_int32          nalloc;    /* size of allocated ptr array             */
 63    struct Sel     **sel;       /* sel ptr array                           */
 64};
 65typedef struct Sela SELA;
 66
 67
 68/*-------------------------------------------------------------------------*
 69 *                                 Kernel                                  *
 70 *-------------------------------------------------------------------------*/
 71#define  KERNEL_VERSION_NUMBER    2
 72
 73struct L_Kernel
 74{
 75    l_int32       sy;          /* kernel height                            */
 76    l_int32       sx;          /* kernel width                             */
 77    l_int32       cy;          /* y location of kernel origin              */
 78    l_int32       cx;          /* x location of kernel origin              */
 79    l_float32   **data;        /* data[i][j] in [row][col] order           */
 80};
 81typedef struct L_Kernel  L_KERNEL;
 82
 83
 84/*-------------------------------------------------------------------------*
 85 *                 Morphological boundary condition flags                  *
 86 *
 87 *  Two types of boundary condition for erosion.
 88 *  The global variable MORPH_BC takes on one of these two values.
 89 *  See notes in morph.c for usage.
 90 *-------------------------------------------------------------------------*/
 91enum {
 92    SYMMETRIC_MORPH_BC = 0,
 93    ASYMMETRIC_MORPH_BC = 1
 94};
 95
 96
 97/*-------------------------------------------------------------------------*
 98 *                        Structuring element types                        *
 99 *-------------------------------------------------------------------------*/
100enum {
101    SEL_DONT_CARE  = 0,
102    SEL_HIT        = 1,
103    SEL_MISS       = 2
104};
105
106
107/*-------------------------------------------------------------------------*
108 *                  Runlength flags for granulometry                       *
109 *-------------------------------------------------------------------------*/
110enum {
111    L_RUN_OFF = 0,
112    L_RUN_ON  = 1
113};
114
115
116/*-------------------------------------------------------------------------*
117 *         Direction flags for grayscale morphology, granulometry,         *
118 *                   composable Sels, and convolution                      *
119 *-------------------------------------------------------------------------*/
120enum {
121    L_HORIZ            = 1,
122    L_VERT             = 2,
123    L_BOTH_DIRECTIONS  = 3
124};
125
126
127/*-------------------------------------------------------------------------*
128 *                   Morphological operation flags                         *
129 *-------------------------------------------------------------------------*/
130enum {
131    L_MORPH_DILATE    = 1,
132    L_MORPH_ERODE     = 2,
133    L_MORPH_OPEN      = 3,
134    L_MORPH_CLOSE     = 4,
135    L_MORPH_HMT       = 5
136};
137
138
139/*-------------------------------------------------------------------------*
140 *                    Grayscale intensity scaling flags                    *
141 *-------------------------------------------------------------------------*/
142enum {
143    L_LINEAR_SCALE  = 1,
144    L_LOG_SCALE     = 2
145};
146
147
148/*-------------------------------------------------------------------------*
149 *                      Morphological tophat flags                         *
150 *-------------------------------------------------------------------------*/
151enum {
152    L_TOPHAT_WHITE = 0,
153    L_TOPHAT_BLACK = 1
154};
155
156
157/*-------------------------------------------------------------------------*
158 *                Arithmetic and logical operator flags                    *
159 *                 (use on grayscale images and Numas)                     *
160 *-------------------------------------------------------------------------*/
161enum {
162    L_ARITH_ADD       = 1,
163    L_ARITH_SUBTRACT  = 2,
164    L_ARITH_MULTIPLY  = 3,   /* on numas only */
165    L_ARITH_DIVIDE    = 4,   /* on numas only */
166    L_UNION           = 5,   /* on numas only */
167    L_INTERSECTION    = 6,   /* on numas only */
168    L_SUBTRACTION     = 7,   /* on numas only */
169    L_EXCLUSIVE_OR    = 8    /* on numas only */
170};
171
172
173/*-------------------------------------------------------------------------*
174 *                        Min/max selection flags                          *
175 *-------------------------------------------------------------------------*/
176enum {
177    L_CHOOSE_MIN = 1,           /* useful in a downscaling "erosion"  */
178    L_CHOOSE_MAX = 2,           /* useful in a downscaling "dilation" */
179    L_CHOOSE_MAX_MIN_DIFF = 3   /* useful in a downscaling contrast   */
180};
181
182
183/*-------------------------------------------------------------------------*
184 *                    Distance function b.c. flags                         *
185 *-------------------------------------------------------------------------*/
186enum {
187    L_BOUNDARY_BG = 1,  /* assume bg outside image */
188    L_BOUNDARY_FG = 2   /* assume fg outside image */
189};
190
191
192/*-------------------------------------------------------------------------*
193 *                         Image comparison flags                          *
194 *-------------------------------------------------------------------------*/
195enum {
196    L_COMPARE_XOR = 1,
197    L_COMPARE_SUBTRACT = 2,
198    L_COMPARE_ABS_DIFF = 3
199};
200
201
202/*-------------------------------------------------------------------------*
203 *                          Color content flags                            *
204 *-------------------------------------------------------------------------*/
205enum {
206    L_MAX_DIFF_FROM_AVERAGE_2 = 1,
207    L_MAX_MIN_DIFF_FROM_2 = 2,
208    L_MAX_DIFF = 3
209};
210
211
212/*-------------------------------------------------------------------------*
213 *    Standard size of border added around images for special processing   *
214 *-------------------------------------------------------------------------*/
215static const l_int32  ADDED_BORDER = 32;   /* pixels, not bits */
216
217
218#endif  /* LEPTONICA_MORPH_H */