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

Go to the source code of this file.

Functions

static l_int32 fpixaExtendArray (FPIXA *fpixa)
 
static l_int32 fpixaExtendArrayToSize (FPIXA *fpixa, l_int32 size)
 
FPIXfpixCreate (l_int32 width, l_int32 height)
 
FPIXfpixCreateTemplate (FPIX *fpixs)
 
FPIXfpixClone (FPIX *fpix)
 
FPIXfpixCopy (FPIX *fpixs)
 
void fpixDestroy (FPIX **pfpix)
 
l_ok fpixGetDimensions (FPIX *fpix, l_int32 *pw, l_int32 *ph)
 
l_ok fpixSetDimensions (FPIX *fpix, l_int32 w, l_int32 h)
 
l_int32 fpixGetWpl (FPIX *fpix)
 
l_ok fpixSetWpl (FPIX *fpix, l_int32 wpl)
 
l_int32 fpixGetRefcount (FPIX *fpix)
 
l_ok fpixChangeRefcount (FPIX *fpix, l_int32 delta)
 
l_ok fpixGetResolution (FPIX *fpix, l_int32 *pxres, l_int32 *pyres)
 
l_ok fpixSetResolution (FPIX *fpix, l_int32 xres, l_int32 yres)
 
l_ok fpixCopyResolution (FPIX *fpixd, FPIX *fpixs)
 
l_float32 * fpixGetData (FPIX *fpix)
 
l_ok fpixSetData (FPIX *fpix, l_float32 *data)
 
l_ok fpixGetPixel (FPIX *fpix, l_int32 x, l_int32 y, l_float32 *pval)
 
l_ok fpixSetPixel (FPIX *fpix, l_int32 x, l_int32 y, l_float32 val)
 
FPIXAfpixaCreate (l_int32 n)
 
FPIXAfpixaCopy (FPIXA *fpixa, l_int32 copyflag)
 
void fpixaDestroy (FPIXA **pfpixa)
 
l_ok fpixaAddFPix (FPIXA *fpixa, FPIX *fpix, l_int32 copyflag)
 
l_int32 fpixaGetCount (FPIXA *fpixa)
 
l_ok fpixaChangeRefcount (FPIXA *fpixa, l_int32 delta)
 
FPIXfpixaGetFPix (FPIXA *fpixa, l_int32 index, l_int32 accesstype)
 
l_ok fpixaGetFPixDimensions (FPIXA *fpixa, l_int32 index, l_int32 *pw, l_int32 *ph)
 
l_float32 * fpixaGetData (FPIXA *fpixa, l_int32 index)
 
l_ok fpixaGetPixel (FPIXA *fpixa, l_int32 index, l_int32 x, l_int32 y, l_float32 *pval)
 
l_ok fpixaSetPixel (FPIXA *fpixa, l_int32 index, l_int32 x, l_int32 y, l_float32 val)
 
DPIXdpixCreate (l_int32 width, l_int32 height)
 
DPIXdpixCreateTemplate (DPIX *dpixs)
 
DPIXdpixClone (DPIX *dpix)
 
DPIXdpixCopy (DPIX *dpixs)
 
void dpixDestroy (DPIX **pdpix)
 
l_ok dpixGetDimensions (DPIX *dpix, l_int32 *pw, l_int32 *ph)
 
l_ok dpixSetDimensions (DPIX *dpix, l_int32 w, l_int32 h)
 
l_int32 dpixGetWpl (DPIX *dpix)
 
l_ok dpixSetWpl (DPIX *dpix, l_int32 wpl)
 
l_int32 dpixGetRefcount (DPIX *dpix)
 
l_ok dpixChangeRefcount (DPIX *dpix, l_int32 delta)
 
l_ok dpixGetResolution (DPIX *dpix, l_int32 *pxres, l_int32 *pyres)
 
l_ok dpixSetResolution (DPIX *dpix, l_int32 xres, l_int32 yres)
 
l_ok dpixCopyResolution (DPIX *dpixd, DPIX *dpixs)
 
l_float64 * dpixGetData (DPIX *dpix)
 
l_ok dpixSetData (DPIX *dpix, l_float64 *data)
 
l_ok dpixGetPixel (DPIX *dpix, l_int32 x, l_int32 y, l_float64 *pval)
 
l_ok dpixSetPixel (DPIX *dpix, l_int32 x, l_int32 y, l_float64 val)
 
FPIXfpixRead (const char *filename)
 
FPIXfpixReadStream (FILE *fp)
 
FPIXfpixReadMem (const l_uint8 *data, size_t size)
 
l_ok fpixWrite (const char *filename, FPIX *fpix)
 
l_ok fpixWriteStream (FILE *fp, FPIX *fpix)
 
l_ok fpixWriteMem (l_uint8 **pdata, size_t *psize, FPIX *fpix)
 
FPIXfpixEndianByteSwap (FPIX *fpixd, FPIX *fpixs)
 
DPIXdpixRead (const char *filename)
 
DPIXdpixReadStream (FILE *fp)
 
DPIXdpixReadMem (const l_uint8 *data, size_t size)
 
l_ok dpixWrite (const char *filename, DPIX *dpix)
 
l_ok dpixWriteStream (FILE *fp, DPIX *dpix)
 
l_ok dpixWriteMem (l_uint8 **pdata, size_t *psize, DPIX *dpix)
 
DPIXdpixEndianByteSwap (DPIX *dpixd, DPIX *dpixs)
 
l_ok fpixPrintStream (FILE *fp, FPIX *fpix, l_int32 factor)
 

Variables

static const size_t MaxPtrArraySize = 100000
 
static const size_t InitialPtrArraySize = 20
 

Detailed Description

   ---------------------------------------------------
   This file has these FPix, FPixa and DPix utilities:
  • creation and destruction
  • accessors
  • serialization and deserialization ---------------------------------------------------
   FPix Create/copy/destroy
         FPIX          *fpixCreate()
         FPIX          *fpixCreateTemplate()
         FPIX          *fpixClone()
         FPIX          *fpixCopy()
         void           fpixDestroy()
   FPix accessors
         l_int32        fpixGetDimensions()
         l_int32        fpixSetDimensions()
         l_int32        fpixGetWpl()
         l_int32        fpixSetWpl()
         l_int32        fpixGetRefcount()
         l_int32        fpixChangeRefcount()
         l_int32        fpixGetResolution()
         l_int32        fpixSetResolution()
         l_int32        fpixCopyResolution()
         l_float32     *fpixGetData()
         l_int32        fpixSetData()
         l_int32        fpixGetPixel()
         l_int32        fpixSetPixel()
   FPixa Create/copy/destroy
         FPIXA         *fpixaCreate()
         FPIXA         *fpixaCopy()
         void           fpixaDestroy()
   FPixa addition
         l_int32        fpixaAddFPix()
         static l_int32 fpixaExtendArray()
         static l_int32 fpixaExtendArrayToSize()
   FPixa accessors
         l_int32        fpixaGetCount()
         l_int32        fpixaChangeRefcount()
         FPIX          *fpixaGetFPix()
         l_int32        fpixaGetFPixDimensions()
         l_float32     *fpixaGetData()
         l_int32        fpixaGetPixel()
         l_int32        fpixaSetPixel()
   DPix Create/copy/destroy
         DPIX          *dpixCreate()
         DPIX          *dpixCreateTemplate()
         DPIX          *dpixClone()
         DPIX          *dpixCopy()
         void           dpixDestroy()
   DPix accessors
         l_int32        dpixGetDimensions()
         l_int32        dpixSetDimensions()
         l_int32        dpixGetWpl()
         l_int32        dpixSetWpl()
         l_int32        dpixGetRefcount()
         l_int32        dpixChangeRefcount()
         l_int32        dpixGetResolution()
         l_int32        dpixSetResolution()
         l_int32        dpixCopyResolution()
         l_float64     *dpixGetData()
         l_int32        dpixSetData()
         l_int32        dpixGetPixel()
         l_int32        dpixSetPixel()
   FPix serialized I/O
         FPIX          *fpixRead()
         FPIX          *fpixReadStream()
         FPIX          *fpixReadMem()
         l_int32        fpixWrite()
         l_int32        fpixWriteStream()
         l_int32        fpixWriteMem()
         FPIX          *fpixEndianByteSwap()
   DPix serialized I/O
         DPIX          *dpixRead()
         DPIX          *dpixReadStream()
         DPIX          *dpixReadMem()
         l_int32        dpixWrite()
         l_int32        dpixWriteStream()
         l_int32        dpixWriteMem()
         DPIX          *dpixEndianByteSwap()
   Print FPix (subsampled, for debugging)
         l_int32        fpixPrintStream()

Definition in file fpix1.c.

Function Documentation

◆ dpixChangeRefcount()

l_ok dpixChangeRefcount ( DPIX dpix,
l_int32  delta 
)

dpixChangeRefcount()

Parameters
[in]dpix
[in]delta
Returns
0 if OK, 1 on error

Definition at line 1354 of file fpix1.c.

References DPix::refcount.

Referenced by dpixClone(), and dpixDestroy().

◆ dpixClone()

DPIX* dpixClone ( DPIX dpix)

dpixClone()

Parameters
[in]dpix
Returns
same dpix ptr, or NULL on error
Notes:
     (1) See pixClone() for definition and usage.

Definition at line 1159 of file fpix1.c.

References dpixChangeRefcount().

Referenced by dpixEndianByteSwap().

◆ dpixCopy()

DPIX* dpixCopy ( DPIX dpixs)

dpixCopy()

Parameters
[in]dpixs
Returns
dpixd, or NULL on error

Definition at line 1177 of file fpix1.c.

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

Referenced by dpixEndianByteSwap(), and dpixLinearCombination().

◆ dpixCopyResolution()

l_ok dpixCopyResolution ( DPIX dpixd,
DPIX dpixs 
)

dpixCopyResolution()

Parameters
[in]dpixd,dpixs
Returns
0 if OK, 1 on error

Definition at line 1419 of file fpix1.c.

References dpixGetResolution(), and dpixSetResolution().

Referenced by dpixCreateTemplate().

◆ dpixCreate()

DPIX* dpixCreate ( l_int32  width,
l_int32  height 
)

dpixCreate()

Parameters
[in]width,height
Returns
dpix with data allocated and initialized to 0, or NULL on error
Notes:
     (1) Makes a DPix of specified size, with the data array
         allocated and initialized to 0.
     (2) The number of pixels must be less than 2^28.

Definition at line 1080 of file fpix1.c.

References dpixDestroy(), dpixSetData(), dpixSetDimensions(), dpixSetWpl(), and DPix::refcount.

Referenced by dpixCreateTemplate(), dpixReadStream(), dpixScaleByInteger(), and fpixConvertToDPix().

◆ dpixCreateTemplate()

DPIX* dpixCreateTemplate ( DPIX dpixs)

dpixCreateTemplate()

Parameters
[in]dpixs
Returns
dpixd, or NULL on error
Notes:
     (1) Makes a DPix of the same size as the input DPix, with the
         data array allocated and initialized to 0.
     (2) Copies the resolution.

Definition at line 1130 of file fpix1.c.

References dpixCopyResolution(), dpixCreate(), and dpixGetDimensions().

Referenced by dpixCopy().

◆ dpixDestroy()

void dpixDestroy ( DPIX **  pdpix)

dpixDestroy()

Parameters
[in,out]pdpixwill be set to null before returning
Returns
void
Notes:
     (1) Decrements the ref count and, if 0, destroys the dpix.
     (2) Always nulls the input ptr.

Definition at line 1214 of file fpix1.c.

References dpixChangeRefcount(), dpixGetData(), and dpixGetRefcount().

Referenced by dpixCreate(), dpixReadStream(), and dpixWriteStream().

◆ dpixEndianByteSwap()

DPIX* dpixEndianByteSwap ( DPIX dpixd,
DPIX dpixs 
)

dpixEndianByteSwap()

Parameters
[in]dpixd[optional] can be either NULL, or equal to dpixs
[in]dpixs
Returns
dpixd always
Notes:
     (1) On big-endian hardware, this does byte-swapping on each of
         the 4-byte words in the dpix data.  On little-endians,
         the data is unchanged.  This is used for serialization
         of dpix; the data is serialized in little-endian byte
         order because most hardware is little-endian.
     (2) The operation can be either in-place or, if dpixd == NULL,
         a new dpix is made.  If not in-place, caller must catch
         the returned pointer.

Definition at line 2104 of file fpix1.c.

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

Referenced by dpixReadStream(), and dpixWriteStream().

◆ dpixGetData()

l_float64* dpixGetData ( DPIX dpix)

◆ dpixGetDimensions()

l_ok dpixGetDimensions ( DPIX dpix,
l_int32 *  pw,
l_int32 *  ph 
)

◆ dpixGetPixel()

l_ok dpixGetPixel ( DPIX dpix,
l_int32  x,
l_int32  y,
l_float64 *  pval 
)

dpixGetPixel()

Parameters
[in]dpix
[in]x,ypixel coords
[out]pvalpixel value
Returns
0 if OK; 1 or 2 on error

Notes: (1) If the point is outside the image, this returns an error (2), with 0.0 in pval. To avoid spamming output, it fails silently.

Definition at line 1485 of file fpix1.c.

References DPix::data, and dpixGetDimensions().

◆ dpixGetRefcount()

l_int32 dpixGetRefcount ( DPIX dpix)

dpixGetRefcount()

Parameters
[in]dpix
Returns
refcount, or UNDEF on error

Definition at line 1336 of file fpix1.c.

References DPix::refcount.

Referenced by dpixDestroy().

◆ dpixGetResolution()

l_ok dpixGetResolution ( DPIX dpix,
l_int32 *  pxres,
l_int32 *  pyres 
)

dpixGetResolution()

Parameters
[in]dpix
[out]pxres,pyres[optional] x and y resolution
Returns
0 if OK, 1 on error

Definition at line 1375 of file fpix1.c.

References DPix::xres, and DPix::yres.

Referenced by dpixCopyResolution(), and dpixWriteStream().

◆ dpixGetWpl()

l_int32 dpixGetWpl ( DPIX dpix)

dpixGetWpl()

Parameters
[in]dpix
Returns
wpl, or 0 on error

Definition at line 1298 of file fpix1.c.

References DPix::wpl.

Referenced by dpixAddMultConstant(), dpixConvertToFPix(), dpixConvertToPix(), dpixGetMax(), dpixGetMin(), dpixLinearCombination(), dpixScaleByInteger(), and fpixConvertToDPix().

◆ dpixRead()

DPIX* dpixRead ( const char *  filename)

dpixRead()

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

Definition at line 1855 of file fpix1.c.

References dpixReadStream(), and fopenReadStream().

◆ dpixReadMem()

DPIX* dpixReadMem ( const l_uint8 *  data,
size_t  size 
)

dpixReadMem()

Parameters
[in]dataof serialized dpix
[in]sizeof data in bytes
Returns
dpix, or NULL on error

Definition at line 1935 of file fpix1.c.

References dpixReadStream(), and fopenReadFromMemory().

◆ dpixReadStream()

DPIX* dpixReadStream ( FILE *  fp)

dpixReadStream()

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

Definition at line 1882 of file fpix1.c.

References DPIX_VERSION_NUMBER, dpixCreate(), dpixDestroy(), dpixEndianByteSwap(), dpixGetData(), and dpixSetResolution().

Referenced by dpixRead(), and dpixReadMem().

◆ dpixSetData()

l_ok dpixSetData ( DPIX dpix,
l_float64 *  data 
)

dpixSetData()

Parameters
[in]dpix
[in]data
Returns
0 if OK, 1 on error

Definition at line 1459 of file fpix1.c.

References DPix::data.

Referenced by dpixCreate().

◆ dpixSetDimensions()

l_ok dpixSetDimensions ( DPIX dpix,
l_int32  w,
l_int32  h 
)

dpixSetDimensions()

Parameters
[in]dpix
[in]w,h
Returns
0 if OK, 1 on error

Definition at line 1277 of file fpix1.c.

References DPix::h, and DPix::w.

Referenced by dpixCreate().

◆ dpixSetPixel()

l_ok dpixSetPixel ( DPIX dpix,
l_int32  x,
l_int32  y,
l_float64  val 
)

dpixSetPixel()

Parameters
[in]dpix
[in]x,ypixel coords
[in]valpixel value
Returns
0 if OK; 1 or 2 on error

Notes: (1) If the point is outside the image, this returns an error (2), with 0.0 in pval. To avoid spamming output, it fails silently.

Definition at line 1522 of file fpix1.c.

References DPix::data, and dpixGetDimensions().

◆ dpixSetResolution()

l_ok dpixSetResolution ( DPIX dpix,
l_int32  xres,
l_int32  yres 
)

dpixSetResolution()

Parameters
[in]dpix
[in]xres,yresx and y resolution
Returns
0 if OK, 1 on error

Definition at line 1397 of file fpix1.c.

References DPix::xres, and DPix::yres.

Referenced by dpixCopyResolution(), and dpixReadStream().

◆ dpixSetWpl()

l_ok dpixSetWpl ( DPIX dpix,
l_int32  wpl 
)

dpixSetWpl()

Parameters
[in]dpix
[in]wpl
Returns
0 if OK, 1 on error

Definition at line 1316 of file fpix1.c.

References DPix::wpl.

Referenced by dpixCreate().

◆ dpixWrite()

l_ok dpixWrite ( const char *  filename,
DPIX dpix 
)

dpixWrite()

Parameters
[in]filename
[in]dpix
Returns
0 if OK, 1 on error

Definition at line 1963 of file fpix1.c.

References dpixWriteStream(), and fopenWriteStream().

◆ dpixWriteMem()

l_ok dpixWriteMem ( l_uint8 **  pdata,
size_t *  psize,
DPIX dpix 
)

dpixWriteMem()

Parameters
[out]pdatadata of serialized dpix
[out]psizesize of returned data
[in]dpix
Returns
0 if OK, 1 on error
Notes:
     (1) Serializes a dpix in memory and puts the result in a buffer.

Definition at line 2041 of file fpix1.c.

References dpixWriteStream(), fopenWriteWinTempfile(), and l_binaryReadStream().

◆ dpixWriteStream()

l_ok dpixWriteStream ( FILE *  fp,
DPIX dpix 
)

dpixWriteStream()

Parameters
[in]fpfile stream opened for "wb"
[in]dpix
Returns
0 if OK, 1 on error

Definition at line 1994 of file fpix1.c.

References DPIX_VERSION_NUMBER, dpixDestroy(), dpixEndianByteSwap(), dpixGetData(), dpixGetDimensions(), and dpixGetResolution().

Referenced by dpixWrite(), and dpixWriteMem().

◆ fpixaAddFPix()

l_ok fpixaAddFPix ( FPIXA fpixa,
FPIX fpix,
l_int32  copyflag 
)

fpixaAddFPix()

Parameters
[in]fpixa
[in]fpixto be added
[in]copyflagL_INSERT, L_COPY, L_CLONE
Returns
0 if OK; 1 on error

Definition at line 751 of file fpix1.c.

References FPixa::fpix, fpixaExtendArray(), fpixaGetCount(), fpixClone(), fpixCopy(), fpixDestroy(), L_CLONE, L_COPY, L_INSERT, FPixa::n, and FPixa::nalloc.

Referenced by fpixaConvertLABToXYZ(), fpixaConvertXYZToLAB(), and fpixaCopy().

◆ fpixaChangeRefcount()

l_ok fpixaChangeRefcount ( FPIXA fpixa,
l_int32  delta 
)

fpixaChangeRefcount()

Parameters
[in]fpixa
[in]delta
Returns
0 if OK, 1 on error

Definition at line 885 of file fpix1.c.

References FPixa::refcount.

Referenced by fpixaCopy(), and fpixaDestroy().

◆ fpixaCopy()

FPIXA* fpixaCopy ( FPIXA fpixa,
l_int32  copyflag 
)

fpixaCopy()

Parameters
[in]fpixa
[in]copyflagL_COPY, L_CLODE or L_COPY_CLONE
Returns
new fpixa, or NULL on error
Notes:
     copyflag may be one of
       ~ L_COPY makes a new fpixa and copies each fpix
       ~ L_CLONE gives a new ref-counted handle to the input fpixa
       ~ L_COPY_CLONE makes a new fpixa with clones of all fpix

Definition at line 665 of file fpix1.c.

References fpixaAddFPix(), fpixaChangeRefcount(), fpixaCreate(), fpixaGetFPix(), L_CLONE, L_COPY, L_COPY_CLONE, L_INSERT, and FPixa::n.

◆ fpixaCreate()

FPIXA* fpixaCreate ( l_int32  n)

fpixaCreate()

Parameters
[in]ninitial number of ptrs
Returns
fpixa, or NULL on error

Definition at line 631 of file fpix1.c.

Referenced by fpixaConvertLABToXYZ(), fpixaConvertXYZToLAB(), and fpixaCopy().

◆ fpixaDestroy()

void fpixaDestroy ( FPIXA **  pfpixa)

fpixaDestroy()

Parameters
[in,out]pfpixawill be set to null before returning
Returns
void
Notes:
     (1) Decrements the ref count and, if 0, destroys the fpixa.
     (2) Always nulls the input ptr.

Definition at line 712 of file fpix1.c.

References FPixa::fpix, fpixaChangeRefcount(), fpixDestroy(), FPixa::n, and FPixa::refcount.

◆ fpixaExtendArray()

static l_int32 fpixaExtendArray ( FPIXA fpixa)
static

fpixaExtendArray()

Parameters
[in]fpixa
Returns
0 if OK; 1 on error
Notes:
     (1) Doubles the size of the fpixa ptr array.
     (2) The max number of fpix ptrs is 100000.

Definition at line 803 of file fpix1.c.

References fpixaExtendArrayToSize(), and FPixa::nalloc.

Referenced by fpixaAddFPix().

◆ fpixaExtendArrayToSize()

static l_int32 fpixaExtendArrayToSize ( FPIXA fpixa,
l_int32  size 
)
static

fpixaExtendArrayToSize()

Parameters
[in]fpixa
[in]sizenew ptr array size
Returns
0 if OK; 1 on error
Notes:
     (1) If necessary, reallocs new fpix ptr array to size.
     (2) The max number of fpix ptrs is 100K.

Definition at line 828 of file fpix1.c.

References FPixa::nalloc.

Referenced by fpixaExtendArray().

◆ fpixaGetCount()

l_int32 fpixaGetCount ( FPIXA fpixa)

◆ fpixaGetData()

l_float32* fpixaGetData ( FPIXA fpixa,
l_int32  index 
)

fpixaGetData()

Parameters
[in]fpixa
[in]indexinto fpixa array
Returns
data not a copy, or NULL on error

Definition at line 970 of file fpix1.c.

References fpixaGetCount(), fpixaGetFPix(), fpixDestroy(), fpixGetData(), and L_CLONE.

Referenced by fpixaConvertLABToXYZ(), and fpixaConvertXYZToLAB().

◆ fpixaGetFPix()

FPIX* fpixaGetFPix ( FPIXA fpixa,
l_int32  index,
l_int32  accesstype 
)

fpixaGetFPix()

Parameters
[in]fpixa
[in]indexto the index-th fpix
[in]accesstypeL_COPY or L_CLONE
Returns
fpix, or NULL on error

Definition at line 907 of file fpix1.c.

References FPixa::fpix, fpixClone(), fpixCopy(), L_CLONE, L_COPY, and FPixa::n.

Referenced by fpixaCopy(), fpixaDisplayQuadtree(), fpixaGetData(), fpixaGetFPixDimensions(), fpixaGetPixel(), and fpixaSetPixel().

◆ fpixaGetFPixDimensions()

l_ok fpixaGetFPixDimensions ( FPIXA fpixa,
l_int32  index,
l_int32 *  pw,
l_int32 *  ph 
)

fpixaGetFPixDimensions()

Parameters
[in]fpixa
[in]indexto the index-th box
[out]pw,ph[optional] each can be null
Returns
0 if OK, 1 on error

Definition at line 936 of file fpix1.c.

References fpixaGetFPix(), fpixDestroy(), fpixGetDimensions(), L_CLONE, and FPixa::n.

Referenced by fpixaConvertLABToRGB(), fpixaConvertLABToXYZ(), fpixaConvertXYZToLAB(), and fpixaConvertXYZToRGB().

◆ fpixaGetPixel()

l_ok fpixaGetPixel ( FPIXA fpixa,
l_int32  index,
l_int32  x,
l_int32  y,
l_float32 *  pval 
)

fpixaGetPixel()

Parameters
[in]fpixa
[in]indexinto fpixa array
[in]x,ypixel coords
[out]pvalpixel value
Returns
0 if OK; 1 on error

Definition at line 1002 of file fpix1.c.

References fpixaGetCount(), fpixaGetFPix(), fpixDestroy(), fpixGetPixel(), and L_CLONE.

Referenced by quadtreeGetChildren(), and quadtreeGetParent().

◆ fpixaSetPixel()

l_ok fpixaSetPixel ( FPIXA fpixa,
l_int32  index,
l_int32  x,
l_int32  y,
l_float32  val 
)

fpixaSetPixel()

Parameters
[in]fpixa
[in]indexinto fpixa array
[in]x,ypixel coords
[in]valpixel value
Returns
0 if OK; 1 on error

Definition at line 1039 of file fpix1.c.

References fpixaGetCount(), fpixaGetFPix(), fpixDestroy(), fpixSetPixel(), and L_CLONE.

◆ fpixChangeRefcount()

l_ok fpixChangeRefcount ( FPIX fpix,
l_int32  delta 
)

fpixChangeRefcount()

Parameters
[in]fpix
[in]delta
Returns
0 if OK, 1 on error

Definition at line 432 of file fpix1.c.

References FPix::refcount.

Referenced by fpixClone(), and fpixDestroy().

◆ fpixClone()

FPIX* fpixClone ( FPIX fpix)

fpixClone()

Parameters
[in]fpix
Returns
same fpix ptr, or NULL on error
Notes:
     (1) See pixClone() for definition and usage.

Definition at line 236 of file fpix1.c.

References fpixChangeRefcount().

Referenced by fpixaAddFPix(), fpixAffinePta(), fpixaGetFPix(), fpixEndianByteSwap(), and fpixProjectivePta().

◆ fpixCopy()

◆ fpixCopyResolution()

l_ok fpixCopyResolution ( FPIX fpixd,
FPIX fpixs 
)

fpixCopyResolution()

Parameters
[in]fpixd,fpixs
Returns
0 if OK, 1 on error

Definition at line 497 of file fpix1.c.

References fpixGetResolution(), and fpixSetResolution().

Referenced by fpixAddBorder(), fpixCreateTemplate(), fpixRemoveBorder(), and fpixRotate90().

◆ fpixCreate()

FPIX* fpixCreate ( l_int32  width,
l_int32  height 
)

fpixCreate()

Parameters
[in]width,height
Returns
fpixd with data allocated and initialized to 0, or NULL on error
Notes:
     (1) Makes a FPix of specified size, with the data array
         allocated and initialized to 0.
     (2) The number of pixels must be less than 2^29.

Definition at line 156 of file fpix1.c.

References fpixDestroy(), fpixSetData(), fpixSetDimensions(), fpixSetWpl(), and FPix::refcount.

Referenced by dpixConvertToFPix(), fpixaConvertLABToXYZ(), fpixaConvertXYZToLAB(), fpixAddBorder(), fpixCreateTemplate(), fpixReadStream(), fpixRemoveBorder(), fpixRotate90(), and fpixScaleByInteger().

◆ fpixCreateTemplate()

FPIX* fpixCreateTemplate ( FPIX fpixs)

fpixCreateTemplate()

Parameters
[in]fpixs
Returns
fpixd, or NULL on error
Notes:
     (1) Makes a FPix of the same size as the input FPix, with the
         data array allocated and initialized to 0.
     (2) Copies the resolution.

Definition at line 206 of file fpix1.c.

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

Referenced by fpixAffine(), fpixCopy(), and fpixProjective().

◆ fpixDestroy()

void fpixDestroy ( FPIX **  pfpix)

fpixDestroy()

Parameters
[in,out]pfpixwill be set to null before returning
Returns
void
Notes:
     (1) Decrements the ref count and, if 0, destroys the fpix.
     (2) Always nulls the input ptr.

Definition at line 292 of file fpix1.c.

References fpixChangeRefcount(), fpixGetData(), and fpixGetRefcount().

Referenced by dewarpDestroy(), dewarpMinimize(), dewarpPopulateFullRes(), fpixaAddFPix(), fpixaDestroy(), fpixaDisplayQuadtree(), fpixAffinePta(), fpixaGetData(), fpixaGetFPixDimensions(), fpixaGetPixel(), fpixaSetPixel(), fpixCreate(), fpixProjectivePta(), fpixReadStream(), and fpixWriteStream().

◆ fpixEndianByteSwap()

FPIX* fpixEndianByteSwap ( FPIX fpixd,
FPIX fpixs 
)

fpixEndianByteSwap()

Parameters
[in]fpixd[optional] can be either NULL, or equal to fpixs
[in]fpixs
Returns
fpixd always
Notes:
     (1) On big-endian hardware, this does byte-swapping on each of
         the 4-byte floats in the fpix data.  On little-endians,
         the data is unchanged.  This is used for serialization
         of fpix; the data is serialized in little-endian byte
         order because most hardware is little-endian.
     (2) The operation can be either in-place or, if fpixd == NULL,
         a new fpix is made.  If not in-place, caller must catch
         the returned pointer.

Definition at line 1802 of file fpix1.c.

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

Referenced by fpixReadStream(), and fpixWriteStream().

◆ fpixGetData()

◆ fpixGetDimensions()

◆ fpixGetPixel()

l_ok fpixGetPixel ( FPIX fpix,
l_int32  x,
l_int32  y,
l_float32 *  pval 
)

fpixGetPixel()

Parameters
[in]fpix
[in]x,ypixel coords
[out]pvalpixel value
Returns
0 if OK; 1 or 2 on error

Notes: (1) If the point is outside the image, this returns an error (2), with 0.0 in pval. To avoid spamming output, it fails silently.

Definition at line 563 of file fpix1.c.

References FPix::data, and fpixGetDimensions().

Referenced by fpixAddSlopeBorder(), fpixaGetPixel(), and fpixPrintStream().

◆ fpixGetRefcount()

l_int32 fpixGetRefcount ( FPIX fpix)

fpixGetRefcount()

Parameters
[in]fpix
Returns
refcount, or UNDEF on error

Definition at line 414 of file fpix1.c.

References FPix::refcount.

Referenced by fpixDestroy().

◆ fpixGetResolution()

l_ok fpixGetResolution ( FPIX fpix,
l_int32 *  pxres,
l_int32 *  pyres 
)

fpixGetResolution()

Parameters
[in]fpix
[out]pxres,pyres[optional] x and y resolution
Returns
0 if OK, 1 on error

Definition at line 453 of file fpix1.c.

References FPix::xres, and FPix::yres.

Referenced by fpixCopyResolution(), and fpixWriteStream().

◆ fpixGetWpl()

◆ fpixPrintStream()

l_ok fpixPrintStream ( FILE *  fp,
FPIX fpix,
l_int32  factor 
)

fpixPrintStream()

Parameters
[in]fpfile stream
[in]fpix
[in]factorfor subsampling
Returns
0 if OK, 1 on error
Notes:
     (1) Subsampled printout of fpix for debugging.

Definition at line 2164 of file fpix1.c.

References fpixGetDimensions(), and fpixGetPixel().

◆ fpixRead()

FPIX* fpixRead ( const char *  filename)

fpixRead()

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

Definition at line 1553 of file fpix1.c.

References fopenReadStream(), and fpixReadStream().

◆ fpixReadMem()

FPIX* fpixReadMem ( const l_uint8 *  data,
size_t  size 
)

fpixReadMem()

Parameters
[in]dataof serialized fpix
[in]sizeof data in bytes
Returns
fpix, or NULL on error

Definition at line 1633 of file fpix1.c.

References fopenReadFromMemory(), and fpixReadStream().

◆ fpixReadStream()

FPIX* fpixReadStream ( FILE *  fp)

fpixReadStream()

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

Definition at line 1580 of file fpix1.c.

References FPIX_VERSION_NUMBER, fpixCreate(), fpixDestroy(), fpixEndianByteSwap(), fpixGetData(), and fpixSetResolution().

Referenced by dewarpReadStream(), fpixRead(), and fpixReadMem().

◆ fpixSetData()

l_ok fpixSetData ( FPIX fpix,
l_float32 *  data 
)

fpixSetData()

Parameters
[in]fpix
[in]data
Returns
0 if OK, 1 on error

Definition at line 537 of file fpix1.c.

References FPix::data.

Referenced by fpixCreate().

◆ fpixSetDimensions()

l_ok fpixSetDimensions ( FPIX fpix,
l_int32  w,
l_int32  h 
)

fpixSetDimensions()

Parameters
[in]fpix
[in]w,h
Returns
0 if OK, 1 on error

Definition at line 355 of file fpix1.c.

References FPix::h, and FPix::w.

Referenced by fpixCreate().

◆ fpixSetPixel()

l_ok fpixSetPixel ( FPIX fpix,
l_int32  x,
l_int32  y,
l_float32  val 
)

fpixSetPixel()

Parameters
[in]fpix
[in]x,ypixel coords
[in]valpixel value
Returns
0 if OK; 1 or 2 on error

Notes: (1) If the point is outside the image, this returns an error (2), with 0.0 in pval. To avoid spamming output, it fails silently.

Definition at line 600 of file fpix1.c.

References FPix::data, and fpixGetDimensions().

Referenced by fpixAddSlopeBorder(), and fpixaSetPixel().

◆ fpixSetResolution()

l_ok fpixSetResolution ( FPIX fpix,
l_int32  xres,
l_int32  yres 
)

fpixSetResolution()

Parameters
[in]fpix
[in]xres,yresx and y resolution
Returns
0 if OK, 1 on error

Definition at line 475 of file fpix1.c.

References FPix::xres, and FPix::yres.

Referenced by fpixCopyResolution(), and fpixReadStream().

◆ fpixSetWpl()

l_ok fpixSetWpl ( FPIX fpix,
l_int32  wpl 
)

fpixSetWpl()

Parameters
[in]fpix
[in]wpl
Returns
0 if OK, 1 on error

Definition at line 394 of file fpix1.c.

References FPix::wpl.

Referenced by fpixCreate().

◆ fpixWrite()

l_ok fpixWrite ( const char *  filename,
FPIX fpix 
)

fpixWrite()

Parameters
[in]filename
[in]fpix
Returns
0 if OK, 1 on error

Definition at line 1661 of file fpix1.c.

References fopenWriteStream(), and fpixWriteStream().

◆ fpixWriteMem()

l_ok fpixWriteMem ( l_uint8 **  pdata,
size_t *  psize,
FPIX fpix 
)

fpixWriteMem()

Parameters
[out]pdatadata of serialized fpix
[out]psizesize of returned data
[in]fpix
Returns
0 if OK, 1 on error
Notes:
     (1) Serializes a fpix in memory and puts the result in a buffer.

Definition at line 1739 of file fpix1.c.

References fopenWriteWinTempfile(), fpixWriteStream(), and l_binaryReadStream().

◆ fpixWriteStream()

l_ok fpixWriteStream ( FILE *  fp,
FPIX fpix 
)

fpixWriteStream()

Parameters
[in]fpfile stream opened for "wb"
[in]fpix
Returns
0 if OK, 1 on error

Definition at line 1692 of file fpix1.c.

References FPIX_VERSION_NUMBER, fpixDestroy(), fpixEndianByteSwap(), fpixGetData(), fpixGetDimensions(), and fpixGetResolution().

Referenced by dewarpWriteStream(), fpixWrite(), and fpixWriteMem().

Variable Documentation

◆ InitialPtrArraySize

const size_t InitialPtrArraySize = 20
static

n'importe quoi

Definition at line 133 of file fpix1.c.