Leptonica 1.68
C Image Processing Library

morph.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_MORPH_H
00017 #define  LEPTONICA_MORPH_H
00018 
00019 /* 
00020  *  morph.h
00021  *
00022  *  Contains the following structs:
00023  *      struct Sel
00024  *      struct Sela
00025  *      struct Kernel
00026  *
00027  *  Contains definitions for:
00028  *      morphological b.c. flags
00029  *      structuring element types
00030  *      runlength flags for granulometry
00031  *      direction flags for grayscale morphology
00032  *      morphological operation flags
00033  *      standard border size
00034  *      grayscale intensity scaling flags
00035  *      morphological tophat flags
00036  *      arithmetic and logical operator flags
00037  *      grayscale morphology selection flags
00038  *      distance function b.c. flags
00039  *      image comparison flags
00040  *      color content flags
00041  */
00042 
00043 /*-------------------------------------------------------------------------*
00044  *                             Sel and Sel array                           *
00045  *-------------------------------------------------------------------------*/
00046 #define  SEL_VERSION_NUMBER    1
00047 
00048 struct Sel
00049 {
00050     l_int32       sy;          /* sel height                               */
00051     l_int32       sx;          /* sel width                                */
00052     l_int32       cy;          /* y location of sel origin                 */
00053     l_int32       cx;          /* x location of sel origin                 */
00054     l_int32     **data;        /* {0,1,2}; data[i][j] in [row][col] order  */
00055     char         *name;        /* used to find sel by name                 */
00056 };
00057 typedef struct Sel SEL;
00058 
00059 struct Sela
00060 {
00061     l_int32          n;         /* number of sel actually stored           */
00062     l_int32          nalloc;    /* size of allocated ptr array             */
00063     struct Sel     **sel;       /* sel ptr array                           */
00064 };
00065 typedef struct Sela SELA;
00066 
00067 
00068 /*-------------------------------------------------------------------------*
00069  *                                 Kernel                                  *
00070  *-------------------------------------------------------------------------*/
00071 #define  KERNEL_VERSION_NUMBER    2
00072 
00073 struct L_Kernel
00074 {
00075     l_int32       sy;          /* kernel height                            */
00076     l_int32       sx;          /* kernel width                             */
00077     l_int32       cy;          /* y location of kernel origin              */
00078     l_int32       cx;          /* x location of kernel origin              */
00079     l_float32   **data;        /* data[i][j] in [row][col] order           */
00080 };
00081 typedef struct L_Kernel  L_KERNEL;
00082 
00083 
00084 /*-------------------------------------------------------------------------*
00085  *                 Morphological boundary condition flags                  *
00086  *
00087  *  Two types of boundary condition for erosion.
00088  *  The global variable MORPH_BC takes on one of these two values.
00089  *  See notes in morph.c for usage.
00090  *-------------------------------------------------------------------------*/
00091 enum {
00092     SYMMETRIC_MORPH_BC = 0,
00093     ASYMMETRIC_MORPH_BC = 1
00094 };
00095 
00096 
00097 /*-------------------------------------------------------------------------*
00098  *                        Structuring element types                        *
00099  *-------------------------------------------------------------------------*/
00100 enum {
00101     SEL_DONT_CARE  = 0,
00102     SEL_HIT        = 1,
00103     SEL_MISS       = 2
00104 };
00105 
00106 
00107 /*-------------------------------------------------------------------------*
00108  *                  Runlength flags for granulometry                       *
00109  *-------------------------------------------------------------------------*/
00110 enum {
00111     L_RUN_OFF = 0,
00112     L_RUN_ON  = 1
00113 };
00114 
00115 
00116 /*-------------------------------------------------------------------------*
00117  *         Direction flags for grayscale morphology, granulometry,         *
00118  *                   composable Sels, and convolution                      *
00119  *-------------------------------------------------------------------------*/
00120 enum {
00121     L_HORIZ            = 1,
00122     L_VERT             = 2,
00123     L_BOTH_DIRECTIONS  = 3
00124 };
00125 
00126 
00127 /*-------------------------------------------------------------------------*
00128  *                   Morphological operation flags                         *
00129  *-------------------------------------------------------------------------*/
00130 enum {
00131     L_MORPH_DILATE    = 1,
00132     L_MORPH_ERODE     = 2,
00133     L_MORPH_OPEN      = 3,
00134     L_MORPH_CLOSE     = 4,
00135     L_MORPH_HMT       = 5
00136 };
00137 
00138 
00139 /*-------------------------------------------------------------------------*
00140  *                    Grayscale intensity scaling flags                    *
00141  *-------------------------------------------------------------------------*/
00142 enum {
00143     L_LINEAR_SCALE  = 1,
00144     L_LOG_SCALE     = 2
00145 };
00146 
00147 
00148 /*-------------------------------------------------------------------------*
00149  *                      Morphological tophat flags                         *
00150  *-------------------------------------------------------------------------*/
00151 enum {
00152     L_TOPHAT_WHITE = 0,
00153     L_TOPHAT_BLACK = 1
00154 };
00155 
00156 
00157 /*-------------------------------------------------------------------------*
00158  *                Arithmetic and logical operator flags                    *
00159  *                 (use on grayscale images and Numas)                     *
00160  *-------------------------------------------------------------------------*/
00161 enum {
00162     L_ARITH_ADD       = 1,
00163     L_ARITH_SUBTRACT  = 2,
00164     L_ARITH_MULTIPLY  = 3,   /* on numas only */
00165     L_ARITH_DIVIDE    = 4,   /* on numas only */
00166     L_UNION           = 5,   /* on numas only */
00167     L_INTERSECTION    = 6,   /* on numas only */
00168     L_SUBTRACTION     = 7,   /* on numas only */
00169     L_EXCLUSIVE_OR    = 8    /* on numas only */
00170 };
00171 
00172 
00173 /*-------------------------------------------------------------------------*
00174  *                        Min/max selection flags                          *
00175  *-------------------------------------------------------------------------*/
00176 enum {
00177     L_CHOOSE_MIN = 1,           /* useful in a downscaling "erosion"  */
00178     L_CHOOSE_MAX = 2,           /* useful in a downscaling "dilation" */
00179     L_CHOOSE_MAX_MIN_DIFF = 3   /* useful in a downscaling contrast   */
00180 };
00181 
00182 
00183 /*-------------------------------------------------------------------------*
00184  *                    Distance function b.c. flags                         *
00185  *-------------------------------------------------------------------------*/
00186 enum {
00187     L_BOUNDARY_BG = 1,  /* assume bg outside image */
00188     L_BOUNDARY_FG = 2   /* assume fg outside image */
00189 };
00190 
00191 
00192 /*-------------------------------------------------------------------------*
00193  *                         Image comparison flags                          *
00194  *-------------------------------------------------------------------------*/
00195 enum {
00196     L_COMPARE_XOR = 1,
00197     L_COMPARE_SUBTRACT = 2,
00198     L_COMPARE_ABS_DIFF = 3
00199 };
00200 
00201 
00202 /*-------------------------------------------------------------------------*
00203  *                          Color content flags                            *
00204  *-------------------------------------------------------------------------*/
00205 enum {
00206     L_MAX_DIFF_FROM_AVERAGE_2 = 1,
00207     L_MAX_MIN_DIFF_FROM_2 = 2,
00208     L_MAX_DIFF = 3
00209 };
00210 
00211 
00212 /*-------------------------------------------------------------------------*
00213  *    Standard size of border added around images for special processing   *
00214  *-------------------------------------------------------------------------*/
00215 static const l_int32  ADDED_BORDER = 32;   /* pixels, not bits */
00216 
00217 
00218 #endif  /* LEPTONICA_MORPH_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines