Leptonica 1.68
C Image Processing Library

fhmtauto.c File Reference

Code generator, writes dwa code for user-supplied hit-miss transform Sels. More...

#include <string.h>
#include "allheaders.h"

Go to the source code of this file.

Defines

#define OUTROOT   "fhmtgen"
#define TEMPLATE1   "hmttemplate1.txt"
#define TEMPLATE2   "hmttemplate2.txt"
#define BUFFER_SIZE   512
#define PROTOARGS   "(l_uint32 *, l_int32, l_int32, l_int32, l_uint32 *, l_int32);"

Functions

static char * makeBarrelshiftString (l_int32 delx, l_int32 dely, l_int32 type)
static SARRAYsarrayMakeInnerLoopDWACode (SEL *sel, l_int32 nhits, l_int32 nmisses)
static SARRAYsarrayMakeWplsCode (SEL *sel)
l_int32 fhmtautogen (SELA *sela, l_int32 fileindex, const char *filename)
l_int32 fhmtautogen1 (SELA *sela, l_int32 fileindex, const char *filename)
l_int32 fhmtautogen2 (SELA *sela, l_int32 fileindex, const char *filename)

Variables

static char wpldecls [][60]
static char wpldefs [][24]
static char wplstrp [][10]
static char wplstrm [][10]

Detailed Description

Code generator, writes dwa code for user-supplied hit-miss transform Sels.

  Main function calls:
     l_int32             fhmtautogen()
     l_int32             fhmtautogen1()
     l_int32             fhmtautogen2()

  Static helpers:
     static SARRAY      *sarrayMakeWplsCode()
     static SARRAY      *sarrayMakeInnerLoopDWACode()
     static char        *makeBarrelshiftString()

  This automatically generates dwa code for the hit-miss transform.
  Here's a road map for how it all works.

  (1) You generate an array (a SELA) of hit-miss transform SELs.
      This can be done in several ways, including
         (a) calling the function selaAddHitMiss() for
             pre-compiled SELs
         (b) generating the SELA in code in line
         (c) reading in a SELA from file, using selaRead()
             or various other formats.

  (2) You call fhmtautogen1() and fhmtautogen2() on this SELA.
      This uses the text files hmttemplate1.txt and
      hmttemplate2.txt for building up the source code.  See the file
      prog/fhmtautogen.c for an example of how this is done.
      The output is written to files named fhmtgen.*.c
      and fhmtgenlow.*.c, where "*" is an integer that you
      input to this function.  That integer labels both
      the output files, as well as all the functions that
      are generated.  That way, using different integers,
      you can invoke fhmtautogen() any number of times
      to get functions that all have different names so that
      they can be linked into one program.
      
  (3) You copy the generated source code back to your src
      directory for compilation.  Put their names in the
      Makefile, regnerate the prototypes, and recompile
      the libraries.  Look at the Makefile to see how I've
      included fhmtgen.1.c and fhmtgenlow.1.c.  These files
      provide the high-level interfaces for the hmt, and
      the low-level interfaces to do the actual work.

  (4) In an application, you now use this interface.  Again
      for the example files generated, using integer "1":

         PIX   *pixHMTDwa_1(PIX *pixd, PIX *pixs, char *selname);

            or

         PIX   *pixFHMTGen_1(PIX *pixd, PIX *pixs, char *selname);

      where the selname is one of the set that were defined
      as the name field of sels.  This set is listed at the
      beginning of the file fhmtgen.1.c.
      As an example, see the file prog/fmtauto_reg.c, which
      verifies the correctness of the implementation by
      comparing the dwa result with that of full-image
      rasterops. 

Definition in file fhmtauto.c.


Define Documentation

#define OUTROOT   "fhmtgen"

Definition at line 83 of file fhmtauto.c.

Referenced by fhmtautogen1(), and fhmtautogen2().

#define TEMPLATE1   "hmttemplate1.txt"

Definition at line 84 of file fhmtauto.c.

Referenced by fhmtautogen1().

#define TEMPLATE2   "hmttemplate2.txt"

Definition at line 85 of file fhmtauto.c.

Referenced by fhmtautogen2().

#define BUFFER_SIZE   512
#define PROTOARGS   "(l_uint32 *, l_int32, l_int32, l_int32, l_uint32 *, l_int32);"

Definition at line 89 of file fhmtauto.c.

Referenced by fhmtautogen2().


Function Documentation

static char * makeBarrelshiftString ( l_int32  delx,
l_int32  dely,
l_int32  type 
) [static]
static SARRAY * sarrayMakeInnerLoopDWACode ( SEL sel,
l_int32  nhits,
l_int32  nmisses 
) [static]
static SARRAY * sarrayMakeWplsCode ( SEL sel) [static]
l_int32 fhmtautogen ( SELA sela,
l_int32  fileindex,
const char *  filename 
)

fhmtautogen()

Input: sela fileindex filename (<optional>; can be null) Return: 0 if OK; 1 on error

