Leptonica  1.82.0
Image processing and image analysis suite
pixacc.c File Reference
#include "allheaders.h"

Go to the source code of this file.

Functions

PIXACCpixaccCreate (l_int32 w, l_int32 h, l_int32 negflag)
 
PIXACCpixaccCreateFromPix (PIX *pix, l_int32 negflag)
 
void pixaccDestroy (PIXACC **ppixacc)
 
PIXpixaccFinal (PIXACC *pixacc, l_int32 outdepth)
 
PIXpixaccGetPix (PIXACC *pixacc)
 
l_int32 pixaccGetOffset (PIXACC *pixacc)
 
l_ok pixaccAdd (PIXACC *pixacc, PIX *pix)
 
l_ok pixaccSubtract (PIXACC *pixacc, PIX *pix)
 
l_ok pixaccMultConst (PIXACC *pixacc, l_float32 factor)
 
l_ok pixaccMultConstAccumulate (PIXACC *pixacc, PIX *pix, l_float32 factor)
 

Detailed Description

     Pixacc creation, destruction
          PIXACC   *pixaccCreate()
          PIXACC   *pixaccCreateFromPix()
          void      pixaccDestroy()
     Pixacc finalization
          PIX      *pixaccFinal()
     Pixacc accessors
          PIX      *pixaccGetPix()
          l_int32   pixaccGetOffset()
     Pixacc accumulators
          l_int32   pixaccAdd()
          l_int32   pixaccSubtract()
          l_int32   pixaccMultConst()
          l_int32   pixaccMultConstAccumulate()
 This is a simple interface for some of the pixel arithmetic operations
 in pixarith.c.  These are easy to code up, but not as fast as
 hand-coded functions that do arithmetic on corresponding pixels.
 Suppose you want to make a linear combination of pix1 and pix2:
    pixd = 0.4 * pix1 + 0.6 * pix2
 where pix1 and pix2 are the same size and have depth 'd'.  Then:
    Pixacc *pacc = pixaccCreateFromPix(pix1, 0);  // first; addition only
    pixaccMultConst(pacc, 0.4);
    pixaccMultConstAccumulate(pacc, pix2, 0.6);  // Add in 0.6 of the second
    pixd = pixaccFinal(pacc, d);  // Get the result
    pixaccDestroy(&pacc);

Definition in file pixacc.c.

Function Documentation

◆ pixaccAdd()

l_ok pixaccAdd ( PIXACC pixacc,
PIX pix 
)

pixaccAdd()

Parameters
[in]pixacc
[in]pixto be added
Returns
0 if OK, 1 on error

Definition at line 254 of file pixacc.c.

References pixaccGetPix(), and pixAccumulate().

Referenced by pixaccCreateFromPix(), and pixaccMultConstAccumulate().

◆ pixaccCreate()

PIXACC* pixaccCreate ( l_int32  w,
l_int32  h,
l_int32  negflag 
)

pixaccCreate()

Parameters
[in]w,hof 32 bpp internal Pix
[in]negflag0 if only positive numbers are involved; 1 if there will be negative numbers
Returns
pixacc, or NULL on error
Notes:
     (1) Use negflag = 1 for safety if any negative numbers are going
         to be used in the chain of operations.  Negative numbers
         arise, e.g., by subtracting a pix, or by adding a pix
         that has been pre-multiplied by a negative number.
     (2) Initializes the internal 32 bpp pix, similarly to the
         initialization in pixInitAccumulate().

Definition at line 92 of file pixacc.c.

References Pixacc::h, Pixacc::offset, Pixacc::pix, pixaccDestroy(), pixCreate(), pixSetAllArbitrary(), and Pixacc::w.

Referenced by pixaccCreateFromPix(), and pixaccMultConstAccumulate().

◆ pixaccCreateFromPix()

PIXACC* pixaccCreateFromPix ( PIX pix,
l_int32  negflag 
)

pixaccCreateFromPix()

Parameters
[in]pix
[in]negflag0 if only positive numbers are involved; 1 if there will be negative numbers
Returns
pixacc, or NULL on error
Notes:
     (1) See pixaccCreate()

Definition at line 132 of file pixacc.c.

References pixaccAdd(), pixaccCreate(), and pixGetDimensions().

◆ pixaccDestroy()

void pixaccDestroy ( PIXACC **  ppixacc)

pixaccDestroy()

Parameters
[in,out]ppixaccwill be set to null before returning
Returns
void
Notes:
     (1) Always nulls the input ptr.

Definition at line 162 of file pixacc.c.

References Pixacc::pix, and pixDestroy().

Referenced by pixaccCreate(), and pixaccMultConstAccumulate().

◆ pixaccFinal()

PIX* pixaccFinal ( PIXACC pixacc,
l_int32  outdepth 
)

pixaccFinal()

Parameters
[in]pixacc
[in]outdepth8, 16 or 32 bpp
Returns
pixd 8, 16 or 32 bpp, or NULL on error

Definition at line 193 of file pixacc.c.

References pixaccGetOffset(), pixaccGetPix(), and pixFinalAccumulate().

Referenced by pixaccMultConstAccumulate().

◆ pixaccGetOffset()

l_int32 pixaccGetOffset ( PIXACC pixacc)

pixaccGetOffset()

Parameters
[in]pixacc
Returns
offset, or -1 on error

Definition at line 233 of file pixacc.c.

References Pixacc::offset.

Referenced by pixaccFinal(), and pixaccMultConst().

◆ pixaccGetPix()

PIX* pixaccGetPix ( PIXACC pixacc)

pixaccGetPix()

Parameters
[in]pixacc
Returns
pix, or NULL on error

Definition at line 216 of file pixacc.c.

References Pixacc::pix.

Referenced by pixaccAdd(), pixaccFinal(), pixaccMultConst(), and pixaccSubtract().

◆ pixaccMultConst()

l_ok pixaccMultConst ( PIXACC pixacc,
l_float32  factor 
)

pixaccMultConst()

Parameters
[in]pixacc
[in]factor
Returns
0 if OK, 1 on error

Definition at line 298 of file pixacc.c.

References pixaccGetOffset(), pixaccGetPix(), and pixMultConstAccumulate().

Referenced by pixaccMultConstAccumulate().

◆ pixaccMultConstAccumulate()

l_ok pixaccMultConstAccumulate ( PIXACC pixacc,
PIX pix,
l_float32  factor 
)

pixaccMultConstAccumulate()

Parameters
[in]pixacc
[in]pix
[in]factor
Returns
0 if OK, 1 on error
Notes:
     (1) This creates a temp pix that is pix multiplied by the
         constant factor.  It then adds that into pixacc.

Definition at line 326 of file pixacc.c.

References pixaccAdd(), pixaccCreate(), pixaccDestroy(), pixaccFinal(), pixaccMultConst(), pixDestroy(), and pixGetDimensions().

◆ pixaccSubtract()

l_ok pixaccSubtract ( PIXACC pixacc,
PIX pix 
)

pixaccSubtract()

Parameters
[in]pixacc
[in]pixto be subtracted
Returns
0 if OK, 1 on error

Definition at line 276 of file pixacc.c.

References pixaccGetPix(), and pixAccumulate().