Pads an image in array with dimensions nxbox by nybox into the center of a larger array, brray, which can be the same as array. The SLICE_MODE is specified by type, which must be byte, float or short integer. The size of the padded image is specified by nx and ny while nxdim specifies the X dimension of the output array. The values of the image in the padding area will be tapered from the value of a pixel at the edge of the input image edge down to a common value. That value is either the mean at the edge of the input image, if ifmean is zero, or the value supplied in dmeanin, if ifmean is nonzero.
Fortran wrapper to call sliceTaperOutPad with a floating point array.
Extracts a subarea of an image, places it into the center of a potentially larger array with padding, and tapers the image down to the mean value at its edge, tapering pixels inside the extracted image area. The image data are in array, their X dimension is nxdimin, and their SLICE_MODE is given in type. The mode can be byte, signed or unsigned short, float, or RGB. The starting and ending coordinates to extract in X and Y are ix0 to ix1 and iy0 to iy1. The output image array is brray and its X dimension is specified by nxdim. The padded image size is specified by nx and ny, and nxtap and nytap indicate the number of pixels over which to taper in X and Y. The output array can be the same as the input array if the input image fills the entire array.
Fortran wrapper to sliceTaperInPad for padding a whole float image array of size nxbox by nybox. The output array can be the same as the input array.
Pads an image in array with dimensions nxbox by nybox into the center of a larger array, brray, which can be the same as array. The SLICE_MODE is specified by type, which must be byte, float or short integer. The size of the padded image is specified by nx and ny while nxdim specifies the X dimension of the output array. The padding is done by replicating pixels and smoothing lines progressively more for farther out from the pixels in the box. This is done in a series of progressively larger rectangles; the each pixel in first rectangle contains the average of the three nearest pixels on the outer edge of the actual data; each pixel in the second rectangle is the average of the 5 nearest pixels in the first rectangle, etc.
Fortran wrapper to call sliceSmoothOutPad with a floating point array.
Computes the mean along the edge for the portion of the image in array bounded by X indices ixlo and ixhi and Y indices iylo and iyhi, inclusive. nxdim is the X dimension of the array. The mean is based solely on the single columns at ixlo and ixhi and the single rows at iylo and iyhi.
Fortran wrapper to sliceEdgeMean . The indexes are numbered from 1.
Splits a small image in array with dimensions nxbox by nybox into the 4 corners of a potentially larger array. The padded image is placed in brray with a size of nx by ny, where nxdim is the X dimension of brray. The image will be padded with the mean at the edge of the image, or with the value in fillin if iffill is non-zero. In either case the values will be shifted so that the mean of the whole array is zero.
Fortran wrapper to splitFill .
Analyzes for fill areas at the edge of the slice sl, finds the borders between actual image and fill areas, and tapers the image intensities down to the fill value over ntaper pixels. If inside is 0 the image intensities at the edge are extended into the fill area, while if inside is 1 then pixels inside the image are attenuated. Returns -1 for memory allocation errors.
Fortran wrapper to sliceTaperAtFill for tapering a real*4 image in array of size nx by ny. Returns -1 for memory error.
Takes the filter parameters sigma1, sigma2, radius1, and radius2 and sets up a contrast transfer (filter) function in the array ctf, which should be dimensioned to at least 8193. The dimensions of the real space image being filtered are specified in nx and ny, and the step size between the values in ctf is returned in delta. If no filtering is selected (sigma1 and sigma2 both 0) then 0 is returned in delta. The values in ctf are scaled so that mean of all but the zero element is 1.
Fortran wrapper for XCorrSetCTF.
Sets up a filter function in ctf as described for XCorrSetCTF, but with no scaling, such that the filter value will be 1 for all unattenuated frequencies. The number of elements computed in ctf is returned in nizeOut.
Fortran wrapper for XCorrSetCTFnoScl.
Applies the filter in ctf to the 2D Fourier transform in fft, and puts result into array, which can be the same as ctf. The dimensions of the real space image are given by nx and ny, and the dimension of the real image array are assumed to be nx + 2 by ny. delta is the interval in reciprocal space (1/pixel) for the function in ctf.
Fortran wrapper to XCorrFilterPart
Shifts the contents of array to have a zero mean. nxdim specifies the X dimension of array, and nx and ny are the size of the data in array.
Fortran wrapper to XCorrMeanZero
Finds the coordinates of the maxpeaks highest peaks in array, which is dimensioned to nxdim by ny, and returns the positions in xpeak, ypeak and the peak values in peak. The X size of the image is assumed to be nxdim - 2. The sub-pixel position is determined by fitting a parabola separately in X and Y to the peak and 2 adjacent points. Positions are numbered from zero and coordinates bigger than half the image size are shifted to be negative. The positions are thus the amount to shift a second image in a correlation to align it to the first. If fewer than maxpeaks peaks are found, then the remaining values in peaks will be -1.e30.
Fortran wrapper to XCorrPeakFind. If maxpeaks is 1, then xpeak, ypeak, and peak can be single variables instead of arrays.
Given values at three successive positions, y1, y2, and y3, where y2 is the peak value, this fits a parabola to the values and returns the offset of the peak from the center position, a number between -0.5 and 0.5.
Fortran wrapper to parabolicFitPosition
Forms the product of complex numbers in array and the complex conjugate of numbers in brray and puts the result back in array, where the arrays are Fourier transforms of images with dimensions nx by ny.
Fortran wrapper to conjugateProduct
Returns the cross-correlation coefficient between the images in array and brray at a shift between the images given by xpeak, ypeak. The images have sizes nx by ny and the arrays have X dimension nxdim. Areas on each size of nxpad in X and nypad in Y are excluded from the correlation. Otherwise, the correlation will include all the pixels in the overlap between the images at the given shift. The number of pixels will be returned in nsum.
Fortran wrapper to XCorrCCCoefficient.
Applies a Sobel-type gradient filter to an image after scaling it by a
specified amount. When an image is being scaled down, some of the scaling
can be done with binning and the remainder is done with interpolation.
inImage - input image
nxin, nyin - size of image, which is assumed to be contiguous in
the image array (X dimension equals nxin.)
scaleFac - overall amount by which image is being scaled down (a value
< 1 will scale an image up).
minInterp - minimum amount of this scaling to be done by interpolation.
linear - set nonzero to use linear rather than cubic interpolation
center - weighting of center pixel, 2 for Sobel or 1 for Prewitt filter
outImage - output image
nxout, nyout - returned with size of output image
xOffset, yOffset - coordinate offset in output image:
input_coord = output_coord * scalingFactor + xOffset
The return value is 1 for a failure to allocate a temporary array.
If inImage is NULL or center < 0, the function will compute the output
sizes and offsets and return.
If center is 0, the scaled image is computed and returned without Sobel
filtering.
The call from Fortran is the same as that from C.
Applies a linear transformation to an image using cubic or linear
interpolation. It eliminates all range tests from the inner loop, but
falls back from cubic to quadratic interpolation (which range tests) around
the edges of the input image area.
array - The input image array
bray - The output image array
nxa,nya - The dimensions of array
nxb,nyb - The dimensions of bray
amat - A 2x2 matrix to specify rotation, scaling, and skewing
xc,yc - The coordinates of the center of array
xt,yt - The translation to add to the final image. The
center of the output array is taken as nxb / 2., nyb / 2.
scale - A multiplicative scale factor for the intensities
dmean - Mean intensity of image or other value with which to fill
empty image area
linear - Set non-zero to do linear interpolation
The coordinate transformation from (Xi, Yi) in the input image to the
(Xo, Yo) in the output image is given by:
Xo = a11(Xi - Xc) + a12(Yi - Yc) + nxb/2. + xt
Yo = a21(Xi - Xc) + a22(Yi - Yc) + nyb/2. + yt
where Xi is a coordinate running from 0 at the left edge of the first pixel
to nxa at the right edge of the last pixel in X, and similarly for Y.
When calling from C, indices in amat are transposed: a11 = amat[0][0],
a12 = amat[1][0], a21 = amat[0][1], a22 = amat[1][1]
To call from Fortran, use arguments of the same type and in the same order.
Indices in amat are in logical order: a11 = amat(1,1), a12 = amat(1,2),
etc.
This routine is now parallelized with OpenMP. The allowed threads is
proportional to the square root of output image area, falling to 1 at about
32x32.
Selects which filter to use in image reduction with type and sets the scaling factor with zoom, a value less that must be less than 1. The type can be 0 for a box (equivalent to binning), 1 for a Blackman window, 2 for a triangle filter, 3 for a Mitchell filter, or 4 or 5 for Lanczos 2 or Lanczos 3. The total width of the filter in the source image is returned in outWidth. Returns 1 for a filter type out of range or 2 for a zoom out of range.
Fortran wrapper for selectZoomFilter
Reduces an image using the interpolation filter and zoom specified in
selectZoomFilter.
slines - array of line pointers for the input image
aXsize, aYsize - size of input image
aXoff, aYoff - coordinate in the input image at which the lower left pixel of the
output starts
bXsize, bYsize - size output image to be created, potentially from a subset of
the input in X or Y and into a subset of the output array
bXdim - X dimension of the full output image array
bXoff - Index of first pixel in X to fill in output array
dtype - Type of data, a SLICE_MODE_... value. BYTE, FLOAT, RGB, and USHORT are
allowed
outData - Output array, or address of first line to fill in a larger output array.
The array is the same data type as the input unless mapping is being done, in which
case it must be unsigned integers.
cindex - Unsigned integer RGBA values to map byte or short data into, or NULL for
no mapping
bindex - Byte values to map RGB data into, or NULL for no mapping. Each channel is
mapped the same and a fourth channel is added with zero.
Returns 1 if no filter has been selected, 2 for an unsupported data type, 3 for an
attempt to map float data, 4 if needed input coordinates to compose the output image go
out of range, or 5 for a memory allocation error.
This function is parallelized with OpenMP and uses the same formula as cubinterp for
reducing the number of threads for small images.
Fortran wrapper for zoomWithFilter
Performs image reduction using zoomWithFilter and can be used the same way as
cubinterp could be for scaling an image down and shifting it. The zoom and filter
must already be specified with selectZoomFilter .
array - The input image array
bray - The output image array
nxa,nya - The dimensions of array
nxb,nyb - The dimensions of bray
xc,yc - The coordinates of the center of array
xt,yt - The translation to add to the final image. The
center of the output array is taken as nxb / 2., nyb / 2.
dmean - Mean intensity of image or other value with which to fill empty
image area
Returns the same error values as zoomWithFilter
Fortran wrapper for zoomFiltInterp
Initializes transform f with a11 and a22 set equal to val; use 1.0 for a unit transform.
Copies transform f1 to f2, which have rows1 and rows2 rows, respectively.
Multiples transform f1 (the one applied first) by f2 (the one applied second) and places the result in prod, which can be the same as f1 or f2.
Takes the inverse of transform f and returns the result in finv, which can be the same as f.
Applies transform f to the point x, y, with the center of transformation at xcen, ycen, and returns the result in xp, yp, which can be the same as x, y.
Converts a 2 by 2 transformation matrix into four "natural" parameters of
image transformation. The transformation is specified by a11, a12,
a21, and a22, where
x' = a11 * x + a12 * y
y' = a21 * x + a22 * y
In the converted transformation, theta is overall rotation, smag is
overall magnification, str is a unidirectional stretch, and phi is the
angle of the stretch axis. Two equivalent solutions are possible, with the
stretch axis in the first or fourth quadrant. The function returns the
solution that makes the magnification smag nearer to 1.0.
Fortran wrapper to amatToRotmagstr, where amat is dimensioned (2,*) or otherwise has elements in the order a11, a21, a12, a22.
Obtains a 2 by 2 transformation from four parameters of image transformation: theta is overall rotation, smag is overall magnification, str is a unidirectional stretch, and phi is the angle of the stretch axis, where angles are in degrees. The transformation is returned in a11, a12, a21, and a22.
Fortran wrapper to rotmagstrToAmat, where amat is dimensioned (2,*) or otherwise has elements in the order a11, a21, a12, a22.
Reduces an array in size by summing pixels (binning) by the factor nbin.
array has the input, with dimensions nxin by nyin, and slice mode in
type. The slice mode can be byte, short, unsigned short, float, or RGB.
brray receives the output, with dimensions returned in nxr and nyr.
The output will have the same mode as the input and will be the average of
binned values, except in two cases. If the input is bytes or RGB and
keepByte is 0, then the output will be signed short integers and will be
the sum, not the average, of the binned values, and for RGB data the output
will be an equal sum of red, green, and blue values. brray can be the
same as array, and nxr, nyr can be the same variables as nxin,
nyin. The output size is obtained by integer division of the input size
by the binning. If the remainder of this division is nonzero, the data are
centered in the output array as nearly as possible. Specifically, the
coordinates of the lower left corner of the output array are offset by
((nx % nbin) / 2, (ny % nbin) / 2)
relative to the input array. Returns 1 for an unsupported data type.
Fortran wrapper for reduceByBinning, called as reduce_by_binning. Again, the output variables can safely be the same as the input variables.
Computes the radius rad and center (xc, yc) for a circle through the 3 given points (x1, y1), (x2, y2), and (x3, y3). Returns 1 for error (square root of negative number).
Fit a circle or sphere to a set of points using a simplex search with
the amoeba routine.
Inputs: X and Y coordinates in arrays xpt, ypt; zpt is NULL for a
circle fit or has the array of Z coordinate; number of points in numPts.
Outputs: radius in rad, center coordinate in xcen, ycen, and zcen
for a sphere fit, and RMS error in rmsErr. Returns 0.
Fit a circle or sphere to a set of points with weighting of errors using a
simplex search with the amoeba routine.
Inputs: X and Y coordinates in arrays xpt, ypt; zpt is NULL for a
circle fit or has the array of Z coordinate; weights has an array of
weights or is NULL for no weighting; the number of points is in numPts.
Outputs: radius in rad, center coordinate in xcen, ycen, and zcen
for a sphere fit, and RMS error in rmsErr. Returns 0.
Returns 1 if the point x, y is inside or on the polygon (contour) whose vertices are in ptX, ptY, where np is the number of points, otherwise returns 0.
Fortran wrapper to InsideContour . But it is more convenient to call
logical function inside(ptX, ptY, np, x, y)
Finds the smallest convex boundary around an arbitrary set of points in sx, sy. npnts is the total number of points. If fracomit is nonzero, it omits that fraction of points from consideration completely, choosing the points that are farthest from the centroid of all the points. (If fracomit is negative, the Y coordinates of the points will be temporarily scaled to have the same standard deviation as the X range in order to determine the farthest points; it then eliminates -fracomit points.) It returns the centroid of the points under consideration in xcen, ycen. It returns the set of boundary points in bx, by and the number of points in nvert. The size of bx and by is specified by maxverts. If pad is nonzero, it makes the boundary points be that distance away from the outermost sx, sy points. It uses Graham's scan algorithm. nvert is returned with -1 for an error allocating temporary arrays, or -2 for the boundary arrays not large enough.
Fortran wrapper for convexBound
Sets one parameter for surfaceSort .
Fortran wrapper for setSurfSortParam
Sorts a set of points in 3D onto two surfaces. The X, Y, and Z coordinates of the numPts points are packed sequentially into the array xyz. The surfaces number, 1 for the bottom one and 2 for the top one, are returned in group. The return value is 1 for a memory allocation error.
Fortran wrapper for surfaceSort, where xyz is dimensioned to (3,*)
/* Spacing of squares for sorting points and accessing rings of points */ static float gridSpacing = 50.; /* 0 */ /* Maximum neighbors to evalue for finding neighbor with steepest angle */ static int maxAngleNeigh = 50; /* 1 */ /* Use pairs with angle more than this fraction of very steepest angle */ static float steepestRatio = 0.5f; /* 2 */ /* If there are fewer than this number of pairs, take pairs down to angleMax */ static int numMinForAmax = 10; /* 3 */ /* Angle to go down to if steepestRatio doesn't give enough pairs */ static float angleMax = 20.; /* 4 */ /* If fewer than this number of pairs, take pairs down to angelRelax */ static int numMinForArelax = 3; /* 5 */ /* Angle to go down to if angleMax doesn't give enough pairs */ static float angleRelax = 5.; /* 6 */ /* Criterion for MAD-Median outlier elimination based on delta Z of a pair */ static float outlierCrit = 3.; /* 7 */ /* Maximum distance to search for neighboring points in plane fits */ static float maxFitDist = 2048.; /* 8 */ /* Maximum number of points in plane fits */ static int maxNumFit = 15; /* 9 */ /* Minimum # of points for fitting parallel planes */ static int biplaneMinFit = 5; /* 10 */ /* Minimum # of points for fitting one plane */ static int planeMinFit = 4; /* 11 */ /* Maximum % distance of Z value between nearest and other plane for deferring to 2nd round: values > 50 disable deferring points */ static float maxRound1Dist = 100.; /* 12 */ /* 1 for minimal output, 2 for exhaustive output */ static int debugLevel = 0; /* 13 */
Converts a list entry in the string line into a set of integers, returns a pointer to the list of numbers, and returns the number of values in nlist. An example of a list is 1-5,7,9,11,15-20. Numbers separated by dashes are replaced by all of the numbers in the range. Numbers need not be in any order, and backward ranges (10-5) are handled. Any characters besides digits are valid separators. A / at the beginning of the string will return an error. Negative numbers can be entered provided that the minus sign immediately precedes the number. E.g.: -3 - -1 or -3--1 will give -3,-2,-1; -3, -1,1 or -3,-1,1 will give -3,-1,1.
Performs a multidimensional search to minimize a function of ndim
variables using the Nelder-Mead algorithm as elaborated by Lagarius et al.
The function value is computed by funk,
a void function of two variables: a float array containing the values of
the ndim variables, and a pointer to a float for the function value.
p is a 2-dimensional array dimensioned to at least one more than the
number of variables in each dimension, and mp specifies its fastest
dimension (second in C, first in fortran). y is a one-dimensional array
also dimensioned to at least one more than the number of variables.
Both of these should be preloaded by calling amoebaInit.
Termination is controlled by ftol, which is a limit for the fractional
difference in function value between the lowest and highest point in the
simplex, and the array ptol, which has limits for the difference of each
variable; each component of each point must be within the respective limit
of the value for the lowest point. iterP is returned with
the number of iterations; iloP is returned with the index of the minimum
vector in p (p[i][iloP] in C, p(iloP, i) in fortran).
From fortran the subroutine is called as:
call amoeba(p, y, mp, ndim, ftol, funk, iter, ptol, ilo)
where funk is:
subroutine funk(a, value)
Initializes the arrays p, y, and ptol before calling amoeba.
a is an array with the initial values of the variable.
da is an array with
factors proportional to the magnitude of the components of a.
The initial step size for each variable is set to delfac times da,
while the termination tolerance for each variable is set to ptolFac times
da. Other variables are as just described. From fortran it is called as:
call amoebaInit(p, y, mp, ndim, delfac, ptolFac, a, da, func, ptol)
Computes a standard or kernel histogram from the numVals values in the array values. The histogram is placed in the array bins, and occupies numBins between firstVal and lastVal. The kernel width is set by h, use 0 for a standard binned histogram. Set verbose to 1 for a list of values, or 2 for a list of bin values.
Fortran wrapper for kernelHistogram
Scans a histogram for peaks and a dip. The histogram is in numBins elements of bins, extending from firstVal to lastVal. It will be scanned between values scanBot and scanTop. If findPeaks is nonzero, it will find the two highest peaks and return their values in peakBelow and peakAbove, then find the dip between them and returns its value in dip; otherwise it just scans the range for the lowest point and returns the value in dip. The return value is 1 if it fails to find two peaks.
Fortran wrapper for scanHistogram
Finds a histogram dip by starting with a high smoothing and dropping to a
lower one.
values - Array of values to form histogram from
numVals - Number of values in the array
bins - Array to build histogram in
numBins - Number of bins to divide histogram into
firstVal, lastVal - Starting and ending value for histogram range
minGuess - If non-zero, it specifies an estimate of the minimum number of
items above the dip
verbose - Verbose output flag, passed to kernelHistogram
histDip - Returned with the location of the dip
peakBelow, peakAbove - Returned with the peak values below and above
the dip
The return value is 1 if a dip cannot be found after 4 trial H values.
Fortran wrapper for findHistogramDip
Makes a model bead of radius beadSize in array with dimensions boxSize by boxSize.
Finds integral above background of a bead located at xcen, ycen in array, an image nx by ny with X dimension nxdim. rCenter, rInner, and rOuter are radii of the center and the inner and outer radii of the background annulus. Returns the center and annular means in cenmean and annmean, and if annPct is supplied with a fractional percentile, returns the percentile value in median, using temp as a temporary array. temp is not used if annPct is 0. The return value is center minus annular mean.
Calculates the mean avg, standard deviation sd, and standard error of mean sem, from the n values in array x. Callable from Fortran by the same name.
Fortran wrapper for avgSD
Computes a mean avg and standard deviation sd from the sum of values sx, sum of squares sxsq, and number of values n. It will not generate any division by 0 errors. Callable from Fortran by the same name.
Fortran wrapper for sumsToAvgSD
Computes a mean avg and standard deviation sd from the sum of values sx8, sum of squares sxsq8, and number of values n1 * n2, where the number of values can be greater than 2**31. It will not generate any division by 0 errors.
Fortran wrapper for sumsToAvgSDdbl; use real*8 for sx8, sxsq8.
Fits a straight line to the n points in arrays x and y by the method of least squares, returning slope, intercept bint, correlation coeficient ro.
Fortran wrapper for lsFit
Fits a straight line to the n points in arrays x and y by the method of least squares, returning slope, intercept bint, correlation coeficient ro, standard errors of the estimate se, the slope sb, and the intercept sa, and for one X value xpred, it returns the predicted value ypred and the standard error of the prediction prederr.
Fortran wrapper for lsFitPred
Fortran wrapper for lsFitPred that returns the standard errors and omits the prediction
Does a linear regression fit of the n values in the array y to
the values in the arrays x1 and x2, namely to the equation
y = a * x1 + b * x2 + c
It returns the coefficients a and c, and the intercept c.
If c is NULL it fits instead to
y = a * x1 + b * x2
Fortran wrapper for lsFit2
Fortran wrapper for calling lsFit2 with c NULL.
Does a linear regression fit of the n values in the array y to
the values in the arrays x1 and x2, namely to the equation
y = a * x1 + b * x2 + c
It returns the coefficients a and b, and the intercept c, but
if c is NULL it fits instead to
y = a * x1 + b * x2
For one value of x1 and x2 given by x1pred and x2pred, it returns the
value predicted by the equation in ypred and the standard error of the
prediction in prederr.
Fortran wrapper for lsFit2Pred
Does a linear regression fit of the n values in the array y to
the values in the arrays x1, x2, and x3, namely, to the equation
y = a1 * x1 + a2 * x2 + a3 * x3 + c
It returns the coefficients a1, a2, a3 and the intercept c.
Fortran wrapper for lsFit3
Uses qsort to sort the n floats in the array x.
Fortran wrapper for rsSortFloats
Uses qsort to sort indexes in index to the n floats in the array x.
Fortran wrapper for rsSortIndexedFloats
Computes the median of the n values in the array x, which has already been sorted, and returns the value in median.
Fortran wrapper for rsMedianOfSorted
Computes the median of the n values in x. The value is returned in median and xsort is used for sorting the array and returned with the sorted values.
Fortran wrapper for rsMedian
Computes the normalized median absolute deviation from the median for the n values in x, using the value already computed for the median in median. The result is returned in MADN, and tmp is returned with sorted values of the absolute deviations.
Fortran wrapper for rsMADN
Selects outliers among the n values in the array x by testing whether the absolute deviation from the median is greater than normalized median absolute deviation by the criterion kcrit. out is used for temporary storage and is returned with -1 or 1 for outliers in the negative or positive direction from the median, 0 otherwise.
Fortran wrapper for rsMadMedianOutliers
Computes a trimmed mean of the n already sorted values in x, trimming off the fraction gamma on each end of the distribution. The value is returned in trmean.
Fortran wrapper for rsTrimmedMeanOfSorted
Computes a trimmed mean of the n values in x, trimming off the fraction gamma on each end of the distribution. The value is returned in trmean and xsort is used for sorting the array and returned with the sorted values.
Fortran wrapper for rsTrimmedMean
Selects item number s (numbered from 1) out of num items in the array r, where items are considered in order from low to high. r is partially rearranged while finding the item.
Same as percentileFloat but with an integer array r
Estimates mean and SD of a sample of an image. Returns nonzero for errors.
image = array of pointers to each line of data
type = data type, 0 for bytes, 2 for unsigned shorts, 3 for signed shorts, 6 for
floats, 7 for 4-byte integers, 8 for RGB triples of bytes or 9 for RGBA bytes;
RGB values are weighted with NTSC weighting
nx, ny = X and Y dimensions of image
sample = fraction of pixels to sample
ixStart, iyStart = starting X and Y index to include
nxUse, nyUse = number of pixels in X and Y to include
mean, sd = returned values of mean and sd
Fortran wrapper for sampleMeanSD with a floating point array in image
Estimates percentile limits for contrast strecthing an image by building a histogram
of a sample.
image = line pointers to image
mode = data type, a SLICE_MODE_ value; BYTE, USHORT, SHORT, or FLOAT are allowed
nx, ny = X and Y dimensions of image
sample = fraction of pixels to sample
ixStart, iyStart = starting X and Y coordinates to sample
nxUse, nyUse = extent of image to sample in X and Y
pctLo, pctHi = Percentile levels to find on the low and high end of range
(1.0 is 1%)
scaleLo, scaleHi = returned values of those percentile levels
Returns 1 for inadequate number of pixels, 2 for invalid mode, or 3 for memory error.
Returns the t-value that gives the significance level signif with the number of degrees of freedom ndf, where signif should be between 0.5 and 1.0.
Fortran wrapper for tValue
Returns the F-value that gives the cumulative probability value signif with the number of degrees of freedom ndf1 and ndf2.
Fortran wrapper for fValue
Returns the value of the error function erf() at x.
Fortran wrapper for errFunc
Computes and returns the incomplete beta function of x for parameters a and b, for 0 <= x <= 1, and a > 0 and b > 0.
Fortran wrapper for incompBeta
Computes and returns the beta function of p and q, which must be > 0.
Computes and returns the natural log of the gamma function of x, which should not equal 0, -1, -2, etc.
Solves the linear matrix equation A X = B by Gauss-Jordan elimination.
A is a square matrix of size n by n in array a, dimensioned to np
columns. B is a matrix with one row per row of A and m columns in array
b, dimensioned to mp columns. The columns of b are replaced by
the m solution vectors while a is reduced to a unit matrix. It is
called the same from C and Fortran, but the matrices must be in row-major
order in both cases. Specifically, in C, the matrices are indexed as
Arowcolumn and in Fortran they are indexed as A(column,row).
The maximum value of n is 2000 but better and faster approaches should be
used long before reaching that point. The routine returns -1 if n exceeds
this value and 1 if the A matrix is singular.
Compute products in a sparse matrix for lsqr. The matrix has m data rows
times n columns, one for each variable
If mode = 1, compute y = y + A*x.
If mode = 2, compute x = x + A(transpose)*y.
UsrWrk is loaded as follows:
Offset to JA values, the column number of each data value (from 1)
Offset to RW values, the data values themselves
IA values: the starting index of each row. Numbered from 1
Adds one value val and its data column icol to arrays valRow and icolRow for the current row, and maintains the number of values in numInRow.
Fortran wrapper for addValueToRow
Adds one data row to a sparse matrix. Values are in valRow, column numbers (numbered from 1) in icolRow, number of values in numInRow. rwrk is the sparse matrix array of data values, ja is the corresponding array of column numbers, ia is an array of starting indexes into those arrays for each row (indexes numbered from 1). The number of rows is maintained in numRows, and maxRows and maxVals are the maximum number of rows and values allowed.
Fortran wrapper for addRowToMatrix
Normalizes each column of data in the sparse matrix by dividing it by the square root of the sum of squares of values in that column, as recommended for running lsqr. rwrk, ja, and ia are as described for addRowToMatrix; numVars is the number of variables (columns) and numRows is the number of rows. The normalizing factor for each column is returned in sumEntries. The solution vector obtained from normalized data needs to be divided by sumEntries.
Fortran wrapper for normalizeColumns
Examines a list of npclist piece coordinates in pclist for one dimension (x or y) at a spacing of stride between successive values, applies a reduction factor redfac, and given the frame size nframe, it finds the minimum coordinate minpiece, the # of pieces npieces, and the overlap noverlap. It also checks that ALL coordinates on the list are multiples of frame size minus overlap. Upon failure, it returns the line number at which that check fails, and also return -1 in npieces.
Fortran wrapper for checkPieceList which assumes the stride is 1. Upon error, it prints a message, and still returns -1 in npieces.
Adjusts a list of npclist piece coordinates in pclist for one dimension (x or y), at a spacing of stride between successive values, changing the overlap from noverlap to newOverlap, given the frame size nframe and the minimum coordinate minpiece (which is retained).
Fortran wrapper for adjustPieceOverlap that assumes a stride of 1.
Solves for positions of overlapping pieces by adjusting them iteratively to
minimize the difference between measured displacement between pairs of
pieces and the difference in their positions.
ivarpc: index from included variables (pieces) to overall piece number
nvar: Number of variables
indvar: index from piece number to variable number; must be set to less
than the minimum variable number (0 for C, 1 for Fortran) for all pieces
potentially connected to the ones included as variables.
ixpclist, iypclist: X and Y piece coordinates.
dxedge, dyedge: the measured difference from the nominal displacement
between pieces at an edge
idir: 1 if those values are the amount that the upper piece is displaced
from being in register with the lower; -1 if they are the amount that the
upper piece needs to be shifted to be in register.
pieceLower, pieceUpper: index of pieces below and above an edge
ifskipEdge: A number indicating whether the edge should be skipped
edgeStep: Stride between X and Y edges at the same edge index in the edge
arrays dxedge, dyedge, pieceLower, pieceUpper, ifskipEdge. If the arrays
are accessed in Fortran as array(edge,ixy), then this value is the first
dimension of the array. If they are accessed in C as arrayedgeixy or
array2*edge+ixy then the value is 1.
dxyvar: array into which the piece shifts in X and Y are returned for
each piece in the variable list
varStep: Stride between X and Y shifts for a given piece in dxyvar; as
for edgeStep, this is either 1 or the long dimension of the array.
edgeLower, edgeUpper: edge index of edge below or edge above a given piece
in X or Y.
pcStep: Stride between X and Y edges at the same piece in those arrays;
again, this is either 1 or the long dimension of the array
work: Array for temporary storage, must be at least 20.25 times the number
of variables plus 1.
fort: A nonzero value indicates that the indexes in
ivarpc, indvar, pieceLower, pieceUpper, edgeLower, edgeUpper are numbered
from 1 instead 0.
leaveInd: Absolute edge index in edge arrays of edge to leave out
skipCrit: An edge is skipped if ifskipEdge is >= this value
critMaxMove: Terminate if the maximum move of any piece in X or Y is less
than this criterion.
robustCrit: Use robust fitting to eliminate or down-weight outlying
edge displacements; multiply outlier criterion by given factor.
critMoveDiff: Terminate if the average move changes by less than this
amount between samples
maxIter: Maximum number of iterations
numAvgForTest: Number of iterations over which to average the average
moves in X and Y for the test based on critMoveDiff
intervalForTest: Number of iterations between such tests
numIter is returned with the number of iteratation.
wErrMean and wErrMax are returned with the mean and maximum of weighted
errors.
Returns 1 if the strides are not all 1 or all different from 1.
Called from Fortran with identical arguments and name.
Initialize parallel writing to an image file by reading in the boundary
info file whose name is filename, and storing various values in static
variables. filename can be NULL or an empty string, in which case the count of
parallel writing files is incremented and this info file index is marked as having no
info file. nxin and nyin * specify the dimensions of the images. The format of
the info file is to start with a line with these entries:
Version type nx numLines numFiles
version = 1 for now
type = 0 for chunks in Z, 1 for chunks in Y that require boundaries on each
section
nx = X dimension of image file
numLines = number of lines written at each boundary
numFiles = number of boundary files
For each boundary file, there are then two lines:
Name of boundary file
Boundary 1 section and starting line, boundary 2 section and starting line
Sections and lines are numbered from 0. For chunks in Z, the section number
should be -1 for no boundary (i.e., for boundary 1 of first chunk and
boundary 2 of last chunk). A line number of -1 indicates that the boundary
extends to the end of the section (thus, a setup script does not need to
know the size of the images in Y). This routine will convert a line number
of -1 to the appropriate starting line.
For chunks in Y, the section number is
ignored (and should be -1) and the line number should be -1 for no boundary.
Returns 1 for failure to open file, 2 for error reading file, 3 for
inappropriate values in header line of file, 4 for memory allocation errors, or
5 for trying to open too many boundary info files for the array.
Simple Fortran wrapper for parWrtInitialize, called by the Fortran parWrtInitialize funtion.
Returns properties read from the current boundary info file: allSec 1 if chunks are in Y, linesBound with the number of lines in each boundary, nfiles with the number of boundary files. These values are all zero if there was no boundary info file at the current index. Returns 1 for parallel writing not initialized.
Fortran wrapper for parWrtProperties.
Sets the index of the current boundary info file to index, numbered from 0. Returns 1 for index out of range.
Fortran wrapper for parWrtSetCurrent, with index numbered from 1.
Finds the parallel writing region that contains nlWrite lines starting with line lineNum on section secNum and returns the boundary file in filename, and the section and starting line of the first and second boundaries in arrays sections and startLines. Returns 1 if parallel writing not initialized, or 2 if the region is not found.
Fortran wrapper for parWrtFindRegion
Fortran-callable function to get the parameters of parallel writing region number regionNum (numbered from 1) and return the boundary file in filename and the sections and starting lines in arrays sections and startLines. Returns 2 if writing not initialized, or 1 if the region number is out of bounds.
Returns a pointer to the color ramp specification for the standard false color table used in 3dmod.
Returns a pointer to a color ramp specification for an false color table inverted from the one used in 3dmod.
Converts a color ramp specification in rampData to a full 256-color table in table. The first value in the rampData array is the number of color specifications; each set of 4 numbers after that is a red, green, and blue value (range 0-255) and a relative position along the color table.
Reads a color map specification from the file specified by filename and converts it to a complete color table in table. The file starts with the number of lines of color data. If there are 256 lines they must be red, green, blue triplets (range 0-255); otherwise each line has a red, green, and blue followed by a relative position in the color table. Returns 1 for error opening a file, 2 for errors reading the file, 3 for an invalid number of lines, or 4 for a memory allocation error.
static int standardRampData[] = { 15, 255, 0, 255, -616, 179, 0, 255, -569, 120, 40, 255, -528, 60, 96, 255, -469, 0, 175, 177, -400, 0, 191, 143, -383, 0, 207, 78, -361, 90, 255, 60, -305, 191, 255, 0, -259, 239, 255, 0, -240, 255, 255, 0, -229, 255, 175, 0, -162, 255, 105, 0, -83, 255, 45, 55, -20, 255, 0, 90, 0, }; /* An inverted color ramp specification, used in model view for mesh normals */ static int invertedRampData[] = { 15, 255, 0, 90, 0, 255, 45, 55, 20, 255, 105, 0, 83, 255, 175, 0, 162, 255, 255, 0, 229, 239, 255, 0, 240, 191, 255, 0, 259, 90, 255, 60, 305, 0, 207, 78, 361, 0, 191, 143, 383, 0, 175, 177, 400, 60, 96, 255, 469, 120, 40, 255, 528, 179, 0, 255, 569, 255, 0, 255, 616, };