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

Go to the source code of this file.

Functions

FPIXpixConvertToFPix (PIX *pixs, l_int32 ncomps)
 
DPIXpixConvertToDPix (PIX *pixs, l_int32 ncomps)
 
PIXfpixConvertToPix (FPIX *fpixs, l_int32 outdepth, l_int32 negvals, l_int32 errorflag)
 
PIXfpixDisplayMaxDynamicRange (FPIX *fpixs)
 
DPIXfpixConvertToDPix (FPIX *fpix)
 
PIXdpixConvertToPix (DPIX *dpixs, l_int32 outdepth, l_int32 negvals, l_int32 errorflag)
 
FPIXdpixConvertToFPix (DPIX *dpix)
 
l_ok fpixGetMin (FPIX *fpix, l_float32 *pminval, l_int32 *pxminloc, l_int32 *pyminloc)
 
l_ok fpixGetMax (FPIX *fpix, l_float32 *pmaxval, l_int32 *pxmaxloc, l_int32 *pymaxloc)
 
l_ok dpixGetMin (DPIX *dpix, l_float64 *pminval, l_int32 *pxminloc, l_int32 *pyminloc)
 
l_ok dpixGetMax (DPIX *dpix, l_float64 *pmaxval, l_int32 *pxmaxloc, l_int32 *pymaxloc)
 
FPIXfpixScaleByInteger (FPIX *fpixs, l_int32 factor)
 
DPIXdpixScaleByInteger (DPIX *dpixs, l_int32 factor)
 
FPIXfpixLinearCombination (FPIX *fpixd, FPIX *fpixs1, FPIX *fpixs2, l_float32 a, l_float32 b)
 
l_ok fpixAddMultConstant (FPIX *fpix, l_float32 addc, l_float32 multc)
 
DPIXdpixLinearCombination (DPIX *dpixd, DPIX *dpixs1, DPIX *dpixs2, l_float32 a, l_float32 b)
 
l_ok dpixAddMultConstant (DPIX *dpix, l_float64 addc, l_float64 multc)
 
l_ok fpixSetAllArbitrary (FPIX *fpix, l_float32 inval)
 
l_ok dpixSetAllArbitrary (DPIX *dpix, l_float64 inval)
 
FPIXfpixAddBorder (FPIX *fpixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot)
 
FPIXfpixRemoveBorder (FPIX *fpixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot)
 
FPIXfpixAddMirroredBorder (FPIX *fpixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot)
 
FPIXfpixAddContinuedBorder (FPIX *fpixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot)
 
FPIXfpixAddSlopeBorder (FPIX *fpixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot)
 
l_ok fpixRasterop (FPIX *fpixd, l_int32 dx, l_int32 dy, l_int32 dw, l_int32 dh, FPIX *fpixs, l_int32 sx, l_int32 sy)
 
FPIXfpixRotateOrth (FPIX *fpixs, l_int32 quads)
 
FPIXfpixRotate180 (FPIX *fpixd, FPIX *fpixs)
 
FPIXfpixRotate90 (FPIX *fpixs, l_int32 direction)
 
FPIXfpixFlipLR (FPIX *fpixd, FPIX *fpixs)
 
FPIXfpixFlipTB (FPIX *fpixd, FPIX *fpixs)
 
FPIXfpixAffinePta (FPIX *fpixs, PTA *ptad, PTA *ptas, l_int32 border, l_float32 inval)
 
FPIXfpixAffine (FPIX *fpixs, l_float32 *vc, l_float32 inval)
 
FPIXfpixProjectivePta (FPIX *fpixs, PTA *ptad, PTA *ptas, l_int32 border, l_float32 inval)
 
FPIXfpixProjective (FPIX *fpixs, l_float32 *vc, l_float32 inval)
 
l_ok linearInterpolatePixelFloat (l_float32 *datas, l_int32 w, l_int32 h, l_float32 x, l_float32 y, l_float32 inval, l_float32 *pval)
 
PIXfpixThresholdToPix (FPIX *fpix, l_float32 thresh)
 
FPIXpixComponentFunction (PIX *pix, l_float32 rnum, l_float32 gnum, l_float32 bnum, l_float32 rdenom, l_float32 gdenom, l_float32 bdenom)
 

Detailed Description


   ------------------------------------------
   This file has these FPix utilities:
      ~ interconversions with pix, fpix, dpix
      ~ min and max values
      ~ integer scaling
      ~ arithmetic operations
      ~ set all
      ~ border functions
      ~ simple rasterop (source --> dest)
      ~ geometric transforms
   ------------------------------------------

   Interconversions between Pix, FPix and DPix
         FPIX          *pixConvertToFPix()
         DPIX          *pixConvertToDPix()
         PIX           *fpixConvertToPix()
         PIX           *fpixDisplayMaxDynamicRange()  [useful for debugging]
         DPIX          *fpixConvertToDPix()
         PIX           *dpixConvertToPix()
         FPIX          *dpixConvertToFPix()

   Min/max value
         l_int32        fpixGetMin()
         l_int32        fpixGetMax()
         l_int32        dpixGetMin()
         l_int32        dpixGetMax()

   Integer scaling
         FPIX          *fpixScaleByInteger()
         DPIX          *dpixScaleByInteger()

   Arithmetic operations
         FPIX          *fpixLinearCombination()
         l_int32        fpixAddMultConstant()
         DPIX          *dpixLinearCombination()
         l_int32        dpixAddMultConstant()

   Set all
         l_int32        fpixSetAllArbitrary()
         l_int32        dpixSetAllArbitrary()

   FPix border functions
         FPIX          *fpixAddBorder()
         FPIX          *fpixRemoveBorder()
         FPIX          *fpixAddMirroredBorder()
         FPIX          *fpixAddContinuedBorder()
         FPIX          *fpixAddSlopeBorder()

   FPix simple rasterop
         l_int32        fpixRasterop()

   FPix rotation by multiples of 90 degrees
         FPIX          *fpixRotateOrth()
         FPIX          *fpixRotate180()
         FPIX          *fpixRotate90()
         FPIX          *fpixFlipLR()
         FPIX          *fpixFlipTB()

   FPix affine and projective interpolated transforms
         FPIX          *fpixAffinePta()
         FPIX          *fpixAffine()
         FPIX          *fpixProjectivePta()
         FPIX          *fpixProjective()
         l_int32        linearInterpolatePixelFloat()

   Thresholding to 1 bpp Pix
         PIX           *fpixThresholdToPix()

   Generate function from components
         FPIX          *pixComponentFunction()

Definition in file fpix2.c.

Function Documentation

◆ dpixAddMultConstant()

l_ok dpixAddMultConstant ( DPIX dpix,
l_float64  addc,
l_float64  multc 
)

dpixAddMultConstant()

Parameters
[in]dpix
[in]addcuse 0.0 to skip the operation
[in]multcuse 1.0 to skip the operation
Returns
0 if OK, 1 on error
Notes:
     (1) This is an in-place operation.
     (2) It can be used to multiply each pixel by a constant,
         and also to add a constant to each pixel.  Multiplication
         is done first.

Definition at line 1246 of file fpix2.c.

References dpixGetData(), dpixGetDimensions(), and dpixGetWpl().

◆ dpixConvertToFPix()

FPIX* dpixConvertToFPix ( DPIX dpix)

dpixConvertToFPix()

Parameters
[in]dpix
Returns
fpix, or NULL on error

Definition at line 635 of file fpix2.c.

References dpixGetData(), dpixGetDimensions(), dpixGetWpl(), fpixCreate(), fpixGetData(), and fpixGetWpl().

◆ dpixConvertToPix()

PIX* dpixConvertToPix ( DPIX dpixs,
l_int32  outdepth,
l_int32  negvals,
l_int32  errorflag 
)

dpixConvertToPix()

Parameters
[in]dpixs
[in]outdepth0, 8, 16 or 32 bpp
[in]negvalsL_CLIP_TO_ZERO, L_TAKE_ABSVAL
[in]errorflag1 to output error stats; 0 otherwise
Returns
pixd, or NULL on error
Notes:
     (1) Use outdepth = 0 to programmatically determine the
         output depth.  If no values are greater than 255,
         it will set outdepth = 8; otherwise to 16 or 32.
     (2) Because we are converting a float to an unsigned int
         with a specified dynamic range (8, 16 or 32 bits), errors
         can occur.  If errorflag == TRUE, output the number
         of values out of range, both negative and positive.
     (3) If a pixel value is positive and out of range, clip to
         the maximum value represented at the outdepth of 8, 16
         or 32 bits.

Definition at line 533 of file fpix2.c.

References dpixGetData(), dpixGetDimensions(), dpixGetWpl(), L_CLIP_TO_ZERO, L_TAKE_ABSVAL, pixCreate(), and pixGetData().

◆ dpixGetMax()

l_ok dpixGetMax ( DPIX dpix,
l_float64 *  pmaxval,
l_int32 *  pxmaxloc,
l_int32 *  pymaxloc 
)

dpixGetMax()

Parameters
[in]dpix
[out]pmaxval[optional] max value
[out]pxmaxloc[optional] x location of max
[out]pymaxloc[optional] y location of max
Returns
0 if OK; 1 on error

Definition at line 834 of file fpix2.c.

References dpixGetData(), dpixGetDimensions(), and dpixGetWpl().

◆ dpixGetMin()

l_ok dpixGetMin ( DPIX dpix,
l_float64 *  pminval,
l_int32 *  pxminloc,
l_int32 *  pyminloc 
)

dpixGetMin()

Parameters
[in]dpix
[out]pminval[optional] min value
[out]pxminloc[optional] x location of min
[out]pyminloc[optional] y location of min
Returns
0 if OK; 1 on error

Definition at line 783 of file fpix2.c.

References dpixGetData(), dpixGetDimensions(), and dpixGetWpl().

◆ dpixLinearCombination()

DPIX* dpixLinearCombination ( DPIX dpixd,
DPIX dpixs1,
DPIX dpixs2,
l_float32  a,
l_float32  b 
)

dpixLinearCombination()

Parameters
[in]dpixd[optional] this can be null, or equal to dpixs1
[in]dpixs1can be equal to dpixd
[in]dpixs2
[in]a,bmultiplication factors on dpixs1 and dpixs2, rsp.
Returns
dpixd always
Notes:
     (1) Computes pixelwise linear combination: a * src1 + b * src2
     (2) Alignment is to UL corner; src1 and src2 do not have to be
         the same size.
     (3) There are 2 cases.  The result can go to a new dest, or
         in-place to dpixs1:
         * dpixd == null:   (src1 + src2) --> new dpixd
         * dpixd == dpixs1:  (src1 + src2) --> src1  (in-place)

Definition at line 1192 of file fpix2.c.

References dpixCopy(), dpixGetData(), dpixGetDimensions(), and dpixGetWpl().

◆ dpixScaleByInteger()

DPIX* dpixScaleByInteger ( DPIX dpixs,
l_int32  factor 
)

dpixScaleByInteger()

Parameters
[in]dpixstypically low resolution
[in]factorinteger scaling factor
Returns
dpixd interpolated result, or NULL on error
Notes:
     (1) The width wd of dpixd is related to ws of dpixs by:
             wd = factor * (ws - 1) + 1   (and ditto for the height)
         We avoid special-casing boundary pixels in the interpolation
         by constructing fpixd by inserting (factor - 1) interpolated
         pixels between each pixel in fpixs.  Then
              wd = ws + (ws - 1) * (factor - 1)    (same as above)
         This also has the advantage that if we subsample by factor,
         throwing out all the interpolated pixels, we regain the
         original low resolution dpix.

Definition at line 989 of file fpix2.c.

References dpixCreate(), dpixGetData(), dpixGetDimensions(), and dpixGetWpl().

◆ dpixSetAllArbitrary()

l_ok dpixSetAllArbitrary ( DPIX dpix,
l_float64  inval 
)

dpixSetAllArbitrary()

Parameters
[in]dpix
[in]invalto set at each pixel
Returns
0 if OK, 1 on error

Definition at line 1320 of file fpix2.c.

References dpixGetData(), and dpixGetDimensions().

◆ fpixAddBorder()

FPIX* fpixAddBorder ( FPIX fpixs,
l_int32  left,
l_int32  right,
l_int32  top,
l_int32  bot 
)

fpixAddBorder()

Parameters
[in]fpixs
[in]left,right,top,botpixels on each side to be added
Returns
fpixd, or NULL on error
Notes:
     (1) Adds border of '0' 32-bit pixels

Definition at line 1357 of file fpix2.c.

References fpixCopy(), fpixCopyResolution(), fpixCreate(), fpixGetDimensions(), and fpixRasterop().

Referenced by fpixAddContinuedBorder(), fpixAddMirroredBorder(), and fpixAddSlopeBorder().

◆ fpixAddContinuedBorder()

FPIX* fpixAddContinuedBorder ( FPIX fpixs,
l_int32  left,
l_int32  right,
l_int32  top,
l_int32  bot 
)

fpixAddContinuedBorder()

Parameters
[in]fpixs
[in]left,right,top,botpixels on each side to be added
Returns
fpixd, or NULL on error
Notes:
     (1) This adds pixels on each side whose values are equal to
         the value on the closest boundary pixel.

Definition at line 1478 of file fpix2.c.

References fpixAddBorder(), fpixGetDimensions(), and fpixRasterop().

◆ fpixAddMirroredBorder()

FPIX* fpixAddMirroredBorder ( FPIX fpixs,
l_int32  left,
l_int32  right,
l_int32  top,
l_int32  bot 
)

fpixAddMirroredBorder()

Parameters
[in]fpixs
[in]left,right,top,botpixels on each side to be added
Returns
fpixd, or NULL on error
Notes:
     (1) See pixAddMirroredBorder() for situations of usage.

Definition at line 1433 of file fpix2.c.

References fpixAddBorder(), fpixGetDimensions(), and fpixRasterop().

Referenced by fpixConvolve().

◆ fpixAddMultConstant()

l_ok fpixAddMultConstant ( FPIX fpix,
l_float32  addc,
l_float32  multc 
)

fpixAddMultConstant()

Parameters
[in]fpix
[in]addcuse 0.0 to skip the operation
[in]multcuse 1.0 to skip the operation
Returns
0 if OK, 1 on error
Notes:
     (1) This is an in-place operation.
     (2) It can be used to multiply each pixel by a constant,
         and also to add a constant to each pixel.  Multiplication
         is done first.

Definition at line 1136 of file fpix2.c.

References fpixGetData(), fpixGetDimensions(), and fpixGetWpl().

Referenced by dewarpPopulateFullRes().

◆ fpixAddSlopeBorder()

FPIX* fpixAddSlopeBorder ( FPIX fpixs,
l_int32  left,
l_int32  right,
l_int32  top,
l_int32  bot 
)

fpixAddSlopeBorder()

Parameters
[in]fpixs
[in]left,right,top,botpixels on each side to be added
Returns
fpixd, or NULL on error
Notes:
     (1) This adds pixels on each side whose values have a normal
         derivative equal to the normal derivative at the boundary
         of fpixs.

Definition at line 1521 of file fpix2.c.

References fpixAddBorder(), fpixGetDimensions(), fpixGetPixel(), and fpixSetPixel().

Referenced by dewarpPopulateFullRes(), fpixAffinePta(), and fpixProjectivePta().

◆ fpixAffine()

FPIX* fpixAffine ( FPIX fpixs,
l_float32 *  vc,
l_float32  inval 
)

fpixAffine()

Parameters
[in]fpixs8 bpp
[in]vcvector of 8 coefficients for projective transformation
[in]invalvalue brought in; typ. 0
Returns
fpixd, or NULL on error

Definition at line 2006 of file fpix2.c.

References affineXformPt(), fpixCreateTemplate(), fpixGetData(), fpixGetDimensions(), fpixGetWpl(), fpixSetAllArbitrary(), and linearInterpolatePixelFloat().

Referenced by fpixAffinePta().

◆ fpixAffinePta()

FPIX* fpixAffinePta ( FPIX fpixs,
PTA ptad,
PTA ptas,
l_int32  border,
l_float32  inval 
)

fpixAffinePta()

Parameters
[in]fpixs8 bpp
[in]ptad4 pts of final coordinate space
[in]ptas4 pts of initial coordinate space
[in]bordersize of extension with constant normal derivative
[in]invalvalue brought in; typ. 0
Returns
fpixd, or NULL on error
Notes:
     (1) If border > 0, all four sides are extended by that distance,
         and removed after the transformation is finished.  Pixels
         that would be brought in to the trimmed result from outside
         the extended region are assigned inval.  The purpose of
         extending the image is to avoid such assignments.
     (2) On the other hand, you may want to give all pixels that
         are brought in from outside fpixs a specific value.  In that
         case, set border == 0.

Definition at line 1951 of file fpix2.c.

References fpixAddSlopeBorder(), fpixAffine(), fpixClone(), fpixDestroy(), fpixRemoveBorder(), getAffineXformCoeffs(), ptaClone(), ptaDestroy(), and ptaTransform().

◆ fpixConvertToDPix()

DPIX* fpixConvertToDPix ( FPIX fpix)

fpixConvertToDPix()

Parameters
[in]fpix
Returns
dpix, or NULL on error

Definition at line 477 of file fpix2.c.

References dpixCreate(), dpixGetData(), dpixGetWpl(), fpixGetData(), fpixGetDimensions(), and fpixGetWpl().

◆ fpixConvertToPix()

PIX* fpixConvertToPix ( FPIX fpixs,
l_int32  outdepth,
l_int32  negvals,
l_int32  errorflag 
)

fpixConvertToPix()

Parameters
[in]fpixs
[in]outdepth0, 8, 16 or 32 bpp
[in]negvalsL_CLIP_TO_ZERO, L_TAKE_ABSVAL
[in]errorflag1 to output error stats; 0 otherwise
Returns
pixd, or NULL on error
Notes:
     (1) Use outdepth = 0 to programmatically determine the
         output depth.  If no values are greater than 255,
         it will set outdepth = 8; otherwise to 16 or 32.
     (2) Because we are converting a float to an unsigned int
         with a specified dynamic range (8, 16 or 32 bits), errors
         can occur.  If errorflag == TRUE, output the number
         of values out of range, both negative and positive.
     (3) If a pixel value is positive and out of range, clip to
         the maximum value represented at the outdepth of 8, 16
         or 32 bits.

Definition at line 320 of file fpix2.c.

References fpixGetData(), fpixGetDimensions(), fpixGetWpl(), L_CLIP_TO_ZERO, L_TAKE_ABSVAL, pixCreate(), and pixGetData().

Referenced by fpixaDisplayQuadtree().

◆ fpixDisplayMaxDynamicRange()

PIX* fpixDisplayMaxDynamicRange ( FPIX fpixs)

fpixDisplayMaxDynamicRange()

Parameters
[in]fpixs
Returns
pixd 8 bpp, or NULL on error

Definition at line 422 of file fpix2.c.

References fpixGetData(), fpixGetDimensions(), fpixGetWpl(), pixCreate(), and pixGetData().

◆ fpixFlipLR()

FPIX* fpixFlipLR ( FPIX fpixd,
FPIX fpixs 
)

pixFlipLR()

Parameters
[in]fpixd[optional] can be null, or equal to fpixs
[in]fpixs
Returns
fpixd, or NULL on error
Notes:
     (1) This does a left-right flip of the image, which is
         equivalent to a rotation out of the plane about a
         vertical line through the image center.
     (2) There are 2 cases for input:
         (a) fpixd == null (creates a new fpixd)
         (b) fpixd == fpixs (in-place operation)
     (3) For clarity, use these two patterns:
         (a) fpixd = fpixFlipLR(NULL, fpixs);
         (b) fpixFlipLR(fpixs, fpixs);

Definition at line 1844 of file fpix2.c.

References fpixCopy(), fpixGetData(), fpixGetDimensions(), and fpixGetWpl().

Referenced by fpixRotate180().

◆ fpixFlipTB()

FPIX* fpixFlipTB ( FPIX fpixd,
FPIX fpixs 
)

fpixFlipTB()

Parameters
[in]fpixd[optional] can be null, or equal to fpixs
[in]fpixs
Returns
fpixd, or NULL on error
Notes:
     (1) This does a top-bottom flip of the image, which is
         equivalent to a rotation out of the plane about a
         horizontal line through the image center.
     (2) There are 2 cases for input:
         (a) fpixd == null (creates a new fpixd)
         (b) fpixd == fpixs (in-place operation)
     (3) For clarity, use these two patterns:
         (a) fpixd = fpixFlipTB(NULL, fpixs);
         (b) fpixFlipTB(fpixs, fpixs);

Definition at line 1894 of file fpix2.c.

References fpixCopy(), fpixGetData(), fpixGetDimensions(), and fpixGetWpl().

Referenced by fpixRotate180().

◆ fpixGetMax()

l_ok fpixGetMax ( FPIX fpix,
l_float32 *  pmaxval,
l_int32 *  pxmaxloc,
l_int32 *  pymaxloc 
)

fpixGetMax()

Parameters
[in]fpix
[out]pmaxval[optional] max value
[out]pxmaxloc[optional] x location of max
[out]pymaxloc[optional] y location of max
Returns
0 if OK; 1 on error

Definition at line 732 of file fpix2.c.

References fpixGetData(), fpixGetDimensions(), and fpixGetWpl().

Referenced by fpixAutoRenderContours().

◆ fpixGetMin()

l_ok fpixGetMin ( FPIX fpix,
l_float32 *  pminval,
l_int32 *  pxminloc,
l_int32 *  pyminloc 
)

fpixGetMin()

Parameters
[in]fpix
[out]pminval[optional] min value
[out]pxminloc[optional] x location of min
[out]pyminloc[optional] y location of min
Returns
0 if OK; 1 on error

Definition at line 681 of file fpix2.c.

References fpixGetData(), fpixGetDimensions(), and fpixGetWpl().

Referenced by fpixAutoRenderContours().

◆ fpixLinearCombination()

FPIX* fpixLinearCombination ( FPIX fpixd,
FPIX fpixs1,
FPIX fpixs2,
l_float32  a,
l_float32  b 
)

fpixLinearCombination()

Parameters
[in]fpixd[optional] this can be null, or equal to fpixs1
[in]fpixs1can be equal to fpixd
[in]fpixs2
[in]a,bmultiplication factors on fpixs1 and fpixs2, rsp.
Returns
fpixd always
Notes:
     (1) Computes pixelwise linear combination: a * src1 + b * src2
     (2) Alignment is to UL corner; src1 and src2 do not have to be
         the same size.
     (3) There are 2 cases.  The result can go to a new dest, or
         in-place to fpixs1:
         * fpixd == null:   (src1 + src2) --> new fpixd
         * fpixd == fpixs1:  (src1 + src2) --> src1  (in-place)

Definition at line 1082 of file fpix2.c.

References fpixCopy(), fpixGetData(), fpixGetDimensions(), and fpixGetWpl().

◆ fpixProjective()

FPIX* fpixProjective ( FPIX fpixs,
l_float32 *  vc,
l_float32  inval 
)

fpixProjective()

Parameters
[in]fpixs8 bpp
[in]vcvector of 8 coefficients for projective transform
[in]invalvalue brought in; typ. 0
Returns
fpixd, or NULL on error

Definition at line 2121 of file fpix2.c.

References fpixCreateTemplate(), fpixGetData(), fpixGetDimensions(), fpixGetWpl(), fpixSetAllArbitrary(), linearInterpolatePixelFloat(), and projectiveXformPt().

Referenced by fpixProjectivePta().

◆ fpixProjectivePta()

FPIX* fpixProjectivePta ( FPIX fpixs,
PTA ptad,
PTA ptas,
l_int32  border,
l_float32  inval 
)

fpixProjectivePta()

Parameters
[in]fpixs8 bpp
[in]ptad4 pts of final coordinate space
[in]ptas4 pts of initial coordinate space
[in]bordersize of extension with constant normal derivative
[in]invalvalue brought in; typ. 0
Returns
fpixd, or NULL on error
Notes:
     (1) If border > 0, all four sides are extended by that distance,
         and removed after the transformation is finished.  Pixels
         that would be brought in to the trimmed result from outside
         the extended region are assigned inval.  The purpose of
         extending the image is to avoid such assignments.
     (2) On the other hand, you may want to give all pixels that
         are brought in from outside fpixs a specific value.  In that
         case, set border == 0.

Definition at line 2066 of file fpix2.c.

References fpixAddSlopeBorder(), fpixClone(), fpixDestroy(), fpixProjective(), fpixRemoveBorder(), getProjectiveXformCoeffs(), ptaClone(), ptaDestroy(), and ptaTransform().

◆ fpixRasterop()

l_ok fpixRasterop ( FPIX fpixd,
l_int32  dx,
l_int32  dy,
l_int32  dw,
l_int32  dh,
FPIX fpixs,
l_int32  sx,
l_int32  sy 
)

fpixRasterop()