Notes: (1) This function generates all the code for implementing dwa morphological operations using all the sels in the sela. (2) See fhmtautogen1() and fhmtautogen2() for details.

Definition at line 192 of file fhmtauto.c.

References ERROR_INT, fhmtautogen1(), fhmtautogen2(), and PROCNAME.

Referenced by main().

l_int32 fhmtautogen1 ( SELA sela,
l_int32  fileindex,
const char *  filename 
)

fhmtautogen1()

Input: sel array fileindex filename (<optional>; can be null) Return: 0 if OK; 1 on error

Notes: (1) This function uses hmttemplate1.txt to create a top-level file that contains two functions that carry out the hit-miss transform for any of the sels in the input sela. (2) The fileindex parameter is inserted into the output filename, as described below. (3) If filename == NULL, the output file is fhmtgen.<n>.c, where <n> is equal to the 'fileindex' parameter. (4) If filename != NULL, the output file is <filename>.<n>.c. (5) Each sel must have at least one hit. A sel with only misses generates code that will abort the operation if it is called.

Definition at line 232 of file fhmtauto.c.

References BUFFER_SIZE, ERROR_INT, FREE, l_binaryRead(), l_binaryWrite(), L_COPY, L_INSERT, NULL, OUTROOT, PROCNAME, sarrayAddString(), sarrayAppendRange(), sarrayCreate(), sarrayCreateLinesFromString(), sarrayDestroy(), sarrayGetString(), sarrayParseRange(), sarrayToString(), selaGetCount(), selaGetSelnames(), size, stringNew(), and TEMPLATE1.

Referenced by fhmtautogen().

l_int32 fhmtautogen2 ( SELA sela,
l_int32  fileindex,
const char *  filename 
)

fhmtautogen2()

Input: sel array fileindex filename (<optional>; can be null) Return: 0 if OK; 1 on error

Notes: (1) This function uses hmttemplate2.txt to create a low-level file that contains the low-level functions for implementing the hit-miss transform for every sel in the input sela. (2) The fileindex parameter is inserted into the output filename, as described below. (3) If filename == NULL, the output file is fhmtgenlow.<n>.c, where <n> is equal to the 'fileindex' parameter. (4) If filename != NULL, the output file is <filename>low.<n>.c.

Definition at line 413 of file fhmtauto.c.

References BUFFER_SIZE, Sel::data, ERROR_INT, FREE, l_binaryRead(), l_binaryWrite(), L_COPY, L_INSERT, L_NOCOPY, NULL, OUTROOT, PROCNAME, PROTOARGS, sarrayAddString(), sarrayAppendRange(), sarrayConcatenate(), sarrayCreate(), sarrayCreateLinesFromString(), sarrayDestroy(), sarrayGetString(), sarrayMakeInnerLoopDWACode(), sarrayMakeWplsCode(), sarrayParseRange(), sarrayToString(), selaGetCount(), selaGetSel(), size, stringNew(), Sel::sx, Sel::sy, and TEMPLATE2.

Referenced by fhmtautogen().


Variable Documentation

char wpldecls[][60] [static]

Definition at line 95 of file fhmtauto.c.

Referenced by sarrayMakeWplsCode().

char wpldefs[][24] [static]

Definition at line 127 of file fhmtauto.c.

Referenced by sarrayMakeWplsCode().

char wplstrp[][10] [static]
Initial value:
 {"+ wpls", "+ wpls2", "+ wpls3", "+ wpls4",
                             "+ wpls5", "+ wpls6", "+ wpls7", "+ wpls8",
                             "+ wpls9", "+ wpls10", "+ wpls11", "+ wpls12",
                             "+ wpls13", "+ wpls14", "+ wpls15", "+ wpls16",
                             "+ wpls17", "+ wpls18", "+ wpls19", "+ wpls20",
                             "+ wpls21", "+ wpls22", "+ wpls23", "+ wpls24",
                             "+ wpls25", "+ wpls26", "+ wpls27", "+ wpls28",
                             "+ wpls29", "+ wpls30", "+ wpls31"}

Definition at line 159 of file fhmtauto.c.

Referenced by makeBarrelshiftString().

char wplstrm[][10] [static]
Initial value:
 {"- wpls", "- wpls2", "- wpls3", "- wpls4",
                             "- wpls5", "- wpls6", "- wpls7", "- wpls8",
                             "- wpls9", "- wpls10", "- wpls11", "- wpls12",
                             "- wpls13", "- wpls14", "- wpls15", "- wpls16",
                             "- wpls17", "- wpls18", "- wpls19", "- wpls20",
                             "- wpls21", "- wpls22", "- wpls23", "- wpls24",
                             "- wpls25", "- wpls26", "- wpls27", "- wpls28",
                             "- wpls29", "- wpls30", "- wpls31"}

Definition at line 168 of file fhmtauto.c.

Referenced by makeBarrelshiftString().

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines