Leptonica 1.68
C Image Processing Library

array.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_ARRAY_H
00017 #define  LEPTONICA_ARRAY_H
00018 
00019 /*
00020  *  Contains the following structs:
00021  *      struct Numa
00022  *      struct Numaa
00023  *      struct Numa2d
00024  *      struct NumaHash
00025  *      struct Sarray
00026  *      struct L_Bytea
00027  *
00028  *  Contains definitions for:
00029  *      Numa interpolation flags
00030  */
00031 
00032 
00033 /*------------------------------------------------------------------------* 
00034  *                             Array Structs                              *
00035  *------------------------------------------------------------------------*/
00036 
00037 #define  NUMA_VERSION_NUMBER     1
00038 
00039     /* Number array: an array of floats */
00040 struct Numa
00041 {
00042     l_int32          nalloc;    /* size of allocated number array      */
00043     l_int32          n;         /* number of numbers saved             */
00044     l_int32          refcount;  /* reference count (1 if no clones)    */
00045     l_float32        startx;    /* x value assigned to array[0]        */
00046     l_float32        delx;      /* change in x value as i --> i + 1    */
00047     l_float32       *array;     /* number array                        */
00048 };
00049 typedef struct Numa  NUMA;
00050 
00051 
00052     /* Array of number arrays */
00053 struct Numaa
00054 {
00055     l_int32          nalloc;    /* size of allocated ptr array          */
00056     l_int32          n;         /* number of Numa saved                 */
00057     struct Numa    **numa;      /* array of Numa                        */
00058 };
00059 typedef struct Numaa  NUMAA;
00060 
00061 
00062 
00063     /* Sparse 2-dimensional array of number arrays */
00064 struct Numa2d
00065 {
00066     l_int32          nrows;      /* number of rows allocated for ptr array  */
00067     l_int32          ncols;      /* number of cols allocated for ptr array  */
00068     l_int32          initsize;   /* initial size of each numa that is made  */
00069     struct Numa   ***numa;       /* 2D array of Numa                        */
00070 };
00071 typedef struct Numa2d  NUMA2D;
00072 
00073 
00074     /* A hash table of Numas */
00075 struct NumaHash
00076 {
00077     l_int32          nbuckets;
00078     l_int32          initsize;   /* initial size of each numa that is made  */
00079     struct Numa    **numa;
00080 };
00081 typedef struct NumaHash NUMAHASH;
00082 
00083 
00084 #define  SARRAY_VERSION_NUMBER     1
00085 
00086     /* String array: an array of C strings */
00087 struct Sarray
00088 {
00089     l_int32          nalloc;    /* size of allocated ptr array         */
00090     l_int32          n;         /* number of strings allocated         */
00091     l_int32          refcount;  /* reference count (1 if no clones)    */
00092     char           **array;     /* string array                        */
00093 };
00094 typedef struct Sarray SARRAY;
00095 
00096 
00097     /* Byte array (analogous to C++ "string") */
00098 struct L_Bytea
00099 {
00100     size_t           nalloc;    /* number of bytes allocated in data array  */
00101     size_t           size;      /* number of bytes presently used           */
00102     l_int32          refcount;  /* reference count (1 if no clones)         */
00103     l_uint8         *data;      /* data array                               */
00104 };
00105 typedef struct L_Bytea L_BYTEA;
00106 
00107 
00108 /*------------------------------------------------------------------------* 
00109  *                              Array flags                               *
00110  *------------------------------------------------------------------------*/
00111 
00112     /* Flags for interpolation in Numa */
00113 enum {
00114     L_LINEAR_INTERP = 1,        /* linear     */
00115     L_QUADRATIC_INTERP = 2      /* quadratic  */
00116 };
00117 
00118     /* Flags for added borders in Numa */
00119 enum {
00120     L_EXTENDED_BORDER = 1,      /* extended with same value           */
00121     L_MIRRORED_BORDER = 2       /* mirrored                           */
00122 };
00123 
00124 
00125 #endif  /* LEPTONICA_ARRAY_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines