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

Go to the source code of this file.

Functions

NUMAnumaArithOp (NUMA *nad, NUMA *na1, NUMA *na2, l_int32 op)
 
NUMAnumaLogicalOp (NUMA *nad, NUMA *na1, NUMA *na2, l_int32 op)
 
NUMAnumaInvert (NUMA *nad, NUMA *nas)
 
l_int32 numaSimilar (NUMA *na1, NUMA *na2, l_float32 maxdiff, l_int32 *psimilar)
 
l_ok numaAddToNumber (NUMA *na, l_int32 index, l_float32 val)
 
l_ok numaGetMin (NUMA *na, l_float32 *pminval, l_int32 *piminloc)
 
l_ok numaGetMax (NUMA *na, l_float32 *pmaxval, l_int32 *pimaxloc)
 
l_ok numaGetSum (NUMA *na, l_float32 *psum)
 
NUMAnumaGetPartialSums (NUMA *na)
 
l_ok numaGetSumOnInterval (NUMA *na, l_int32 first, l_int32 last, l_float32 *psum)
 
l_ok numaHasOnlyIntegers (NUMA *na, l_int32 *pallints)
 
l_ok numaGetMean (NUMA *na, l_float32 *pave)
 
l_ok numaGetMeanAbsval (NUMA *na, l_float32 *paveabs)
 
NUMAnumaSubsample (NUMA *nas, l_int32 subfactor)
 
NUMAnumaMakeDelta (NUMA *nas)
 
NUMAnumaMakeSequence (l_float32 startval, l_float32 increment, l_int32 size)
 
NUMAnumaMakeConstant (l_float32 val, l_int32 size)
 
NUMAnumaMakeAbsval (NUMA *nad, NUMA *nas)
 
NUMAnumaAddBorder (NUMA *nas, l_int32 left, l_int32 right, l_float32 val)
 
NUMAnumaAddSpecifiedBorder (NUMA *nas, l_int32 left, l_int32 right, l_int32 type)
 
NUMAnumaRemoveBorder (NUMA *nas, l_int32 left, l_int32 right)
 
l_ok numaCountNonzeroRuns (NUMA *na, l_int32 *pcount)
 
l_ok numaGetNonzeroRange (NUMA *na, l_float32 eps, l_int32 *pfirst, l_int32 *plast)
 
l_ok numaGetCountRelativeToZero (NUMA *na, l_int32 type, l_int32 *pcount)
 
NUMAnumaClipToInterval (NUMA *nas, l_int32 first, l_int32 last)
 
NUMAnumaMakeThresholdIndicator (NUMA *nas, l_float32 thresh, l_int32 type)
 
NUMAnumaUniformSampling (NUMA *nas, l_int32 nsamp)
 
NUMAnumaReverse (NUMA *nad, NUMA *nas)
 
NUMAnumaLowPassIntervals (NUMA *nas, l_float32 thresh, l_float32 maxn)
 
NUMAnumaThresholdEdges (NUMA *nas, l_float32 thresh1, l_float32 thresh2, l_float32 maxn)
 
l_int32 numaGetSpanValues (NUMA *na, l_int32 span, l_int32 *pstart, l_int32 *pend)
 
l_int32 numaGetEdgeValues (NUMA *na, l_int32 edge, l_int32 *pstart, l_int32 *pend, l_int32 *psign)
 
l_ok numaInterpolateEqxVal (l_float32 startx, l_float32 deltax, NUMA *nay, l_int32 type, l_float32 xval, l_float32 *pyval)
 
l_ok numaInterpolateArbxVal (NUMA *nax, NUMA *nay, l_int32 type, l_float32 xval, l_float32 *pyval)
 
l_ok numaInterpolateEqxInterval (l_float32 startx, l_float32 deltax, NUMA *nasy, l_int32 type, l_float32 x0, l_float32 x1, l_int32 npts, NUMA **pnax, NUMA **pnay)
 
l_ok numaInterpolateArbxInterval (NUMA *nax, NUMA *nay, l_int32 type, l_float32 x0, l_float32 x1, l_int32 npts, NUMA **pnadx, NUMA **pnady)
 
l_ok numaFitMax (NUMA *na, l_float32 *pmaxval, NUMA *naloc, l_float32 *pmaxloc)
 
l_ok numaDifferentiateInterval (NUMA *nax, NUMA *nay, l_float32 x0, l_float32 x1, l_int32 npts, NUMA **pnadx, NUMA **pnady)
 
l_ok numaIntegrateInterval (NUMA *nax, NUMA *nay, l_float32 x0, l_float32 x1, l_int32 npts, l_float32 *psum)
 
l_ok numaSortGeneral (NUMA *na, NUMA **pnasort, NUMA **pnaindex, NUMA **pnainvert, l_int32 sortorder, l_int32 sorttype)
 
NUMAnumaSortAutoSelect (NUMA *nas, l_int32 sortorder)
 
NUMAnumaSortIndexAutoSelect (NUMA *nas, l_int32 sortorder)
 
l_int32 numaChooseSortType (NUMA *nas)
 
NUMAnumaSort (NUMA *naout, NUMA *nain, l_int32 sortorder)
 
NUMAnumaBinSort (NUMA *nas, l_int32 sortorder)
 
NUMAnumaGetSortIndex (NUMA *na, l_int32 sortorder)
 
NUMAnumaGetBinSortIndex (NUMA *nas, l_int32 sortorder)
 
NUMAnumaSortByIndex (NUMA *nas, NUMA *naindex)
 
l_int32 numaIsSorted (NUMA *nas, l_int32 sortorder, l_int32 *psorted)
 
l_ok numaSortPair (NUMA *nax, NUMA *nay, l_int32 sortorder, NUMA **pnasx, NUMA **pnasy)
 
NUMAnumaInvertMap (NUMA *nas)
 
l_ok numaAddSorted (NUMA *na, l_float32 val)
 
l_ok numaFindSortedLoc (NUMA *na, l_float32 val, l_int32 *pindex)
 
NUMAnumaPseudorandomSequence (l_int32 size, l_int32 seed)
 
NUMAnumaRandomPermutation (NUMA *nas, l_int32 seed)
 
l_ok numaGetRankValue (NUMA *na, l_float32 fract, NUMA *nasort, l_int32 usebins, l_float32 *pval)
 
l_ok numaGetMedian (NUMA *na, l_float32 *pval)
 
l_ok numaGetBinnedMedian (NUMA *na, l_int32 *pval)
 
l_ok numaGetMeanDevFromMedian (NUMA *na, l_float32 med, l_float32 *pdev)
 
l_ok numaGetMedianDevFromMedian (NUMA *na, l_float32 *pmed, l_float32 *pdev)
 
l_ok numaGetMode (NUMA *na, l_float32 *pval, l_int32 *pcount)
 
l_ok numaJoin (NUMA *nad, NUMA *nas, l_int32 istart, l_int32 iend)
 
l_ok numaaJoin (NUMAA *naad, NUMAA *naas, l_int32 istart, l_int32 iend)
 
NUMAnumaaFlattenToNuma (NUMAA *naa)
 

Detailed Description


     --------------------------------------
     This file has these Numa utilities:

Definition in file numafunc1.c.

Function Documentation

◆ numaAddBorder()

NUMA* numaAddBorder ( NUMA nas,
l_int32  left,
l_int32  right,
l_float32  val 
)

numaAddBorder()

Parameters
[in]nas
[in]leftnumber of elements to add before the start
[in]rightnumber of elements to add after the end
[in]valinitialize border elements
Returns
nad with added elements at left and right, or NULL on error

Definition at line 902 of file numafunc1.c.

References L_NOCOPY, numaCopy(), numaGetCount(), numaGetFArray(), numaGetParameters(), numaMakeConstant(), and numaSetParameters().

Referenced by numaAddSpecifiedBorder(), and numaClose().

◆ numaAddSorted()

l_ok numaAddSorted ( NUMA na,
l_float32  val 
)

numaAddSorted()

Parameters
[in]nasorted input
[in]valvalue to be inserted in sorted order
Returns
0 if OK, 1 on error
Notes:
     (1) The input na is sorted.  This function determines the
         sort order of na and inserts val into the array.

Definition at line 3124 of file numafunc1.c.

References numaFindSortedLoc(), and numaInsertNumber().

◆ numaAddSpecifiedBorder()

NUMA* numaAddSpecifiedBorder ( NUMA nas,
l_int32  left,
l_int32  right,
l_int32  type 
)

numaAddSpecifiedBorder()

Parameters
[in]nas
[in]leftnumber of elements to add before the start
[in]rightnumber of elements to add after the end
[in]typeL_CONTINUED_BORDER, L_MIRRORED_BORDER
Returns
nad with added elements at left and right, or NULL on error

Definition at line 945 of file numafunc1.c.

References L_CONTINUED_BORDER, L_MIRRORED_BORDER, L_NOCOPY, numaAddBorder(), numaCopy(), numaGetCount(), and numaGetFArray().

Referenced by numaWindowedMean(), numaWindowedMeanSquare(), and numaWindowedMedian().

◆ numaAddToNumber()

l_ok numaAddToNumber ( NUMA na,
l_int32  index,
l_float32  val 
)

numaAddToNumber()

Parameters
[in]nasource numa
[in]indexelement to be changed
[in]valnew value to be added
Returns
0 if OK, 1 on error
Notes:
     (1) This is useful for accumulating sums, regardless of the index
         order in which the values are made available.
     (2) Before use, the numa has to be filled up to index.  This would
         typically be used by creating the numa with the full sized
         array, initialized to 0.0, using numaMakeConstant().

Definition at line 419 of file numafunc1.c.

References Numa::array, and numaGetCount().

◆ numaaFlattenToNuma()

NUMA* numaaFlattenToNuma ( NUMAA naa)

numaaFlattenToNuma()

Parameters
[in]naa
Returns
numa, or NULL on error
Notes:
     (1) This 'flattens' the Numaa to a Numa, by joining successively
         each Numa in the Numaa.
     (2) It doesn't make any assumptions about the location of the
         Numas in the Numaa array, unlike most Numaa functions.
     (3) It leaves the input Numaa unchanged.

Definition at line 3737 of file numafunc1.c.

References Numaa::nalloc, numaaGetPtrArray(), numaCreate(), and numaJoin().

◆ numaaJoin()

l_ok numaaJoin ( NUMAA naad,
NUMAA naas,
l_int32  istart,
l_int32  iend 
)

numaaJoin()

Parameters
[in]naaddest naa; add to this one
[in]naas[optional] source naa; add from this one
[in]istartstarting index in nas
[in]iendending index in naas; use -1 to cat all
Returns
0 if OK, 1 on error
Notes:
     (1) istart < 0 is taken to mean 'read from the start' (istart = 0)
     (2) iend < 0 means 'read to the end'
     (3) if naas == NULL, this is a no-op

Definition at line 3689 of file numafunc1.c.

References L_CLONE, L_INSERT, numaaAddNuma(), numaaGetCount(), and numaaGetNuma().

◆ numaArithOp()

NUMA* numaArithOp ( NUMA nad,
NUMA na1,
NUMA na2,
l_int32  op 
)

numaArithOp()

Parameters
[in]nad[optional] can be null or equal to na1 (in-place
[in]na1
[in]na2
[in]opL_ARITH_ADD, L_ARITH_SUBTRACT, L_ARITH_MULTIPLY, L_ARITH_DIVIDE
Returns
nad always: operation applied to na1 and na2
Notes:
     (1) The sizes of na1 and na2 must be equal.
     (2) nad can only null or equal to na1.
     (3) To add a constant to a numa, or to multiply a numa by
         a constant, use numaTransform().

Definition at line 173 of file numafunc1.c.

References numaGetCount().

◆ numaBinSort()

NUMA* numaBinSort ( NUMA nas,
l_int32  sortorder 
)

numaBinSort()

Parameters
[in]nasof non-negative integers with a max that can not exceed (MaxInitPtraSize - 1)
[in]sortorderL_SORT_INCREASING or L_SORT_DECREASING
Returns
na sorted, or NULL on error
Notes:
     (1) Because this uses a bin sort with buckets of size 1, it
         is not appropriate for sorting either small arrays or
         arrays containing very large integer values.  For such
         arrays, use a standard general sort function like
         numaSort().
     (2) You can use numaSortAutoSelect() to decide which sorting
         method to use.

Definition at line 2718 of file numafunc1.c.

References L_SORT_DECREASING, L_SORT_INCREASING, numaCopy(), numaDestroy(), numaGetBinSortIndex(), numaGetCount(), and numaSortByIndex().

Referenced by numaGetRankValue(), and numaSortAutoSelect().

◆ numaChooseSortType()

l_int32 numaChooseSortType ( NUMA nas)

numaChooseSortType()

Parameters
[in]nasto be sorted
Returns
sorttype L_SHELL_SORT or L_BIN_SORT, or UNDEF on error.
Notes:
     (1) This selects either a shell sort or a bin sort, depending on
         the number of elements in nas and the dynamic range.
     (2) If there are negative values in nas, it selects shell sort.

Definition at line 2602 of file numafunc1.c.

References L_SHELL_SORT, numaGetCount(), numaGetMax(), and numaGetMin().

Referenced by numaGetRankBinValues(), numaSortAutoSelect(), and numaSortIndexAutoSelect().

◆ numaClipToInterval()

NUMA* numaClipToInterval ( NUMA nas,
l_int32  first,
l_int32  last 
)

numaClipToInterval()

Parameters
[in]nas
[in]first>= 0; <= last
[in]last
Returns
numa with the same values as the input, but clipped to the specified interval
Notes:
       If you want the indices of the array values to be unchanged,
       use first = 0.
 Usage:
       This is useful to clip a histogram that has a few nonzero
       values to its nonzero range.

Definition at line 1182 of file numafunc1.c.

References numaAddNumber(), numaCreate(), numaGetCount(), numaGetFValue(), numaGetParameters(), and numaSetParameters().

Referenced by numaWindowedMedian(), and pixGetDifferenceStats().

◆ numaCountNonzeroRuns()

l_ok numaCountNonzeroRuns ( NUMA na,
l_int32 *  pcount 
)

numaCountNonzeroRuns()

Parameters
[in]nae.g., of pixel counts in rows or columns
[out]pcountnumber of nonzero runs
Returns
0 if OK, 1 on error

Definition at line 1037 of file numafunc1.c.

References numaGetCount(), and numaGetIValue().

◆ numaDifferentiateInterval()

l_ok numaDifferentiateInterval ( NUMA nax,
NUMA nay,
l_float32  x0,
l_float32  x1,
l_int32  npts,
NUMA **  pnadx,
NUMA **  pnady 
)

numaDifferentiateInterval()

Parameters
[in]naxnuma of abscissa values
[in]naynuma of ordinate values, corresponding to nax
[in]x0start value of interval
[in]x1end value of interval
[in]nptsnumber of points to evaluate function in interval
[out]pnadx[optional] array of x values in interval
[out]pnadyarray of derivatives in interval
Returns
0 if OK, 1 on error e.g., if x0 or x1 is outside range
Notes:
     (1) The values in nax must be sorted in increasing order.
         If they are not sorted, it is done in the interpolation
         step, and a warning is issued.
     (2) Caller should check for valid return.

Definition at line 2268 of file numafunc1.c.

References L_LINEAR_INTERP, L_NOCOPY, numaAddNumber(), numaCreate(), numaDestroy(), numaGetCount(), numaGetFArray(), numaGetMax(), numaGetMin(), and numaInterpolateArbxInterval().

◆ numaFindSortedLoc()

l_ok numaFindSortedLoc ( NUMA na,
l_float32  val,
l_int32 *  pindex 
)

numaFindSortedLoc()

Parameters
[in]nasorted input
[in]valvalue to be inserted in sorted order
[out]*plocindex location to insert @val
Returns
0 if OK, 1 on error
Notes:
     (1) The input na is sorted.  This determines the sort order of @na,
         either increasing or decreasing, and does a binary search for the
         location to insert val into the array.  The search is O(log n).
     (2) The index returned is the location to insert into the array.
         The value at the index, and all values to the right, are
         moved to the right (increasing their index location by 1).
     (3) If n is the size of na, *ploc can be anything in [0 ... n].
         if *ploc == 0, the value is inserted at the beginning of the
         array; if *ploc == n, it is inserted at the end.
     (4) If the size of na is 1, insert with an increasing sort.

Definition at line 3164 of file numafunc1.c.

References numaGetCount(), and numaGetFValue().

Referenced by numaAddSorted().

◆ numaFitMax()

l_ok numaFitMax ( NUMA na,
l_float32 *  pmaxval,
NUMA naloc,
l_float32 *  pmaxloc 
)

numaFitMax()

Parameters
[in]nanuma of ordinate values, to fit a max to
[out]pmaxvalmax value
[in]naloc[optional] associated numa of abscissa values
[out]pmaxlocabscissa value that gives max value in na; if naloc == null, this is given as an interpolated index value
Returns
0 if OK; 1 on error
Notes:
       If naloc is given, there is no requirement that the
       data points are evenly spaced.  Lagrangian interpolation
       handles that.  The only requirement is that the
       data points are ordered so that the values in naloc
       are either increasing or decreasing.  We test to make
       sure that the sizes of na and naloc are equal, and it
       is assumed that the correspondences na[i] as a function
       of naloc[i] are properly arranged for all i.

 The formula for Lagrangian interpolation through 3 data pts is:
      y(x) = y1(x-x2)(x-x3)/((x1-x2)(x1-x3)) +
             y2(x-x1)(x-x3)/((x2-x1)(x2-x3)) +
             y3(x-x1)(x-x2)/((x3-x1)(x3-x2))

 Then the derivative, using the constants (c1,c2,c3) defined below,
 is set to 0:
      y'(x) = 2x(c1+c2+c3) - c1(x2+x3) - c2(x1+x3) - c3(x1+x2) = 0

Definition at line 2162 of file numafunc1.c.

References numaGetCount(), numaGetFValue(), and numaGetMax().

◆ numaGetBinnedMedian()

l_ok numaGetBinnedMedian ( NUMA na,
l_int32 *  pval 
)

numaGetBinnedMedian()

Parameters
[in]nasource numa
[out]pvalinteger median value
Returns
0 if OK; 1 on error
Notes:
     (1) Computes the median value of the numbers in the numa,
         using bin sort and finding the middle value in the sorted array.
     (2) See numaGetRankValue() for conditions on na for which
         this should be used.  Otherwise, use numaGetMedian().

Definition at line 3436 of file numafunc1.c.

References lept_roundftoi(), numaGetCount(), and numaGetRankValue().

◆ numaGetBinSortIndex()

NUMA* numaGetBinSortIndex ( NUMA nas,
l_int32  sortorder 
)

numaGetBinSortIndex()

Parameters
[in]nasof non-negative integers with a max that can not exceed (MaxInitPtraSize - 1)
[in]sortorderL_SORT_INCREASING or L_SORT_DECREASING
Returns
na sorted, or NULL on error
Notes:
     (1) This creates an array (or lookup table) that contains
         the sorted position of the elements in the input Numa.
     (2) Because it uses a bin sort with buckets of size 1, it
         is not appropriate for sorting either small arrays or
         arrays containing very large integer values.  For such
         arrays, use a standard general sort function like
         numaGetSortIndex().
     (3) You can use numaSortIndexAutoSelect() to decide which
         sorting method to use.

Definition at line 2833 of file numafunc1.c.

References L_SORT_DECREASING, L_SORT_INCREASING, numaCreate(), numaGetCount(), numaGetMax(), and numaGetMin().

Referenced by boxaBinSort(), numaBinSort(), numaSortIndexAutoSelect(), and pixaBinSort().

◆ numaGetCountRelativeToZero()

l_ok numaGetCountRelativeToZero ( NUMA na,
l_int32  type,
l_int32 *  pcount 
)

numaGetCountRelativeToZero()

Parameters
[in]nasource numa
[in]typeL_LESS_THAN_ZERO, L_EQUAL_TO_ZERO, L_GREATER_THAN_ZERO
[out]pcountcount of values of given type
Returns
0 if OK, 1 on error

Definition at line 1131 of file numafunc1.c.

References L_EQUAL_TO_ZERO, L_GREATER_THAN_ZERO, L_LESS_THAN_ZERO, numaGetCount(), and numaGetFValue().

◆ numaGetEdgeValues()

l_int32 numaGetEdgeValues ( NUMA na,
l_int32  edge,
l_int32 *  pstart,
l_int32 *  pend,
l_int32 *  psign 
)

numaGetEdgeValues()

Parameters
[in]nanuma that is output of numaThresholdEdges()
[in]edgeedge number, zero-based
[out]pstart[optional] location of start of transition
[out]pend[optional] location of end of transition
[out]psign[optional] transition sign: +1 is rising, -1 is falling
Returns
0 if OK, 1 on error

Definition at line 1645 of file numafunc1.c.

References numaGetCount(), and numaGetIValue().

◆ numaGetMax()

◆ numaGetMean()

l_ok numaGetMean ( NUMA na,
l_float32 *  pave 
)

numaGetMean()

Parameters
[in]nasource numa
[out]paveaverage of values
Returns
0 if OK, 1 on error

Definition at line 691 of file numafunc1.c.

References numaGetCount(), and numaGetSum().

Referenced by numaGetMeanAbsval().

◆ numaGetMeanAbsval()

l_ok numaGetMeanAbsval ( NUMA na,
l_float32 *  paveabs 
)

numaGetMeanAbsval()

Parameters
[in]nasource numa
[out]paveabsaverage of absolute values
Returns
0 if OK, 1 on error

Definition at line 720 of file numafunc1.c.

References numaDestroy(), numaGetCount(), numaGetMean(), and numaMakeAbsval().

◆ numaGetMeanDevFromMedian()

l_ok numaGetMeanDevFromMedian ( NUMA na,
l_float32  med,
l_float32 *  pdev 
)

numaGetMeanDevFromMedian()

Parameters
[in]nasource numa
[in]medmedian value
[out]pdevaverage absolute value deviation from median value
Returns
0 if OK; 1 on error

Definition at line 3465 of file numafunc1.c.

References numaGetCount(), and numaGetFValue().

Referenced by boxaSizeConsistency().

◆ numaGetMedian()

l_ok numaGetMedian ( NUMA na,
l_float32 *  pval 
)

numaGetMedian()

Parameters
[in]nasource numa
[out]pvalmedian value
Returns
0 if OK; 1 on error
Notes:
     (1) Computes the median value of the numbers in the numa, by
         sorting and finding the middle value in the sorted array.

Definition at line 3405 of file numafunc1.c.

References numaGetCount(), and numaGetRankValue().

Referenced by boxaSizeConsistency(), dewarpLinearLSF(), dewarpQuadraticLSF(), numaGetMedianDevFromMedian(), numaWindowedMedian(), ptaNoisyLinearLSF(), and ptaNoisyQuadraticLSF().

◆ numaGetMedianDevFromMedian()

l_ok numaGetMedianDevFromMedian ( NUMA na,
l_float32 *  pmed,
l_float32 *  pdev 
)

numaGetMedianDevFromMedian()

Parameters
[in]nasource numa
[out]pmed[optional] median value
[out]pdevmedian deviation from median val
Returns
0 if OK; 1 on error
Notes:
     (1) Finds the median of the absolute value of the deviation from
         the median value in the array.  Why take the absolute value?
         Consider the case where you have values equally distributed
         about both sides of a median value.  Without taking the absolute
         value of the differences, you will get 0 for the deviation,
         and this is not useful.

Definition at line 3511 of file numafunc1.c.

References numaAddNumber(), numaCreate(), numaDestroy(), numaGetCount(), numaGetFValue(), and numaGetMedian().

◆ numaGetMin()

l_ok numaGetMin ( NUMA na,
l_float32 *  pminval,
l_int32 *  piminloc 
)

numaGetMin()

Parameters
[in]nasource numa
[out]pminval[optional] min value
[out]piminloc[optional] index of min location
Returns
0 if OK; 1 on error

Definition at line 453 of file numafunc1.c.

References numaGetCount(), and numaGetFValue().

Referenced by makePlotPtaFromNumaGen(), numaChooseSortType(), numaDifferentiateInterval(), numaGetBinSortIndex(), numaGetStatsUsingHistogram(), numaIntegrateInterval(), numaInterpolateArbxInterval(), numaMakeHistogram(), numaMakeHistogramAuto(), and recogIsPaddingNeeded().

◆ numaGetMode()

l_ok numaGetMode ( NUMA na,
l_float32 *  pval,
l_int32 *  pcount 
)

numaGetMode()

Parameters
[in]nasource numa
[out]pvalmode val
[out]pcount[optional] mode count
Returns
0 if OK; 1 on error
Notes:
     (1) Computes the mode value of the numbers in the numa, by
         sorting and finding the value of the number with the
         largest count.
     (2) Optionally, also returns that count.

Definition at line 3560 of file numafunc1.c.

References L_NOCOPY, L_SORT_DECREASING, numaDestroy(), numaGetCount(), numaGetFArray(), and numaSort().

Referenced by numaSelectCrossingThreshold().

◆ numaGetNonzeroRange()

l_ok numaGetNonzeroRange ( NUMA na,
l_float32  eps,
l_int32 *  pfirst,
l_int32 *  plast 
)

numaGetNonzeroRange()

Parameters
[in]nasource numa
[in]epslargest value considered to be zero
[out]pfirst,plastinterval of array indices where values are nonzero
Returns
0 if OK, 1 on error or if no nonzero range is found.

Definition at line 1078 of file numafunc1.c.

References numaGetCount(), and numaGetFValue().

Referenced by pixGetDifferenceStats().

◆ numaGetPartialSums()

NUMA* numaGetPartialSums ( NUMA na)

numaGetPartialSums()

Parameters
[in]nasource numa
Returns
nasum, or NULL on error
Notes:
     (1) nasum[i] is the sum for all j <= i of na[j].
         So nasum[0] = na[0].
     (2) If you want to generate a rank function, where rank[0] - 0.0,
         insert a 0.0 at the beginning of the nasum array.

Definition at line 579 of file numafunc1.c.

References numaAddNumber(), numaCreate(), numaGetCount(), and numaGetFValue().

Referenced by numaDiscretizeHistoInBins().

◆ numaGetRankValue()

l_ok numaGetRankValue ( NUMA na,
l_float32  fract,
NUMA nasort,
l_int32  usebins,
l_float32 *  pval 
)

numaGetRankValue()

Parameters
[in]nasource numa
[in]fractuse 0.0 for smallest, 1.0 for largest
[in]nasort[optional] increasing sorted version of na
[in]usebins0 for general sort; 1 for bin sort
[out]pvalrank val
Returns
0 if OK; 1 on error
Notes:
     (1) Computes the rank value of a number in the na, which is
         the number that is a fraction fract from the small
         end of the sorted version of na.
     (2) If you do this multiple times for different rank values,
         sort the array in advance and use that for nasort;
         if you're only calling this once, input nasort == NULL.
     (3) If usebins == 1, this uses a bin sorting method.
         Use this only where:
          * the numbers are non-negative integers
          * there are over 100 numbers
          * the maximum value is less than about 50,000
     (4) The advantage of using a bin sort is that it is O(n),
         instead of O(nlogn) for general sort routines.

Definition at line 3352 of file numafunc1.c.

References L_SORT_INCREASING, numaBinSort(), numaDestroy(), numaGetCount(), numaGetFValue(), and numaSort().

Referenced by boxaGetRankVals(), numaGetBinnedMedian(), and numaGetMedian().

◆ numaGetSortIndex()

NUMA* numaGetSortIndex ( NUMA na,
l_int32  sortorder 
)

numaGetSortIndex()

Parameters
[in]nasource numa
[in]sortorderL_SORT_INCREASING or L_SORT_DECREASING
Returns
na giving an array of indices that would sort the input array, or NULL on error

Definition at line 2751 of file numafunc1.c.

References L_COPY, L_SORT_DECREASING, L_SORT_INCREASING, numaAddNumber(), numaCreate(), numaGetCount(), and numaGetFArray().

Referenced by numaSortIndexAutoSelect(), numaSortPair(), pixcmapGetRankIntensity(), and ptaGetSortIndex().

◆ numaGetSpanValues()

l_int32 numaGetSpanValues ( NUMA na,
l_int32  span,
l_int32 *  pstart,
l_int32 *  pend 
)

numaGetSpanValues()

Parameters
[in]nanuma that is output of numaLowPassIntervals()
[in]spanspan number, zero-based
[out]pstart[optional] location of start of transition
[out]pend[optional] location of end of transition
Returns
0 if OK, 1 on error

Definition at line 1608 of file numafunc1.c.

References numaGetCount(), and numaGetIValue().

◆ numaGetSum()

l_ok numaGetSum ( NUMA na,
l_float32 *  psum 
)

◆ numaGetSumOnInterval()

l_ok numaGetSumOnInterval ( NUMA na,
l_int32  first,
l_int32  last,
l_float32 *  psum 
)

numaGetSumOnInterval()

Parameters
[in]nasource numa
[in]firstbeginning index
[in]lastfinal index; use -1 to go to the end
[out]psumsum of values in the index interval range
Returns
0 if OK, 1 on error

Definition at line 613 of file numafunc1.c.

References numaGetCount(), and numaGetFValue().

Referenced by numaFindLocForThreshold().

◆ numaHasOnlyIntegers()

l_ok numaHasOnlyIntegers ( NUMA na,
l_int32 *  pallints 
)

numaHasOnlyIntegers()

Parameters
[in]nasource numa
[out]pallints1 if all sampled values are ints; else 0
Returns
0 if OK, 1 on error

Definition at line 656 of file numafunc1.c.

References numaGetCount(), and numaGetFValue().

Referenced by numaMakeHistogramAuto().

◆ numaIntegrateInterval()

l_ok numaIntegrateInterval ( NUMA nax,
NUMA nay,
l_float32  x0,
l_float32  x1,
l_int32  npts,
l_float32 *  psum 
)

numaIntegrateInterval()

Parameters
[in]naxnuma of abscissa values
[in]naynuma of ordinate values, corresponding to nax
[in]x0start value of interval
[in]x1end value of interval
[in]nptsnumber of points to evaluate function in interval
[out]psumintegral of function over interval
Returns
0 if OK, 1 on error e.g., if x0 or x1 is outside range
Notes:
     (1) The values in nax must be sorted in increasing order.
         If they are not sorted, it is done in the interpolation
         step, and a warning is issued.
     (2) Caller should check for valid return.

Definition at line 2351 of file numafunc1.c.

References L_LINEAR_INTERP, L_NOCOPY, numaDestroy(), numaGetCount(), numaGetFArray(), numaGetMax(), numaGetMin(), and numaInterpolateArbxInterval().

◆ numaInterpolateArbxInterval()

l_ok numaInterpolateArbxInterval ( NUMA nax,
NUMA nay,
l_int32  type,
l_float32  x0,
l_float32  x1,
l_int32  npts,
NUMA **  pnadx,
NUMA **  pnady 
)

numaInterpolateArbxInterval()

Parameters
[in]naxnuma of abscissa values
[in]naynuma of ordinate values, corresponding to nax
[in]typeL_LINEAR_INTERP, L_QUADRATIC_INTERP
[in]x0start value of interval
[in]x1end value of interval
[in]nptsnumber of points to evaluate function in interval
[out]pnadx[optional] array of x values in interval
[out]pnadyarray of y values in interval
Returns
0 if OK, 1 on error e.g., if x0 or x1 is outside range
Notes:
     (1) The values in nax must be sorted in increasing order.
         If they are not sorted, we do it here, and complain.
     (2) If the values in nax are equally spaced, you can use
         numaInterpolateEqxInterval().
     (3) Caller should check for valid return.
     (4) We don't call numaInterpolateArbxVal() for each output
         point, because that requires an O(n) search for
         each point.  Instead, we do a single O(n) pass through
         nax, saving the indices to be used for each output yval.
     (5) Uses lagrangian interpolation.  See numaInterpolateEqxVal()
         for formulas.

Definition at line 2001 of file numafunc1.c.

References L_LINEAR_INTERP, L_NOCOPY, L_QUADRATIC_INTERP, L_SORT_INCREASING, numaAddNumber(), numaClone(), numaCreate(), numaDestroy(), numaGetCount(), numaGetFArray(), numaGetMax(), numaGetMin(), numaIsSorted(), and numaSortPair().

Referenced by numaDifferentiateInterval(), and numaIntegrateInterval().

◆ numaInterpolateArbxVal()

l_ok numaInterpolateArbxVal ( NUMA nax,
NUMA nay,
l_int32  type,
l_float32  xval,
l_float32 *  pyval 
)

numaInterpolateArbxVal()

Parameters
[in]naxnuma of abscissa values
[in]naynuma of ordinate values, corresponding to nax
[in]typeL_LINEAR_INTERP, L_QUADRATIC_INTERP
[in]xval
[out]pyvalinterpolated value
Returns
0 if OK, 1 on error e.g., if xval is outside range
Notes:
     (1) The values in nax must be sorted in increasing order.
         If, additionally, they are equally spaced, you can use
         numaInterpolateEqxVal().
     (2) Caller should check for valid return.
     (3) Uses lagrangian interpolation.  See numaInterpolateEqxVal()
         for formulas.

Definition at line 1795 of file numafunc1.c.

References L_LINEAR_INTERP, L_NOCOPY, L_QUADRATIC_INTERP, numaGetCount(), numaGetFArray(), and numaGetFValue().

◆ numaInterpolateEqxInterval()

l_ok numaInterpolateEqxInterval ( l_float32  startx,
l_float32  deltax,
NUMA nasy,
l_int32  type,
l_float32  x0,
l_float32  x1,
l_int32  npts,
NUMA **  pnax,
NUMA **  pnay 
)

numaInterpolateEqxInterval()

Parameters
[in]startxxval corresponding to first element in nas
[in]deltaxx increment between array elements in nas
[in]nasynuma of ordinate values, assumed equally spaced
[in]typeL_LINEAR_INTERP, L_QUADRATIC_INTERP
[in]x0start value of interval
[in]x1end value of interval
[in]nptsnumber of points to evaluate function in interval
[out]pnax[optional] array of x values in interval
[out]pnayarray of y values in interval
Returns
0 if OK, 1 on error
Notes:
     (1) Considering nasy as a function of x, the x values
         are equally spaced.
     (2) This creates nay (and optionally nax) of interpolated
         values over the specified interval (x0, x1).
     (3) If the interval (x0, x1) lies partially outside the array
         nasy (as interpreted by startx and deltax), it is an
         error and returns 1.
     (4) Note that deltax is the intrinsic x-increment for the input
         array nasy, whereas delx is the intrinsic x-increment for the
         output interpolated array nay.

Definition at line 1912 of file numafunc1.c.

References L_LINEAR_INTERP, L_QUADRATIC_INTERP, numaAddNumber(), numaCreate(), numaGetCount(), numaInterpolateEqxVal(), and numaSetParameters().

Referenced by numaMakeRankFromHistogram().

◆ numaInterpolateEqxVal()

l_ok numaInterpolateEqxVal ( l_float32  startx,
l_float32  deltax,
NUMA nay,
l_int32  type,
l_float32  xval,
l_float32 *  pyval 
)

numaInterpolateEqxVal()

Parameters
[in]startxxval corresponding to first element in array
[in]deltaxx increment between array elements
[in]naynuma of ordinate values, assumed equally spaced
[in]typeL_LINEAR_INTERP, L_QUADRATIC_INTERP
[in]xval
[out]pyvalinterpolated value
Returns
0 if OK, 1 on error e.g., if xval is outside range
Notes:
     (1) Considering nay as a function of x, the x values
         are equally spaced
     (2) Caller should check for valid return.

 For linear Lagrangian interpolation (through 2 data pts):
        y(x) = y1(x-x2)/(x1-x2) + y2(x-x1)/(x2-x1)

 For quadratic Lagrangian interpolation (through 3 data pts):
        y(x) = y1(x-x2)(x-x3)/((x1-x2)(x1-x3)) +
               y2(x-x1)(x-x3)/((x2-x1)(x2-x3)) +
               y3(x-x1)(x-x2)/((x3-x1)(x3-x2))

Definition at line 1703 of file numafunc1.c.

References L_LINEAR_INTERP, L_NOCOPY, L_QUADRATIC_INTERP, numaGetCount(), and numaGetFArray().

Referenced by numaInterpolateEqxInterval().

◆ numaInvert()

NUMA* numaInvert ( NUMA nad,
NUMA nas 
)

numaInvert()

Parameters
[in]nad[optional] can be null or equal to nas (in-place
[in]nas
Returns
nad always: 'inverts' nas
Notes:
     (1) This is intended for use with indicator arrays (0s and 1s).
         It gives a boolean-type output, taking the input as
         an integer and inverting it:
             0              -->  1
             anything else  -->   0

Definition at line 326 of file numafunc1.c.

References numaCopy(), numaGetCount(), numaGetIValue(), and numaSetValue().

◆ numaInvertMap()

NUMA* numaInvertMap ( NUMA nas)

numaInvertMap()

Parameters
[in]nas
Returns
nad the inverted map, or NULL on error or if not invertible
Notes:
     (1) This requires that nas contain each integer from 0 to n-1.
         The array is typically an index array into a sort or permutation
         of another array.

Definition at line 3068 of file numafunc1.c.

References numaCopy(), numaDestroy(), numaGetCount(), numaGetIValue(), numaMakeConstant(), and numaReplaceNumber().

◆ numaIsSorted()

l_int32 numaIsSorted ( NUMA nas,
l_int32  sortorder,
l_int32 *  psorted 
)

numaIsSorted()

Parameters
[in]nas
[in]sortorderL_SORT_INCREASING or L_SORT_DECREASING
[out]psorted1 if sorted; 0 if not
Returns
1 if OK; 0 on error
Notes:
     (1) This is a quick O(n) test if nas is sorted.  It is useful
         in situations where the array is likely to be already
         sorted, and a sort operation can be avoided.

Definition at line 2965 of file numafunc1.c.

References L_SORT_DECREASING, L_SORT_INCREASING, numaGetCount(), and numaGetFValue().

Referenced by numaInterpolateArbxInterval(), and numaSortPair().

◆ numaJoin()

l_ok numaJoin ( NUMA nad,
NUMA nas,
l_int32  istart,
l_int32  iend 
)

numaJoin()

Parameters
[in]naddest numa; add to this one
[in]nas[optional] source numa; add from this one
[in]istartstarting index in nas
[in]iendending index in nas; use -1 to cat all
Returns
0 if OK, 1 on error
Notes:
     (1) istart < 0 is taken to mean 'read from the start' (istart = 0)
     (2) iend < 0 means 'read to the end'
     (3) if nas == NULL, this is a no-op

Definition at line 3640 of file numafunc1.c.

References numaAddNumber(), numaGetCount(), and numaGetFValue().

Referenced by boxaSort2d(), mergeLookup(), numaaFlattenToNuma(), and numaGetCrossingDistances().

◆ numaLogicalOp()

NUMA* numaLogicalOp ( NUMA nad,
NUMA na1,
NUMA na2,
l_int32  op 
)

numaLogicalOp()

Parameters
[in]nad[optional] can be null or equal to na1 (in-place
[in]na1
[in]na2
[in]opL_UNION, L_INTERSECTION, L_SUBTRACTION, L_EXCLUSIVE_OR
Returns
nad always: operation applied to na1 and na2
Notes:
     (1) The sizes of na1 and na2 must be equal.
     (2) nad can only be null or equal to na1.
     (3) This is intended for use with indicator arrays (0s and 1s).
         Input data is extracted as integers (0 == false, anything
         else == true); output results are 0 and 1.
     (4) L_SUBTRACTION is subtraction of val2 from val1.  For bit logical
         arithmetic this is (val1 & ~val2), but because these values
         are integers, we use (val1 && !val2).

Definition at line 253 of file numafunc1.c.

References numaGetCount().

Referenced by recogPreSplittingFilter().

◆ numaLowPassIntervals()

NUMA* numaLowPassIntervals ( NUMA nas,
l_float32  thresh,
l_float32  maxn 
)

numaLowPassIntervals()

Parameters
[in]nasinput numa
[in]threshthreshold fraction of max; in [0.0 ... 1.0]
[in]maxnfor normalizing; set maxn = 0.0 to use the max in nas
Returns
nad : interval abscissa pairs, or NULL on error
Notes:
     (1) For each interval where the value is less than a specified
         fraction of the maximum, this records the left and right "x"
         value.

Definition at line 1410 of file numafunc1.c.

References numaAddNumber(), numaCreate(), numaGetCount(), numaGetFValue(), numaGetMax(), and numaGetParameters().

◆ numaMakeAbsval()

NUMA* numaMakeAbsval ( NUMA nad,
NUMA nas 
)

numaMakeAbsval()

Parameters
[in]nadcan be null for new array, or the same as nas for inplace
[in]nasinput numa
Returns
nad with all numbers being the absval of the input, or NULL on error

Definition at line 867 of file numafunc1.c.

References Numa::array, numaCopy(), and numaGetCount().

Referenced by numaGetMeanAbsval().

◆ numaMakeConstant()

NUMA* numaMakeConstant ( l_float32  val,
l_int32  size 
)

◆ numaMakeDelta()

NUMA* numaMakeDelta ( NUMA nas)

numaMakeDelta()

Parameters
[in]nasinput numa
Returns
numa of difference values val[i+1] - val[i], or NULL on error

Definition at line 786 of file numafunc1.c.

References numaAddNumber(), numaCreate(), numaGetCount(), and numaGetFValue().

◆ numaMakeSequence()

NUMA* numaMakeSequence ( l_float32  startval,
l_float32  increment,
l_int32  size 
)

numaMakeSequence()

Parameters
[in]startval
[in]increment
[in]sizeof sequence
Returns
numa of sequence of evenly spaced values, or NULL on error

Definition at line 821 of file numafunc1.c.

References numaAddNumber(), and numaCreate().

Referenced by numaContrastTRC(), numaMakeConstant(), pixaSelectToPdf(), and ptraConcatenatePdfToData().

◆ numaMakeThresholdIndicator()

NUMA* numaMakeThresholdIndicator ( NUMA nas,
l_float32  thresh,
l_int32  type 
)

numaMakeThresholdIndicator()

Parameters
[in]nasinput numa
[in]threshthreshold value
[in]typeL_SELECT_IF_LT, L_SELECT_IF_GT, L_SELECT_IF_LTE, L_SELECT_IF_GTE
Returns
nad : indicator array: values are 0 and 1
Notes:
     (1) For each element in nas, if the constraint given by 'type'
         correctly specifies its relation to thresh, a value of 1
         is recorded in nad.

Definition at line 1231 of file numafunc1.c.

References L_SELECT_IF_GT, L_SELECT_IF_GTE, L_SELECT_IF_LT, L_SELECT_IF_LTE, numaAddNumber(), numaCreate(), numaDestroy(), numaGetCount(), and numaGetFValue().

Referenced by pixaSelectByArea(), pixaSelectByAreaFraction(), pixaSelectByPerimSizeRatio(), pixaSelectByPerimToAreaRatio(), pixaSelectByWidthHeightRatio(), and recogPreSplittingFilter().

◆ numaPseudorandomSequence()

NUMA* numaPseudorandomSequence ( l_int32  size,
l_int32  seed 
)

numaPseudorandomSequence()

Parameters
[in]sizeof sequence
[in]seedfor random number generation
Returns
na pseudorandom on [0,...,size - 1], or NULL on error
Notes:
     (1) This uses the Durstenfeld shuffle.
         See: http://en.wikipedia.org/wiki/Fisher–Yates_shuffle.
         Result is a pseudorandom permutation of the sequence of integers
         from 0 to size - 1.

Definition at line 3254 of file numafunc1.c.

References numaCreateFromIArray().

Referenced by boxaPermutePseudorandom(), numaRandomPermutation(), and pixDisplayPtaa().

◆ numaRandomPermutation()

NUMA* numaRandomPermutation ( NUMA nas,
l_int32  seed 
)

numaRandomPermutation()

Parameters
[in]nasinput array
[in]seedfor random number generation
Returns
nas randomly shuffled array, or NULL on error

Definition at line 3293 of file numafunc1.c.

References numaAddNumber(), numaCopy(), numaCreate(), numaDestroy(), numaGetCount(), numaGetFValue(), numaGetIValue(), and numaPseudorandomSequence().

◆ numaRemoveBorder()

NUMA* numaRemoveBorder ( NUMA nas,
l_int32  left,
l_int32  right 
)

numaRemoveBorder()

Parameters
[in]nas
[in]leftnumber of elements to remove from the start
[in]rightnumber of elements to remove up to the end
Returns
nad with removed elements at left and right, or NULL on error

Definition at line 996 of file numafunc1.c.

References L_NOCOPY, numaCopy(), numaGetCount(), numaGetFArray(), numaGetParameters(), numaMakeConstant(), and numaSetParameters().

Referenced by numaClose().

◆ numaReverse()

NUMA* numaReverse ( NUMA nad,
NUMA nas 
)

numaReverse()

Parameters
[in]nad[optional] can be null or equal to nas
[in]nasinput numa
Returns
nad : reversed, or NULL on error
Notes:
     (1) Usage:
           numaReverse(nas, nas);   // in-place
           nad = numaReverse(NULL, nas);  // makes a new one

Definition at line 1355 of file numafunc1.c.

References Numa::delx, numaAddNumber(), numaCreate(), numaGetCount(), numaGetFValue(), numaSetValue(), and Numa::startx.

◆ numaSimilar()

l_int32 numaSimilar ( NUMA na1,
NUMA na2,
l_float32  maxdiff,
l_int32 *  psimilar 
)

numaSimilar()

Parameters
[in]na1
[in]na2
[in]maxdiffuse 0.0 for exact equality
[out]psimilar1 if similar; 0 if different
Returns
0 if OK, 1 on error
Notes:
     (1) Float values can differ slightly due to roundoff and
         accumulated errors.  Using maxdiff > 0.0 allows similar
         arrays to be identified.

Definition at line 370 of file numafunc1.c.

References numaGetCount(), and numaGetFValue().

◆ numaSort()

NUMA* numaSort ( NUMA naout,
NUMA nain,
l_int32  sortorder 
)

numaSort()

Parameters
[in]naoutoutput numa; can be NULL or equal to nain
[in]naininput numa
[in]sortorderL_SORT_INCREASING or L_SORT_DECREASING
Returns
naout output sorted numa, or NULL on error
Notes:
     (1) Set naout = nain for in-place; otherwise, set naout = NULL.
     (2) Source: Shell sort, modified from K&R, 2nd edition, p.62.
         Slow but simple O(n logn) sort.

Definition at line 2650 of file numafunc1.c.

References Numa::array, L_SORT_DECREASING, L_SORT_INCREASING, numaCopy(), and numaGetCount().

Referenced by dewarpIsLineCoverageValid(), numaGetMode(), numaGetRankBinValues(), numaGetRankValue(), numaSortAutoSelect(), pixaRemoveSelected(), pixThresholdGrayArb(), and ptaSort2d().

◆ numaSortAutoSelect()

NUMA* numaSortAutoSelect ( NUMA nas,
l_int32  sortorder 
)

numaSortAutoSelect()

Parameters
[in]nas
[in]sortorderL_SORT_INCREASING or L_SORT_DECREASING
Returns
naout output sorted numa, or NULL on error
Notes:
     (1) This does either a shell sort or a bin sort, depending on
         the number of elements in nas and the dynamic range.

Definition at line 2521 of file numafunc1.c.

References L_BIN_SORT, L_SHELL_SORT, L_SORT_DECREASING, L_SORT_INCREASING, numaBinSort(), numaChooseSortType(), numaCopy(), numaGetCount(), and numaSort().

◆ numaSortByIndex()

NUMA* numaSortByIndex ( NUMA nas,
NUMA naindex 
)

numaSortByIndex()

Parameters
[in]nas
[in]naindexna that maps from the new numa to the input numa
Returns
nad sorted, or NULL on error

Definition at line 2916 of file numafunc1.c.

References numaAddNumber(), numaCopy(), numaCreate(), numaGetCount(), numaGetFValue(), and numaGetIValue().

Referenced by boxaSort2d(), numaBinSort(), and numaSortPair().

◆ numaSortGeneral()

l_ok numaSortGeneral ( NUMA na,
NUMA **  pnasort,
NUMA **  pnaindex,
NUMA **  pnainvert,
l_int32  sortorder,
l_int32  sorttype 
)

numaSortGeneral()

Parameters
[in]nasource numa
[out]pnasort[optional] sorted numa
[out]pnaindex[optional] index of elements in na associated with each element of nasort
[out]pnainvert[optional] index of elements in nasort associated with each element of na
[in]sortorderL_SORT_INCREASING or L_SORT_DECREASING
[in]sorttypeL_SHELL_SORT or L_BIN_SORT
Returns
0 if OK, 1 on error
Notes:
     (1) Sorting can be confusing.  Here's an array of five values with
         the results shown for the 3 output arrays.

         na      nasort   naindex   nainvert
         -----------------------------------
         3         9         2         3
         4         6         3         2
         9         4         1         0
         6         3         0         1
         1         1         4         4

         Note that naindex is a LUT into na for the sorted array values,
         and nainvert directly gives the sorted index values for the
         input array.  It is useful to view naindex is as a map:
                0  -->  2
                1  -->  3
                2  -->  1
                3  -->  0
                4  -->  4
         and nainvert, the inverse of this map:
                0  -->  3
                1  -->  2
                2  -->  0
                3  -->  1
                4  -->  4

         We can write these relations symbolically as:
             nasort[i] = na[naindex[i]]
             na[i] = nasort[nainvert[i]]

Definition at line 2456 of file numafunc1.c.

References L_BIN_SORT, L_SHELL_SORT, L_SORT_DECREASING, L_SORT_INCREASING, and numaGetMax().

◆ numaSortIndexAutoSelect()

NUMA* numaSortIndexAutoSelect ( NUMA nas,
l_int32  sortorder 
)

numaSortIndexAutoSelect()

Parameters
[in]nas
[in]sortorderL_SORT_INCREASING or L_SORT_DECREASING
Returns
nad indices of nas, sorted by value in nas, or NULL on error
Notes:
     (1) This does either a shell sort or a bin sort, depending on
         the number of elements in nas and the dynamic range.

Definition at line 2562 of file numafunc1.c.

References L_BIN_SORT, L_SHELL_SORT, L_SORT_DECREASING, L_SORT_INCREASING, numaChooseSortType(), numaCopy(), numaGetBinSortIndex(), numaGetCount(), and numaGetSortIndex().

◆ numaSortPair()

l_ok numaSortPair ( NUMA nax,
NUMA nay,
l_int32  sortorder,
NUMA **  pnasx,
NUMA **  pnasy 
)

numaSortPair()

Parameters
[in]nax,nayinput arrays
[in]sortorderL_SORT_INCREASING or L_SORT_DECREASING
[out]pnasxsorted
[out]pnasysorted exactly in order of nasx
Returns
0 if OK, 1 on error
Notes:
     (1) This function sorts the two input arrays, nax and nay,
         together, using nax as the key for sorting.

Definition at line 3017 of file numafunc1.c.

References L_SORT_DECREASING, L_SORT_INCREASING, numaCopy(), numaDestroy(), numaGetSortIndex(), numaIsSorted(), and numaSortByIndex().

Referenced by numaInterpolateArbxInterval().

◆ numaSubsample()

NUMA* numaSubsample ( NUMA nas,
l_int32  subfactor 
)

numaSubsample()

Parameters
[in]nas
[in]subfactorsubsample factor, >= 1
Returns
nad evenly sampled values from nas, or NULL on error

Definition at line 751 of file numafunc1.c.

References numaAddNumber(), numaCreate(), numaGetCount(), and numaGetFValue().

◆ numaThresholdEdges()

NUMA* numaThresholdEdges ( NUMA nas,
l_float32  thresh1,
l_float32  thresh2,
l_float32  maxn 
)

numaThresholdEdges()

Parameters
[in]nasinput numa
[in]thresh1low threshold as fraction of max; in [0.0 ... 1.0]
[in]thresh2high threshold as fraction of max; in [0.0 ... 1.0]
[in]maxnfor normalizing; set maxn = 0.0 to use the max in nas
Returns
nad edge interval triplets, or NULL on error
Notes:
     (1) For each edge interval, where where the value is less
         than thresh1 on one side, greater than thresh2 on
         the other, and between these thresholds throughout the
         interval, this records a triplet of values: the
         'left' and 'right' edges, and either +1 or -1, depending
         on whether the edge is rising or falling.
     (2) No assumption is made about the value outside the array,
         so if the value at the array edge is between the threshold
         values, it is not considered part of an edge.  We start
         looking for edge intervals only after leaving the thresholded
         band.

Definition at line 1487 of file numafunc1.c.

References numaAddNumber(), numaCreate(), numaGetCount(), numaGetFValue(), numaGetMax(), and numaGetParameters().

◆ numaUniformSampling()

NUMA* numaUniformSampling ( NUMA nas,
l_int32  nsamp 
)

numaUniformSampling()

Parameters
[in]nasinput numa
[in]nsampnumber of samples
Returns
nad : resampled array, or NULL on error
Notes:
     (1) This resamples the values in the array, using nsamp
         equal divisions.

Definition at line 1289 of file numafunc1.c.

References L_NOCOPY, numaAddNumber(), numaCreate(), numaGetCount(), numaGetFArray(), numaGetParameters(), and numaSetParameters().