Leptonica  1.82.0
Image processing and image analysis suite
sel1.c File Reference
#include <string.h>
#include "allheaders.h"

Go to the source code of this file.

Data Structures

struct  CompParameterMap
 

Functions

static l_int32 selaExtendArray (SELA *sela)
 
static SELselCreateFromSArray (SARRAY *sa, l_int32 first, l_int32 last)
 
SELAselaCreate (l_int32 n)
 
void selaDestroy (SELA **psela)
 
SELselCreate (l_int32 height, l_int32 width, const char *name)
 
void selDestroy (SEL **psel)
 
SELselCopy (SEL *sel)
 
SELselCreateBrick (l_int32 h, l_int32 w, l_int32 cy, l_int32 cx, l_int32 type)
 
SELselCreateComb (l_int32 factor1, l_int32 factor2, l_int32 direction)
 
l_int32 ** create2dIntArray (l_int32 sy, l_int32 sx)
 
l_ok selaAddSel (SELA *sela, SEL *sel, const char *selname, l_int32 copyflag)
 
l_int32 selaGetCount (SELA *sela)
 
SELselaGetSel (SELA *sela, l_int32 i)
 
char * selGetName (SEL *sel)
 
l_ok selSetName (SEL *sel, const char *name)
 
l_ok selaFindSelByName (SELA *sela, const char *name, l_int32 *pindex, SEL **psel)
 
l_ok selGetElement (SEL *sel, l_int32 row, l_int32 col, l_int32 *ptype)
 
l_ok selSetElement (SEL *sel, l_int32 row, l_int32 col, l_int32 type)
 
l_ok selGetParameters (SEL *sel, l_int32 *psy, l_int32 *psx, l_int32 *pcy, l_int32 *pcx)
 
l_ok selSetOrigin (SEL *sel, l_int32 cy, l_int32 cx)
 
l_ok selGetTypeAtOrigin (SEL *sel, l_int32 *ptype)
 
char * selaGetBrickName (SELA *sela, l_int32 hsize, l_int32 vsize)
 
char * selaGetCombName (SELA *sela, l_int32 size, l_int32 direction)
 
l_ok getCompositeParameters (l_int32 size, l_int32 *psize1, l_int32 *psize2, char **pnameh1, char **pnameh2, char **pnamev1, char **pnamev2)
 
SARRAYselaGetSelnames (SELA *sela)
 
l_ok selFindMaxTranslations (SEL *sel, l_int32 *pxp, l_int32 *pyp, l_int32 *pxn, l_int32 *pyn)
 
SELselRotateOrth (SEL *sel, l_int32 quads)
 
SELAselaRead (const char *fname)
 
SELAselaReadStream (FILE *fp)
 
SELselRead (const char *fname)
 
SELselReadStream (FILE *fp)
 
l_ok selaWrite (const char *fname, SELA *sela)
 
l_ok selaWriteStream (FILE *fp, SELA *sela)
 
l_ok selWrite (const char *fname, SEL *sel)
 
l_ok selWriteStream (FILE *fp, SEL *sel)
 
SELselCreateFromString (const char *text, l_int32 h, l_int32 w, const char *name)
 
char * selPrintToString (SEL *sel)
 
SELAselaCreateFromFile (const char *filename)
 
SELselCreateFromPta (PTA *pta, l_int32 cy, l_int32 cx, const char *name)
 
SELselCreateFromPix (PIX *pix, l_int32 cy, l_int32 cx, const char *name)
 
SELselReadFromColorImage (const char *pathname)
 
SELselCreateFromColorPix (PIX *pixs, const char *selname)
 
SELAselaCreateFromColorPixa (PIXA *pixa, SARRAY *sa)
 
PIXselDisplayInPix (SEL *sel, l_int32 size, l_int32 gthick)
 
PIXselaDisplayInPix (SELA *sela, l_int32 size, l_int32 gthick, l_int32 spacing, l_int32 ncols)
 

Variables

static const l_uint32 MaxPtrArraySize = 10000
 
static const l_int32 InitialPtrArraySize = 50
 
static const l_uint32 MaxKernelSize = 10000
 
static const l_uint32 MaxPixTemplateSize = 100
 
static const l_uint32 MaxPixTemplateHits = 1000
 
static const struct CompParameterMap comp_parameter_map []
 

Detailed Description


     Basic ops on Sels and Selas

        Create/destroy/copy:
           SELA      *selaCreate()
           void       selaDestroy()
           SEL       *selCreate()
           void       selDestroy()
           SEL       *selCopy()
           SEL       *selCreateBrick()
           SEL       *selCreateComb()

        Helper proc:
           l_int32  **create2dIntArray()

        Extension of sela:
           SELA      *selaAddSel()
           static l_int32  selaExtendArray()

        Accessors:
           l_int32    selaGetCount()
           SEL       *selaGetSel()
           char      *selGetName()
           l_int32    selSetName()
           l_int32    selaFindSelByName()
           l_int32    selGetElement()
           l_int32    selSetElement()
           l_int32    selGetParameters()
           l_int32    selSetOrigin()
           l_int32    selGetTypeAtOrigin()
           char      *selaGetBrickName()
           char      *selaGetCombName()
    static char      *selaComputeCompositeParameters()
           l_int32    getCompositeParameters()
           SARRAY    *selaGetSelnames()

        Max translations for erosion and hmt
           l_int32    selFindMaxTranslations()

        Rotation by multiples of 90 degrees
           SEL       *selRotateOrth()

        Sela and Sel serialized I/O
           SELA      *selaRead()
           SELA      *selaReadStream()
           SEL       *selRead()
           SEL       *selReadStream()
           l_int32    selaWrite()
           l_int32    selaWriteStream()
           l_int32    selWrite()
           l_int32    selWriteStream()

        Building custom hit-miss sels from compiled strings
           SEL       *selCreateFromString()
           char      *selPrintToString()     [for debugging]

        Building custom hit-miss sels from a simple file format
           SELA      *selaCreateFromFile()
           static SEL *selCreateFromSArray()

        Making hit-only sels from Pta and Pix
           SEL       *selCreateFromPta()
           SEL       *selCreateFromPix()

        Making hit-miss sels from Pix and image files
           SEL       *selReadFromColorImage()
           SEL       *selCreateFromColorPix()
           SELA      *selaCreateFromColorPixa()

        Printable display of sel
           PIX       *selDisplayInPix()
           PIX       *selaDisplayInPix()

    Usage notes:
       In this file we have seven functions that make sels:
         (1)  selCreate(), with input (h, w, [name])
              The generic function.  Roll your own, using selSetElement().
         (2)  selCreateBrick(), with input (h, w, cy, cx, val)
              The most popular function.  Makes a rectangular sel of
              all hits, misses or don't-cares.  We have many morphology
              operations that create a sel of all hits, use it, and
              destroy it.
         (3)  selCreateFromString() with input (text, h, w, [name])
              Adam Langley's clever function, allows you to make a hit-miss
              sel from a string in code that is geometrically laid out
              just like the actual sel.
         (4)  selaCreateFromFile() with input (filename)
              This parses a simple file format to create an array of
              hit-miss sels.  The sel data uses the same encoding
              as in (3), with geometrical layout enforced.
         (5)  selCreateFromPta() with input (pta, cy, cx, [name])
              Another way to make a sel with only hits.
         (6)  selCreateFromPix() with input (pix, cy, cx, [name])
              Yet another way to make a sel from hits.
         (7)  selCreateFromColorPix() with input (pix, name).
              Another way to make a general hit-miss sel, starting with
              an image editor.
       In addition, there are three functions in selgen.c that
       automatically generate a hit-miss sel from a pix and
       a number of parameters.  This is useful for problems like
       "find all patterns that look like this one."

       Consistency, being the hobgoblin of small minds,
       is adhered to here in the dimensioning and accessing of sels.
       Everything is done in standard matrix (row, column) order.
       When we set specific elements in a sel, we likewise use
       (row, col) ordering:
            selSetElement(), with input (row, col, type)

Definition in file sel1.c.

Function Documentation

◆ create2dIntArray()

l_int32** create2dIntArray ( l_int32  sy,
l_int32  sx 
)

create2dIntArray()

Parameters
[in]syrows == height
[in]sxcolumns == width
Returns
doubly indexed array i.e., an array of sy row pointers, each of which points to an array of sx ints
Notes:
     (1) The array[sy][sx] is indexed in standard "matrix notation",
         with the row index first.

Definition at line 517 of file sel1.c.

Referenced by selCopy(), and selCreate().

◆ getCompositeParameters()

l_ok getCompositeParameters ( l_int32  size,
l_int32 *  psize1,
l_int32 *  psize2,
char **  pnameh1,
char **  pnameh2,
char **  pnamev1,
char **  pnamev2 
)

getCompositeParameters()

Parameters
[in]size
[out]psize1[optional] brick factor size
[out]psize2[optional] comb factor size
[out]pnameh1[optional] name of horiz brick
[out]pnameh2[optional] name of horiz comb
[out]pnamev1[optional] name of vert brick
[out]pnamev2[optional] name of vert comb
Returns
0 if OK, 1 on error
Notes:
     (1) This uses the big lookup table at the top of this file.
     (2) All returned strings are copies that must be freed.

Definition at line 1101 of file sel1.c.

◆ selaAddSel()

l_ok selaAddSel ( SELA sela,
SEL sel,
const char *  selname,
l_int32  copyflag 
)

selaAddSel()

Parameters
[in]sela
[in]selto be added
[in]selnameignored if already defined in sel; req'd in sel when added to a sela
[in]copyflagL_INSERT or L_COPY
Returns
0 if OK; 1 on error
Notes:
     (1) This adds a sel, either inserting or making a copy.
     (2) Because every sel in a sela must have a name, it copies
         the input name if necessary.  You can input NULL for
         selname if the sel already has a name.

Definition at line 559 of file sel1.c.

References L_COPY, L_INSERT, Sela::n, Sela::nalloc, Sel::name, Sela::sel, selaExtendArray(), selaGetCount(), selCopy(), selDestroy(), and stringNew().

Referenced by selaAddCrossJunctions(), selaAddDwaLinear(), selaAddHitMiss(), selaAddTJunctions(), selaCreateFromColorPixa(), selaCreateFromFile(), and selaMakeThinSets().

◆ selaCreate()

SELA* selaCreate ( l_int32  n)

selaCreate()

Parameters
[in]ninitial number of sel ptrs; use 0 for default
Returns
sela, or NULL on error

Definition at line 251 of file sel1.c.

Referenced by sela4and8ccThin(), sela4ccThin(), sela8ccThin(), selaAddBasic(), selaAddCrossJunctions(), selaAddDwaCombs(), selaAddDwaLinear(), selaAddHitMiss(), selaAddTJunctions(), selaCreateFromColorPixa(), selaCreateFromFile(), and selaMakeThinSets().

◆ selaCreateFromColorPixa()

SELA* selaCreateFromColorPixa ( PIXA pixa,
SARRAY sa 
)

selaCreateFromColorPixa()

Parameters
[in]pixacolor pixa representing the sels
[in]sasarray of sel names
Returns
sel if OK, NULL on error
Notes:
     (1) See notes in selCreateFromColorPix()
     (2) sa is required because all sels that are put in a sela
         must have a name.

Definition at line 2203 of file sel1.c.

References L_CLONE, L_INSERT, L_NOCOPY, pixaGetCount(), pixaGetPix(), pixDestroy(), sarrayGetString(), selaAddSel(), selaCreate(), and selCreateFromColorPix().

◆ selaCreateFromFile()

SELA* selaCreateFromFile ( const char *  filename)

selaCreateFromFile()

Parameters
[in]filename
Returns
sela, or NULL on error
Notes:
     (1) The file contains a sequence of Sel descriptions.
     (2) Each Sel is formatted as follows:
          ~ Any number of comment lines starting with '#' are ignored
          ~ The next line contains the selname
          ~ The next lines contain the Sel data.  They must be
            formatted similarly to the string format in
            selCreateFromString(), with each line beginning and
            ending with a double-quote, and showing the 2D layout.
          ~ Each Sel ends when a blank line, a comment line, or
            the end of file is reached.
     (3) See selCreateFromString() for a description of the string
         format for the Sel data.  As an example, here are the lines
         of is a valid file for a single Sel.  In the file, all lines
         are left-justified:
                   # diagonal sel
                   sel_5diag
                   "x    "
                   " x   "
                   "  X  "
                   "   x "
                   "    x"

Definition at line 1773 of file sel1.c.

References l_binaryRead(), L_NOCOPY, lept_stderr(), numaAddNumber(), numaCreate(), numaDestroy(), numaGetCount(), numaGetIValue(), sarrayCreateLinesFromString(), sarrayDestroy(), sarrayGetCount(), sarrayGetString(), selaAddSel(), selaCreate(), selaDestroy(), and selCreateFromSArray().

◆ selaDestroy()

void selaDestroy ( SELA **  psela)

selaDestroy()

Parameters
[in,out]pselawill be set to null before returning
Returns
void

Definition at line 276 of file sel1.c.

References Sela::n, Sela::sel, and selDestroy().

Referenced by pixaThinConnected(), selaCreateFromFile(), and selaMakeThinSets().

◆ selaDisplayInPix()

PIX* selaDisplayInPix ( SELA sela,
l_int32  size,
l_int32  gthick,
l_int32  spacing,
l_int32  ncols 
)

selaDisplayInPix()

Parameters
[in]sela
[in]sizeof grid interiors; odd; minimum size of 13 is enforced
[in]gthickgrid thickness; minimum size of 2 is enforced
[in]spacingbetween sels, both horizontally and vertically
[in]ncolsnumber of sels per "line"
Returns
pix display of all sels in sela, or NULL on error
Notes:
     (1) This gives a visual representation of all the sels in a sela.
     (2) See notes in selDisplayInPix() for display params of each sel.
     (3) This gives the nicest results when all sels in the sela
         are the same size.

Definition at line 2373 of file sel1.c.

References L_CLONE, L_INSERT, pixaAddPix(), pixaCreate(), pixaDestroy(), pixaDisplayTiledInRows(), pixaGetPix(), pixDestroy(), pixGetDimensions(), selaGetCount(), selaGetSel(), and selDisplayInPix().

Referenced by selaMakeThinSets().

◆ selaExtendArray()

static l_int32 selaExtendArray ( SELA sela)
static

selaExtendArray()

Parameters
[in]sela
Returns
0 if OK; 1 on error

Definition at line 609 of file sel1.c.

References Sela::nalloc, reallocNew(), and Sela::sel.

Referenced by selaAddSel().

◆ selaFindSelByName()

l_ok selaFindSelByName ( SELA sela,
const char *  name,
l_int32 *  pindex,
SEL **  psel 
)

selaFindSelByName()

Parameters
[in]sela
[in]namesel name
[out]pindex[optional]
[in]psel[optional] sel (not a copy)
Returns
0 if OK; 1 on error

Definition at line 730 of file sel1.c.

References selaGetCount(), selaGetSel(), and selGetName().

Referenced by selaMakeThinSets().

◆ selaGetBrickName()

char* selaGetBrickName ( SELA sela,
l_int32  hsize,
l_int32  vsize 
)

selaGetBrickName()

Parameters
[in]sela
[in]hsize,vsizeof brick sel
Returns
sel name new string, or NULL if no name or on error

Definition at line 935 of file sel1.c.

References selaGetCount(), selaGetSel(), selGetName(), selGetParameters(), and stringNew().

◆ selaGetCombName()

char* selaGetCombName ( SELA sela,
l_int32  size,
l_int32  direction 
)

selaGetCombName()

Parameters
[in]sela
[in]sizethe product of sizes of the brick and comb parts
[in]directionL_HORIZ, L_VERT
Returns
sel name new string, or NULL if name not found or on error
Notes:
     (1) Combs are by definition 1-dimensional, either horiz or vert.
     (2) Use this with comb Sels; e.g., from selaAddDwaCombs().

Definition at line 974 of file sel1.c.

◆ selaGetCount()

l_int32 selaGetCount ( SELA sela)

selaGetCount()

Parameters
[in]sela
Returns
count, or 0 on error

Definition at line 637 of file sel1.c.

References Sela::n.

Referenced by fhmtautogen1(), fhmtautogen2(), fmorphautogen1(), selaAddSel(), selaDisplayInPix(), selaFindSelByName(), selaGetBrickName(), selaGetSelnames(), and selaWriteStream().

◆ selaGetSel()

SEL* selaGetSel ( SELA sela,
l_int32  i 
)

selaGetSel()

Parameters
[in]sela
[in]iindex of sel to be retrieved not copied
Returns
sel, or NULL on error
Notes:
     (1) This returns a ptr to the sel, not a copy, so the caller
         must not destroy it!

Definition at line 662 of file sel1.c.

References Sela::n, and Sela::sel.

Referenced by selaDisplayInPix(), selaFindSelByName(), selaGetBrickName(), and selaGetSelnames().

◆ selaGetSelnames()

SARRAY* selaGetSelnames ( SELA sela)

selaGetSelnames()

Parameters
[in]sela
Returns
sa of all sel names, or NULL on error

Definition at line 1145 of file sel1.c.

References L_COPY, sarrayAddString(), sarrayCreate(), selaGetCount(), selaGetSel(), and selGetName().

◆ selaRead()

SELA* selaRead ( const char *  fname)

selaRead()

Parameters
[in]fnamefilename
Returns
sela, or NULL on error

Definition at line 1307 of file sel1.c.

References fopenReadStream(), and selaReadStream().

◆ selaReadStream()

SELA* selaReadStream ( FILE *  fp)

selaReadStream()

Parameters
[in]fpfile stream
Returns
sela, or NULL on error

Definition at line 1336 of file sel1.c.

Referenced by selaRead().

◆ selaWrite()

l_ok selaWrite ( const char *  fname,
SELA sela 
)

selaWrite()

Parameters
[in]fnamefilename
[in]sela
Returns
0 if OK, 1 on error

Definition at line 1455 of file sel1.c.

References fopenWriteStream(), and selaWriteStream().

◆ selaWriteStream()

l_ok selaWriteStream ( FILE *  fp,
SELA sela 
)

selaWriteStream()

Parameters
[in]fpfile stream
[in]sela
Returns
0 if OK, 1 on error

Definition at line 1484 of file sel1.c.

References selaGetCount().

Referenced by selaWrite().

◆ selCopy()

SEL* selCopy ( SEL sel)

selCopy()

Parameters
[in]sel
Returns
a copy of the sel, or NULL on error

Definition at line 371 of file sel1.c.

References create2dIntArray(), Sel::cx, Sel::cy, Sel::data, Sel::name, selGetParameters(), stringNew(), Sel::sx, and Sel::sy.

Referenced by selaAddSel(), and selRotateOrth().

◆ selCreate()

SEL* selCreate ( l_int32  height,
l_int32  width,
const char *  name 
)

selCreate()

Parameters
[in]height
[in]width
[in]name[optional] sel name; can be null
Returns
sel, or NULL on error
Notes:
     (1) selCreate() initializes all values to 0.
     (2) After this call, (cy,cx) and nonzero data values must be
         assigned.  If a text name is not assigned here, it will
         be needed later when the sel is put into a sela.

Definition at line 310 of file sel1.c.

References create2dIntArray(), Sel::data, Sel::name, stringNew(), Sel::sx, and Sel::sy.

Referenced by selCreateFromPta(), selCreateFromSArray(), and selCreateFromString().

◆ selCreateBrick()

SEL* selCreateBrick ( l_int32  h,
l_int32  w,
l_int32  cy,
l_int32  cx,
l_int32  type 
)

selCreateBrick()

Parameters
[in]h,wheight, width
[in]cy,cxorigin, relative to UL corner at 0,0
[in]typeSEL_HIT, SEL_MISS, or SEL_DONT_CARE
Returns
sel, or NULL on error
Notes:
     (1) This is a rectangular sel of all hits, misses or don't cares.

Definition at line 418 of file sel1.c.

Referenced by selaAddDwaLinear(), selaAddHitMiss(), and selRotateOrth().

◆ selCreateComb()

SEL* selCreateComb ( l_int32  factor1,
l_int32  factor2,
l_int32  direction 
)

selCreateComb()

Parameters
[in]factor1contiguous space between comb tines
[in]factor2number of comb tines
[in]directionL_HORIZ, L_VERT
Returns
sel, or NULL on error
Notes:
     (1) This generates a comb Sel of hits with the origin as
         near the center as possible.
     (2) In use, this is complemented by a brick sel of size factor1,
         Both brick and comb sels are made by selectComposableSels().

Definition at line 462 of file sel1.c.

◆ selCreateFromColorPix()

SEL* selCreateFromColorPix ( PIX pixs,
const char *  selname 
)

selCreateFromColorPix()

Parameters
[in]pixscmapped or rgb
[in]selname[optional] sel name; can be null
Returns
sel if OK, NULL on error
Notes:
     (1) The sel size is given by the size of pixs.
     (2) In pixs, hits are represented by green pixels, misses by red
         pixels, and don't-cares by white pixels.
     (3) In pixs, there may be no misses, but there must be at least 1 hit.
     (4) At most there can be only one origin pixel, which is optionally
         specified by using a lower-intensity pixel:
           if a hit:  dark green
           if a miss: dark red
           if a don't care: gray
         If there is no such pixel, the origin defaults to the approximate
         center of the sel.

Definition at line 2117 of file sel1.c.

Referenced by selaAddCrossJunctions(), selaAddTJunctions(), selaCreateFromColorPixa(), and selReadFromColorImage().

◆ selCreateFromPix()

SEL* selCreateFromPix ( PIX pix,
l_int32  cy,
l_int32  cx,
const char *  name 
)

selCreateFromPix()

Parameters
[in]pix
[in]cy,cxorigin of sel
[in]name[optional] sel name; can be null
Returns
sel, or NULL on error
Notes:
     (1) The origin must be positive.
     (2) The pix must not exceed MaxPixTemplateSize in either dimension.
         and the total number of hits must not exceed MaxPixTemplateHits.

Definition at line 2008 of file sel1.c.

References pixGetDimensions().

Referenced by selMakePlusSign().

◆ selCreateFromPta()

SEL* selCreateFromPta ( PTA pta,
l_int32  cy,
l_int32  cx,
const char *  name 
)

selCreateFromPta()

Parameters
[in]pta
[in]cy,cxorigin of sel
[in]name[optional] sel name; can be null
Returns
sel of minimum required size, or NULL on error
Notes:
     (1) The origin and all points in the pta must be positive.

Definition at line 1956 of file sel1.c.

References boxDestroy(), boxGetGeometry(), ptaGetBoundingRegion(), ptaGetCount(), ptaGetIPt(), selCreate(), selSetElement(), and selSetOrigin().

◆ selCreateFromSArray()

static SEL * selCreateFromSArray ( SARRAY sa,
l_int32  first,
l_int32  last 
)
static

selCreateFromSArray()

Parameters
[in]sa
[in]firstline of sarray where Sel begins
[in]lastline of sarray where Sel ends
Returns
sela, or NULL on error
Notes:
     (1) The Sel contains the following lines:
         ~ The first line is the selname
         ~ The remaining lines contain the Sel data.  They must
           be formatted similarly to the string format in
           selCreateFromString(), with each line beginning and
           ending with a double-quote, and showing the 2D layout.
         ~ 'last' gives the last line in the Sel data.
     (2) See selCreateFromString() for a description of the string
         format for the Sel data.  As an example, here are the lines
         of is a valid file for a single Sel.  In the file, all lines
         are left-justified:
                   # diagonal sel
                   sel_5diag
                   "x    "
                   " x   "
                   "  X  "
                   "   x "
                   "    x"

Definition at line 1874 of file sel1.c.

References L_NOCOPY, sarrayGetCount(), sarrayGetString(), selCreate(), selSetElement(), and selSetOrigin().

Referenced by selaCreateFromFile().

◆ selCreateFromString()

SEL* selCreateFromString ( const char *  text,
l_int32  h,
l_int32  w,
const char *  name 
)

selCreateFromString()

Parameters
[in]text
[in]h,wheight, width
[in]name[optional] sel name; can be null
Returns
sel of the given size, or NULL on error
Notes:
     (1) The text is an array of chars (in row-major order) where
         each char can be one of the following:
            'x': hit
            'o': miss
            ' ': don't-care
     (2) When the origin falls on a hit or miss, use an upper case
         char (e.g., 'X' or 'O') to indicate it.  When the origin
         falls on a don't-care, indicate this with a 'C'.
         The string must have exactly one origin specified.
     (3) The advantage of this method is that the text can be input
         in a format that shows the 2D layout of the Sel; e.g.,
static const char *seltext = "x "
"x Oo "
"x "
"xxxxx";

Definition at line 1607 of file sel1.c.

References selCreate(), selSetElement(), and selSetOrigin().

Referenced by sela4and8ccThin(), sela4ccThin(), and sela8ccThin().

◆ selDestroy()

void selDestroy ( SEL **  psel)

selDestroy()

Parameters
[in,out]pselwill be set to null before returning
Returns
void

Definition at line 340 of file sel1.c.

References Sel::data, Sel::name, and Sel::sy.

Referenced by selaAddSel(), and selaDestroy().

◆ selDisplayInPix()

PIX* selDisplayInPix ( SEL sel,
l_int32  size,
l_int32  gthick 
)

selDisplayInPix()

Parameters
[in]sel
[in]sizeof grid interiors; odd; minimum size of 13 is enforced
[in]gthickgrid thickness; minimum size of 2 is enforced
Returns
pix display of sel, or NULL on error
Notes:
     (1) This gives a visual representation of a general (hit-miss) sel.
     (2) The empty sel is represented by a grid of intersecting lines.
     (3) Three different patterns are generated for the sel elements:
         ~ hit (solid black circle)
         ~ miss (black ring; inner radius is radius2)
         ~ origin (cross, XORed with whatever is there)

Definition at line 2255 of file sel1.c.

References generatePtaFilledCircle(), L_FLIP_PIXELS, L_SET_PIXELS, PIX_DST, PIX_NOT, pixCreate(), pixGenerateFromPta(), pixRasterop(), pixRenderLine(), pixSubtract(), ptaTransform(), selGetParameters(), and selGetTypeAtOrigin().

Referenced by selaDisplayInPix().

◆ selFindMaxTranslations()

l_ok selFindMaxTranslations ( SEL sel,
l_int32 *  pxp,
l_int32 *  pyp,
l_int32 *  pxn,
l_int32 *  pyn 
)

selFindMaxTranslations()

Parameters
[in]sel
[out]pxp,pyp,pxn,pynmax shifts
Returns
0 if OK; 1 on error
Notes:
       These are the maximum shifts for the erosion operation.
       For example, when j < cx, the shift of the image
       is +x to the cx.  This is a positive xp shift.

Definition at line 1190 of file sel1.c.

References Sel::data, and selGetParameters().

Referenced by pixHMT().

◆ selGetElement()

l_ok selGetElement ( SEL sel,
l_int32  row,
l_int32  col,
l_int32 *  ptype 
)

selGetElement()

Parameters
[in]sel
[in]row
[in]col
[out]ptypeSEL_HIT, SEL_MISS, SEL_DONT_CARE
Returns
0 if OK; 1 on error

Definition at line 779 of file sel1.c.

Referenced by selPrintToString().

◆ selGetName()

char* selGetName ( SEL sel)

selGetName()

Parameters
[in]sel
Returns
sel name not copied, or NULL if no name or on error

Definition at line 683 of file sel1.c.

References Sel::name.

Referenced by selaFindSelByName(), selaGetBrickName(), and selaGetSelnames().

◆ selGetParameters()

l_ok selGetParameters ( SEL sel,
l_int32 *  psy,
l_int32 *  psx,
l_int32 *  pcy,
l_int32 *  pcx 
)

selGetParameters()

Parameters
[in]sel
[out]psy,psx,pcy,pcx[optional] each can be null
Returns
0 if OK, 1 on error

Definition at line 848 of file sel1.c.

References Sel::cx, Sel::cy, Sel::sx, and Sel::sy.

Referenced by pixDilate(), pixErode(), pixHMT(), selaGetBrickName(), selCopy(), selDisplayInPix(), selFindMaxTranslations(), selPrintToString(), selRotateOrth(), and selWriteStream().

◆ selGetTypeAtOrigin()

l_ok selGetTypeAtOrigin ( SEL sel,
l_int32 *  ptype 
)

selGetTypeAtOrigin()

Parameters
[in]sel
[out]ptypeSEL_HIT, SEL_MISS, SEL_DONT_CARE
Returns
0 if OK; 1 on error or if origin is not found

Definition at line 900 of file sel1.c.

Referenced by selDisplayInPix().

◆ selPrintToString()

char* selPrintToString ( SEL sel)

selPrintToString()

Parameters
[in]sel
Returns
str string; caller must free
Notes:
     (1) This is an inverse function of selCreateFromString.
         It prints a textual representation of the SEL to a malloc'd
         string.  The format is the same as selCreateFromString
         except that newlines are inserted into the output
         between rows.
     (2) This is useful for debugging.  However, if you want to
         save some Sels in a file, put them in a Sela and write
         them out with selaWrite().  They can then be read in
         with selaRead().

Definition at line 1698 of file sel1.c.

References selGetElement(), and selGetParameters().

◆ selRead()

SEL* selRead ( const char *  fname)

selRead()

Parameters
[in]fnamefilename
Returns
sel, or NULL on error

Definition at line 1377 of file sel1.c.

References fopenReadStream(), and selReadStream().

◆ selReadFromColorImage()

SEL* selReadFromColorImage ( const char *  pathname)

selReadFromColorImage()

Parameters
[in]pathname
Returns
sel if OK; NULL on error
Notes:
     (1) Loads an image from a file and creates a (hit-miss) sel.
     (2) The sel name is taken from the pathname without the directory
         and extension.

Definition at line 2068 of file sel1.c.

References pixDestroy(), pixRead(), selCreateFromColorPix(), splitPathAtDirectory(), and splitPathAtExtension().

◆ selReadStream()

SEL* selReadStream ( FILE *  fp)

selReadStream()

Parameters
[in]fpfile stream
Returns
sel, or NULL on error

Definition at line 1406 of file sel1.c.

Referenced by selRead().

◆ selRotateOrth()

SEL* selRotateOrth ( SEL sel,
l_int32  quads 
)

selRotateOrth()

Parameters
[in]sel
[in]quads0 - 4; number of 90 degree cw rotations
Returns
seld, or NULL on error

Definition at line 1240 of file sel1.c.

References selCopy(), selCreateBrick(), and selGetParameters().

Referenced by selaMakeThinSets().

◆ selSetElement()

l_ok selSetElement ( SEL sel,
l_int32  row,
l_int32  col,
l_int32  type 
)

selSetElement()

Parameters
[in]sel
[in]row
[in]col
[in]typeSEL_HIT, SEL_MISS, SEL_DONT_CARE
Returns
0 if OK; 1 on error
Notes:
     (1) Because we use row and column to index into an array,
         they are always non-negative.  The location of the origin
         (and the type of operation) determine the actual
         direction of the rasterop.

Definition at line 819 of file sel1.c.

Referenced by selCreateFromPta(), selCreateFromSArray(), and selCreateFromString().

◆ selSetName()

l_ok selSetName ( SEL sel,
const char *  name 
)

selSetName()

Parameters
[in]sel
[in]name[optional]; can be null
Returns
0 if OK, 1 on error
Notes:
     (1) Always frees the existing sel name, if defined.
     (2) If name is not defined, just clears any existing sel name.

Definition at line 708 of file sel1.c.

References Sel::name, and stringReplace().

◆ selSetOrigin()

l_ok selSetOrigin ( SEL sel,
l_int32  cy,
l_int32  cx 
)

selSetOrigin()

Parameters
[in]sel
[in]cy,cx
Returns
0 if OK; 1 on error

Definition at line 878 of file sel1.c.

References Sel::cx, and Sel::cy.

Referenced by selCreateFromPta(), selCreateFromSArray(), and selCreateFromString().

◆ selWrite()

l_ok selWrite ( const char *  fname,
SEL sel 
)

selWrite()

Parameters
[in]fnamefilename
[in]sel
Returns
0 if OK, 1 on error

Definition at line 1517 of file sel1.c.

References fopenWriteStream(), and selWriteStream().

◆ selWriteStream()

l_ok selWriteStream ( FILE *  fp,
SEL sel 
)

selWriteStream()

Parameters
[in]fpfile stream
[in]sel
Returns
0 if OK, 1 on error

Definition at line 1546 of file sel1.c.

References selGetParameters().

Referenced by selWrite().

Variable Documentation

◆ InitialPtrArraySize

const l_int32 InitialPtrArraySize = 50
static

n'importe quoi

Definition at line 151 of file sel1.c.