Image-Leptonica

 view release on metacpan or  search on metacpan

lib/Image/Leptonica/Func/numafunc1.pm  view on Meta::CPAN

=head2 numaClipToInterval

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

  numaClipToInterval()

      Input:  numa
              first, last (clipping interval)
      Return: numa with the same values as the input, but clipped
              to the specified interval

  Note: 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.

=head2 numaDifferentiateInterval

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

  numaDifferentiateInterval()

      Input:  nax (numa of abscissa values)
              nay (numa of ordinate values, corresponding to nax)
              x0 (start value of interval)
              x1 (end value of interval)
              npts (number of points to evaluate function in interval)
              &nadx (<optional return> array of x values in interval)
              &nady (<return> array of derivatives in interval)
      Return: 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.

=head2 numaFitMax

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

  numaFitMax()

      Input:  na  (numa of ordinate values, to fit a max to)
              &maxval (<return> max value)
              naloc (<optional> associated numa of abscissa values)
              &maxloc (<return> abscissa value that gives max value in na;
                   if naloc == null, this is given as an interpolated
                   index value)
      Return: 0 if OK; 1 on error

  Note: 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

=head2 numaGetBinSortIndex

NUMA * numaGetBinSortIndex ( NUMA *nas, l_int32 sortorder )

  numaGetBinSortIndex()

      Input:  na (of non-negative integers with a max that is typically
                  less than 1,000,000)
              sortorder (L_SORT_INCREASING or L_SORT_DECREASING)
      Return: 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().

=head2 numaGetBinnedMedian

l_int32 numaGetBinnedMedian ( NUMA *na, l_int32 *pval )

  numaGetBinnedMedian()

      Input:  na
              &val  (<return> integer median value)
      Return: 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().

=head2 numaGetCountRelativeToZero

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

  numaGetCountRelativeToZero()

      Input:  numa
              type (L_LESS_THAN_ZERO, L_EQUAL_TO_ZERO, L_GREATER_THAN_ZERO)
              &count (<return> count of values of given type)
      Return: 0 if OK, 1 on error

=head2 numaGetEdgeValues

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

  numaGetEdgeValues()

lib/Image/Leptonica/Func/numafunc1.pm  view on Meta::CPAN

l_int32 numaHasOnlyIntegers ( NUMA *na, l_int32 maxsamples, l_int32 *pallints )

  numaHasOnlyIntegers()

      Input:  na
              maxsamples (maximum number of samples to check)
              &allints (<return> 1 if all sampled values are ints; else 0)
      Return: 0 if OK, 1 on error

  Notes:
      (1) Set @maxsamples == 0 to check every integer in na.  Otherwise,
          this samples no more than @maxsamples.

=head2 numaIntegrateInterval

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

  numaIntegrateInterval()

      Input:  nax (numa of abscissa values)
              nay (numa of ordinate values, corresponding to nax)
              x0 (start value of interval)
              x1 (end value of interval)
              npts (number of points to evaluate function in interval)
              &sum (<return> integral of function over interval)
      Return: 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.

=head2 numaInterpolateArbxInterval

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

  numaInterpolateArbxInterval()

      Input:  nax (numa of abscissa values)
              nay (numa of ordinate values, corresponding to nax)
              type (L_LINEAR_INTERP, L_QUADRATIC_INTERP)
              x0 (start value of interval)
              x1 (end value of interval)
              npts (number of points to evaluate function in interval)
              &nadx (<optional return> array of x values in interval)
              &nady (<return> array of y values in interval)
      Return: 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.

=head2 numaInterpolateArbxVal

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

  numaInterpolateArbxVal()

      Input:  nax (numa of abscissa values)
              nay (numa of ordinate values, corresponding to nax)
              type (L_LINEAR_INTERP, L_QUADRATIC_INTERP)
              xval
              &yval (<return> interpolated value)
      Return: 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.

=head2 numaInterpolateEqxInterval

l_int32 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()

      Input:  startx (xval corresponding to first element in nas)
              deltax (x increment between array elements in nas)
              nasy  (numa of ordinate values, assumed equally spaced)
              type (L_LINEAR_INTERP, L_QUADRATIC_INTERP)
              x0 (start value of interval)
              x1 (end value of interval)
              npts (number of points to evaluate function in interval)
              &nax (<optional return> array of x values in interval)
              &nay (<return> array of y values in interval)
      Return: 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.

=head2 numaInterpolateEqxVal

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

  numaInterpolateEqxVal()

      Input:  startx (xval corresponding to first element in array)
              deltax (x increment between array elements)
              nay  (numa of ordinate values, assumed equally spaced)
              type (L_LINEAR_INTERP, L_QUADRATIC_INTERP)
              xval
              &yval (<return> interpolated value)
      Return: 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))

=head2 numaInvert

NUMA * numaInvert ( NUMA *nad, NUMA *nas )



( run in 0.477 second using v1.01-cache-2.11-cpan-d7f47b0818f )