Parameters
[in]fpixddest fpix
[in]dxx val of UL corner of dest rectangle
[in]dyy val of UL corner of dest rectangle
[in]dwwidth of dest rectangle
[in]dhheight of dest rectangle
[in]fpixssrc fpix
[in]sxx val of UL corner of src rectangle
[in]syy val of UL corner of src rectangle
Returns
0 if OK; 1 on error.
Notes:
     (1) This is similar in structure to pixRasterop(), except
         it only allows copying from the source into the destination.
         For that reason, no op code is necessary.  Additionally,
         all pixels are 32 bit words (float values), which makes
         the copy very simple.
     (2) Clipping of both src and dest fpix are done automatically.
     (3) This allows in-place copying, without checking to see if
         the result is valid:  use for in-place with caution!

Definition at line 1608 of file fpix2.c.

References fpixGetData(), fpixGetDimensions(), and fpixGetWpl().

Referenced by fpixAddBorder(), fpixAddContinuedBorder(), fpixAddMirroredBorder(), and fpixRemoveBorder().

◆ fpixRemoveBorder()

FPIX* fpixRemoveBorder ( FPIX fpixs,
l_int32  left,
l_int32  right,
l_int32  top,
l_int32  bot 
)

fpixRemoveBorder()

Parameters
[in]fpixs
[in]left,right,top,botpixels on each side to be removed
Returns
fpixd, or NULL on error

Definition at line 1391 of file fpix2.c.

References fpixCopy(), fpixCopyResolution(), fpixCreate(), fpixGetDimensions(), and fpixRasterop().

Referenced by fpixAffinePta(), and fpixProjectivePta().

◆ fpixRotate180()

FPIX* fpixRotate180 ( FPIX fpixd,
FPIX fpixs 
)

fpixRotate180()

Parameters
[in]fpixd[optional] can be null, or equal to fpixs
[in]fpixs
Returns
fpixd, or NULL on error
Notes:
     (1) This does a 180 rotation of the image about the center,
         which is equivalent to a left-right flip about a vertical
         line through the image center, followed by a top-bottom
         flip about a horizontal line through the image center.
     (2) There are 2 cases for input:
         (a) fpixd == null (creates a new fpixd)
         (b) fpixd == fpixs (in-place operation)
     (3) For clarity, use these two patterns:
         (a) fpixd = fpixRotate180(NULL, fpixs);
         (b) fpixRotate180(fpixs, fpixs);

Definition at line 1747 of file fpix2.c.

References fpixCopy(), fpixFlipLR(), and fpixFlipTB().

Referenced by fpixRotateOrth().

◆ fpixRotate90()

FPIX* fpixRotate90 ( FPIX fpixs,
l_int32  direction 
)

fpixRotate90()

Parameters
[in]fpixs
[in]direction1 = clockwise; -1 = counter-clockwise
Returns
fpixd, or NULL on error
Notes:
     (1) This does a 90 degree rotation of the image about the center,
         either cw or ccw, returning a new pix.
     (2) The direction must be either 1 (cw) or -1 (ccw).

Definition at line 1778 of file fpix2.c.

References fpixCopyResolution(), fpixCreate(), fpixGetData(), fpixGetDimensions(), and fpixGetWpl().

Referenced by fpixRotateOrth().

◆ fpixRotateOrth()

FPIX* fpixRotateOrth ( FPIX fpixs,
l_int32  quads 
)

fpixRotateOrth()

Parameters
[in]fpixs
[in]quads0-3; number of 90 degree cw rotations
Returns
fpixd, or NULL on error

Definition at line 1706 of file fpix2.c.

References fpixCopy(), fpixRotate180(), and fpixRotate90().

◆ fpixScaleByInteger()

FPIX* fpixScaleByInteger ( FPIX fpixs,
l_int32  factor 
)

fpixScaleByInteger()

Parameters
[in]fpixstypically low resolution
[in]factorinteger scaling factor
Returns
fpixd interpolated result, or NULL on error
Notes:
     (1) The width wd of fpixd is related to ws of fpixs by:
             wd = factor * (ws - 1) + 1   (and ditto for the height)
         We avoid special-casing boundary pixels in the interpolation
         by constructing fpixd by inserting (factor - 1) interpolated
         pixels between each pixel in fpixs.  Then
              wd = ws + (ws - 1) * (factor - 1)    (same as above)
         This also has the advantage that if we subsample by factor,
         throwing out all the interpolated pixels, we regain the
         original low resolution fpix.

Definition at line 899 of file fpix2.c.

References fpixCreate(), fpixGetData(), fpixGetDimensions(), and fpixGetWpl().

Referenced by dewarpPopulateFullRes().

◆ fpixSetAllArbitrary()

l_ok fpixSetAllArbitrary ( FPIX fpix,
l_float32  inval 
)

fpixSetAllArbitrary()

Parameters
[in]fpix
[in]invalto set at each pixel
Returns
0 if OK, 1 on error

Definition at line 1291 of file fpix2.c.

References fpixGetData(), and fpixGetDimensions().

Referenced by fpixAffine(), and fpixProjective().

◆ fpixThresholdToPix()

PIX* fpixThresholdToPix ( FPIX fpix,
l_float32  thresh 
)

fpixThresholdToPix()

Parameters
[in]fpix
[in]thresh
Returns
pixd 1 bpp, or NULL on error
Notes:
     (1) For all values of fpix that are <= thresh, sets the pixel
         in pixd to 1.

Definition at line 2239 of file fpix2.c.

References fpixGetData(), fpixGetDimensions(), fpixGetWpl(), pixCreate(), and pixGetData().

◆ linearInterpolatePixelFloat()

l_ok linearInterpolatePixelFloat ( l_float32 *  datas,
l_int32  w,
l_int32  h,
l_float32  x,
l_float32  y,
l_float32  inval,
l_float32 *  pval 
)

linearInterpolatePixelFloat()

Parameters
[in]datasptr to beginning of float image data
[in]w,hdimensions of image
[in]x,yfloating pt location for evaluation
[in]invalfloat value brought in from the outside when the input x,y location is outside the image
[out]pvalinterpolated float value
Returns
0 if OK, 1 on error
Notes:
     (1) This is a standard linear interpolation function.  It is
         equivalent to area weighting on each component, and
         avoids "jaggies" when rendering sharp edges.

Definition at line 2177 of file fpix2.c.

References lept_stderr().

Referenced by fpixAffine(), and fpixProjective().

◆ pixComponentFunction()

FPIX* pixComponentFunction ( PIX pix,
l_float32  rnum,
l_float32  gnum,
l_float32  bnum,
l_float32  rdenom,
l_float32  gdenom,
l_float32  bdenom 
)

pixComponentFunction()

Parameters
[in]pix32 bpp rgb
[in]rnum,gnum,bnumcoefficients for numerator
[in]rdenom,gdenom,bdenomcoefficients for denominator
Returns
fpixd, or NULL on error
Notes:
     (1) This stores a function of the component values of each
         input pixel in fpixd.
     (2) The function is a ratio of linear combinations of component values.
         There are two special cases for denominator coefficients:
         (a) The denominator is 1.0: input 0 for all denominator coefficients
         (b) Only one component is used in the denominator: input 1.0
             for that denominator component and 0.0 for the other two.
     (3) If the denominator is 0, multiply by an arbitrary number that
         is much larger than 1.  Choose 256 "arbitrarily".

Definition at line 2295 of file fpix2.c.

◆ pixConvertToDPix()

DPIX* pixConvertToDPix ( PIX pixs,
l_int32  ncomps 
)

pixConvertToDPix()

Parameters
[in]pixs1, 2, 4, 8, 16 or 32 bpp
[in]ncompsnumber of components: 3 for RGB, 1 otherwise
Returns
dpix, or NULL on error
Notes:
     (1) If colormapped, remove to grayscale.
     (2) If 32 bpp and ncomps == 3, this is RGB; convert to luminance.
         In all other cases the src image is treated as having a single
         component of pixel values.

Definition at line 221 of file fpix2.c.

◆ pixConvertToFPix()

FPIX* pixConvertToFPix ( PIX pixs,
l_int32  ncomps 
)

pixConvertToFPix()

Parameters
[in]pixs1, 2, 4, 8, 16 or 32 bpp
[in]ncompsnumber of components: 3 for RGB, 1 otherwise
Returns
fpix, or NULL on error
Notes:
     (1) If colormapped, remove to grayscale.
     (2) If 32 bpp and ncomps == 3, this is RGB; convert to luminance.
         In all other cases the src image is treated as having a single
         component of pixel values.

Definition at line 130 of file fpix2.c.