Returns num if it is even and has no prime factor greater than limit, or makes the number even and adds idnum until it reaches a value with this property. Use a values of 2 for idnum and call niceFFTlimit to obtain an optimal value of limit for taking the FFT with the current IMOD package. This value is 15 when linked with FFTW (because higher values use slower algorithms) and 19 with the old IMOD FFT routines (an absolute limit in that case).
Fortran wrapper for niceFrame
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 fft. 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 up to 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. If minStrength is greater than 0, then only those peaks that are greater than that fraction of the highest peak will be returned. In addition, if width and widthMin are not NULL, the distance from the peak to the position at half of the peak height is measured in 8 directions, the overall mean width of the peak is returned in width, and the minimum width along one of the four axes is returned in widthMin. 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 XCorrPeakFindWidth. If maxPeaks is 1, then xpeak, ypeak, and peak can be single variables instead of arrays.
Calls XCorrPeakFindWidth with width and widthMin NULL and minStrength 0.
Fortran wrapper to XCorrPeakFind. If maxPeaks is 1, then xpeak, ypeak, and peak can be single variables instead of arrays.
Sets limits for shifts in X and in Y for peaks found in the next call to XCorrPeakFindWidth. The peak position must be between limXlo and limXhi in X and between limYlo and limYhi in Y. Also, if useEllipse is non-zero, the peaks are constrained to be in the ellipse bounded by these limits (i.e., a circle if the range of limts is the same in X and Y).
Fortran wrapper to setPeakFindLimits.
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 side of nxpadA in X and nypadA in Y in array, and of nxpadB and nypadB in brray, 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, but no computation will be done and 0. will be returned if this number is less than minPixels.
Fortran wrapper to CCCoefficientTwoPads
Calls CCCoefficientTwoPads with both excluded areas specified by nxpad, nypad and with a value of 25 for minPixels.
Fortran wrapper to XCorrCCCoefficient
Fills mat with the coefficients of a dim x dim Gaussian kernel with standard deviation sigma. The coefficients are scaled to sum to 1.
Fortran wrapper for sliceGaussianKernel
Fills mat with the coefficients of a Gaussian kernel with standard deviation sigma. The size of the kernel is set to 3 for sigma up to 1., 5 for sigma up to 2., etc., up to the size given by limit. The size is returned in dim. The coefficients are scaled to sum to 1. Values are placed sequentially in mat; i.e., it is not treated as a 2D array of size limit.
Fortran wrapper for scaledGaussianKernel
Applies the kernel in mat, with the size given in kdim, to a whole floating point image in array with X and Y sizes nx amd ny and X dimension nxdim, and places the output into brray with the same X dimension. Scaling coefficients should be sequential in mat with the X dimension advancing fastest. The filtering is parallelized with OpenMP with the same size-dependent limitation on the number of threads as in cubinterp
Fortran wrapper for applyKernelFilter
Converts a 2D FFT or Z slice of a 3D FFT between the organization used by FFT routines, with the origin at the lower left, and the organization used in MRC files, with the origin at the middle left. The complex data are packed in array with nx and ny complex elements in X and Y, direction is 0 to convert from FFT routine organization to file organization, and non-zero for the reverse. tmpArray is a temporary array that must be dimensioned to at least 2 * nx.
Fortran wrapper for wrapFFTslice
Produces indices needed for converting between FFT routine organization and MRC file organization. The size of the dimension is in ny and the direction is 0 for FFT routine to file, or non-zero otherwise. Returns the starting index to copy data from on the low and high ends of the dimension in iyLow and iyHigh, respectively, and the starting index to copy data from the high end to in iyOut. The return value is the increment for these indices. In all cases, a loop is run ny / 2 times. For ny even, the loop simply swaps each element or line between iyHigh to iyLow. For ny odd, first the element at iyOut is saved, then the loop is run to copy from iyHigh to iyOut and from iyLow to iyHigh, then the saved element is copied to iyOut.
Applies a phase shift to the Fourier transform in fft to produce a shift of dx and dy in the corresponding real-space image. The size of the image is given in nxPad, nyPad and the X-dimension of fft is assumed to be nxPad + 2. temp is a temporary array that must be dimensioned to at least nxPad + 2.
Fortran wrapper for fourierShiftImage.
Extracts a portion of the Fourier transform in fftIn into fftOut to achieve an image reduction from real-space image size nxrIn, nyrIn to nxrOut, nyrOut, after shifting the image by dxIn, dyIn. A Fourier shift is required to keep the image centered anyway, so it is efficient to combine this with another shift if one is needed. The X-dimension of fftIn is assumed to be nxrIn + 2 and that of fftOut is assumed to be nxrOut + 2. temp is a temporary array that must be dimensioned to at least nxPad + 2.
Fortran wrapper for fourierReduceImage.
Computes the Fourier Ring Correlation between two FFTs in ffta and fftb with real-space image size of nxReal by ny, where each line has nxReal + 2 floating point numbers. The ring spacing is specified by deltaR and maxRings sets the maximum number of rings to compute. The correlation coefficients are returned into ringCorrs. temp is a temporary array that must have at least 4 * maxRings elements; it can be the same as ringCorrs.
Fortran wrapper for fourierRingCorr
Computes padded sizes in one dimension for Fourier reduction, give the original size in size, the reduction factor in factor, fraction to pad in oadFrac, minimum padding in minPad, and the nice or necessary limiting factor for FFTs in niceLimit. The padded size for the original and cropped data are returned in fullPadSize and cropPadSize and the actual factor being applied is returned in actualFac. The reduction factor or its multiple by 2, 3, 4, 5, 6, 8, or 10 is required to be an integer, where the factor must be accurate to the third decimal place for a multiple to be acceptable. The return value is 1 for a factor not greater than 1 or 2 if it is not an acceptable fractional value.
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 to 1 to use linear rather than cubic interpolation, or to -1 to use zoomFiltInterp instead of binning followed by cubinterp
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, or the return value from zoomdown if it gives an error.
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 filtering operation is parallelized with OpenMP with the same limitation on number of threads as used in cubinterp.
The call from Fortran is the same as that from C.