Leptonica 1.68
C Image Processing Library

ccbord.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_CCBORD_H
00017 #define  LEPTONICA_CCBORD_H
00018 
00019 /*
00020  *  ccbord.h
00021  *
00022  *           CCBord:   represents a single connected component
00023  *           CCBorda:  an array of CCBord
00024  */
00025 
00026     /* Use in ccbaStepChainsToPixCoords() */
00027 enum {
00028       CCB_LOCAL_COORDS = 1,
00029       CCB_GLOBAL_COORDS = 2
00030 };
00031 
00032     /* Use in ccbaGenerateSPGlobalLocs() */
00033 enum {
00034       CCB_SAVE_ALL_PTS = 1,
00035       CCB_SAVE_TURNING_PTS = 2
00036 };
00037 
00038 
00039     /* CCBord contains:
00040      *
00041      *    (1) a minimally-clipped bitmap of the component (pix),
00042      *    (2) a boxa consisting of:
00043      *          for the primary component:
00044      *                (xul, yul) pixel location in global coords
00045      *                (w, h) of the bitmap
00046      *          for the hole components:
00047      *                (x, y) in relative coordinates in primary component
00048      *                (w, h) of the hole border (which is 2 pixels
00049      *                       larger in each direction than the hole itself)
00050      *    (3) a pta ('start') of the initial border pixel location for each
00051      *        closed curve, all in relative coordinates of the primary
00052      *        component.  This is given for the primary component,
00053      *        followed by the hole components, if any.
00054      *    (4) a refcount of the ccbord; used internally when a ccbord
00055      *        is accessed from a ccborda (array of ccbord)
00056      *    (5) a ptaa for the chain code for the border in relative
00057      *        coordinates, where the first pta is the exterior border
00058      *        and all other pta are for interior borders (holes)
00059      *    (6) a ptaa for the global pixel loc rendition of the border,
00060      *        where the first pta is the exterior border and all other
00061      *        pta are for interior borders (holes).
00062      *        This is derived from the local or step chain code.
00063      *    (7) a numaa for the chain code for the border as orientation
00064      *        directions between successive border pixels, where
00065      *        the first numa is the exterior border and all other
00066      *        numa are for interior borders (holes).  This is derived
00067      *        from the local chain code.  The 8 directions are 0 - 7.
00068      *    (8) a pta for a single chain for each c.c., comprised of outer
00069      *        and hole borders, plus cut paths between them, all in
00070      *        local coords.
00071      *    (9) a pta for a single chain for each c.c., comprised of outer
00072      *        and hole borders, plus cut paths between them, all in
00073      *        global coords.
00074      */
00075 struct CCBord
00076 {
00077     struct Pix          *pix;            /* component bitmap (min size)      */
00078     struct Boxa         *boxa;           /* regions of each closed curve     */
00079     struct Pta          *start;          /* initial border pixel locations   */
00080     l_int32              refcount;       /* number of handles; start at 1    */
00081     struct Ptaa         *local;          /* ptaa of chain pixels (local)     */
00082     struct Ptaa         *global;         /* ptaa of chain pixels (global)    */
00083     struct Numaa        *step;           /* numaa of chain code (step dir)   */
00084     struct Pta          *splocal;        /* pta of single chain (local)      */
00085     struct Pta          *spglobal;       /* pta of single chain (global)     */
00086 };
00087 typedef struct CCBord CCBORD;
00088 
00089 
00090 struct CCBorda
00091 {
00092     struct Pix          *pix;            /* input pix (may be null)          */
00093     l_int32              w;              /* width of pix                     */
00094     l_int32              h;              /* height of pix                    */
00095     l_int32              n;              /* number of ccbord in ptr array    */
00096     l_int32              nalloc;         /* number of ccbord ptrs allocated  */
00097     struct CCBord      **ccb;            /* ccb ptr array                    */
00098 };
00099 typedef struct CCBorda CCBORDA;
00100 
00101 
00102 #endif  /* LEPTONICA_CCBORD_H */
00103 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines