90 float*
GetRadialZLUT(
int index) {
return &zluts[zlut_res*zlut_planes*index]; }
109 FFT2D(
int w,
int h) : xfft(w,false), yfft(h,false) {cbuf=
new std::complex<float>[w*h]; }
118 void Apply(
float* d);
122 float&
GetPixel(
int x,
int y) {
return srcImage[width*y+x]; }
133 CPUTracker(
int w,
int h,
int xcorwindow=128,
bool testRun =
false);
145 bool CheckBoundaries(
vector2f center,
float radius);
158 vector2f ComputeXCorInterpolated(
vector2f initial,
int iterations,
int profileWidth,
bool& boundaryHit);
176 vector2f ComputeQI(
vector2f initial,
int iterations,
int radialSteps,
int angularStepsPerQuadrant,
177 float angStepIterationFactor,
float minRadius,
float maxRadius,
bool& boundaryHit,
float* radialweights=0);
233 float ComputeAsymmetry(
vector2f center,
int radialSteps,
int angularSteps,
float minRadius,
float maxRadius,
float *dstAngProf=0);
240 template<
typename TPixel>
void SetImage(TPixel* srcImage,
uint srcpitch);
260 void SetImageFloat(
float* srcImage);
266 void SaveImage(
const char *filename);
278 vector2f ComputeMeanAndCOM(
float bgcorrection=0.0f);
319 float ComputeZ(
vector2f center,
int angularSteps,
int zlutIndex,
bool* boundaryHit=0,
float* profile=0,
float* cmpprof=0,
bool normalizeProfile=
true)
321 float* prof = profile ? profile :
ALLOCA_ARRAY(
float, zlut_res);
322 ComputeRadialProfile(prof,zlut_res,angularSteps, zlut_minradius, zlut_maxradius, center,
false, boundaryHit, normalizeProfile);
323 return LUTProfileCompare(prof, zlutIndex, cmpprof, LUTProfMaxQuadraticFit);
330 void FourierTransform2D();
342 void FourierRadialProfile(
float* dst,
int radialSteps,
int angularSteps,
float minradius,
float maxradius);
350 void Normalize(
float *image=0);
368 void SetRadialZLUT(
float* data,
int planes,
int res,
int num_zluts,
float minradius,
float maxradius,
bool copyMemory,
bool useCorrelation);
375 void SetRadialWeights(
float* radweights);
381 LUTProfMaxSimpleInterp
390 void CalculateErrorCurve(
double* errorcurve_dest,
float* profile,
float* zlut_sel);
401 void CalculateInterpolatedZLUTProfile(
float* profile_dest,
float z,
int zlutIndex);
410 float CalculateErrorFlag(
double* prof1,
double* prof2);
422 float LUTProfileCompare(
float* profile,
int zlutIndex,
float* cmpProf,
LUTProfileMaxComputeMode maxPosMethod,
float* fitcurve=0,
int *maxPos=0,
int frameNum = 0);
432 float LUTProfileCompareAdjustedWeights(
float* rprof,
int zlutIndex,
float z_estim);
451 void ApplyOffsetGain(
float *offset,
float *gain,
float offsetFactor,
float gainFactor);
459 void AllocateQIFFTs(
int nsteps);
472 vector3f QuadrantAlign(
vector3f initial,
int beadIndex,
int angularStepsPerQuadrant,
bool& boundaryHit);
475 template<
typename TPixel>
480 for (
int y=0;y<height;y++) {
481 for (
int x=0;x<width;x++) {
482 srcImage[y*width+x] = ((TPixel*)bp)[x];
std::complex< float > * cbuf
Calculation buffer.
kissfft< scalar_t > * qa_fft_backward
Handle to backward FFT kissfft instance for quadrant align.
kissfft< scalar_t > * qi_fft_forward
Handle to forward FFT kissfft instance for QI.
XCor1DBuffer(int xcorw)
Constructs the buffer and initiates the FFT workers.
float zlut_maxradius
Maximum radius in pixels of the ZLUT profile sampling circle.
__device__ void ComputeQuadrantProfile(cudaImageListf &images, int idx, float *dst, const QIParams ¶ms, int quadrant, float2 center, float mean, int angularSteps)
kissfft< float > yfft
Handle to FFT kissfft instance for y.
float zlut_minradius
Minimum radius in pixels to start sampling for a ZLUT profile.
int zlut_planes
Number of planes per ZLUT.
Class with all CPU algorithm implementations.
void SetImage(TPixel *srcImage, uint srcpitch)
Set the image on which to perform the tracking.
int zlut_res
ZLUT resolution = number of radial steps in a plane.
bool testRun
Flag to enable running a test run.
std::vector< float > zlut_radialweights
Vector with the radialweights used by the error curve calculation.
int zlut_count
Number of ZLUTs (= # beads) available.
Structure to group results from the 2D Gaussian fit.
FFT2D * fft2d
Instance of FFT2D to perform 2D FFTs.
FFT2D(int w, int h)
Initialize the class.
void normalize(TPixel *d, uint w, uint h)
vector2f pos
Found position.
void SetImage8Bit(uchar *srcImage, uint srcpitch)
Set an image with 8 bit type.
__global__ void ApplyOffsetGain(BaseKernelParams kp, cudaImageListf calib_gain, cudaImageListf calib_offset, float gainFactor, float offsetFactor)
float stdev
Standard deviation of values in the ROI. Calculated in ComputeMeanAndCOM.
float & GetPixel(int x, int y)
Get the image pixel greyscale value at point (x,y).
int xcorw
Width of the cross correlation.
float * GetRadialZLUT(int index)
Get the start of the ZLUT of a specific bead.
float * srcImage
Memory region that holds the image on which tracking is to be performed.
int xcorw
Cross correlation profile length.
float mean
Mean intensity of the ROI. Calculated in ComputeMeanAndCOM.
kissfft< scalar_t > * qa_fft_forward
Handle to forward FFT kissfft instance for quadrant align.
float ComputeZ(vector2f center, int angularSteps, int zlutIndex, bool *boundaryHit=0, float *profile=0, float *cmpprof=0, bool normalizeProfile=true)
Helper function to calculate the Z position.
XCor1DBuffer * xcorBuffer
The handle from which to perform cross correlation calculations.
kissfft< scalar_t > fft_backward
Handle to backward FFT kissfft instance.
Class to facilitate 2D Fourier transforms.
float bg
Found fit parameter.
int GetWidth()
Get the width of the image.
float * debugImage
Memory in which an intermediate image can optionally be place and retrieved.
#define ALLOCA_ARRAY(T, N)
Default. Use a 7-point quadratic fit around the error curve's maximum.
int GetHeight()
Get the height of the image.
~FFT2D()
Free memory and delete the instance.
void XCorFFTHelper(complex_t *prof, complex_t *prof_rev, scalar_t *result)
Calculates a cross correlation much like https://en.wikipedia.org/wiki/Autocorrelation#Efficient_comp...
LUTProfileMaxComputeMode
Settings to compute the Z coordinate from the error curve.
Class to facilitate 1D cross correlation calculations.
kissfft< scalar_t > fft_forward
Handle to forward FFT kissfft instance.
std::vector< vector2f > quadrantDirs
Vector with the sampling points for a single quadrant (cos & sin pairs).
kissfft< float > xfft
Handle to FFT kissfft instance for x.
void ComputeRadialProfile(float *dst, int radialSteps, int angularSteps, float minradius, float maxradius, vector2f center, ImageData *img, float mean, bool normalize)
int qi_radialsteps
Number of radialsteps in the QI calculations.
float I0
Found fit parameter.
int trackerID
ID of this tracker (= ID of thread it runs in).
float * GetDebugImage()
Get the debug image.
kissfft< scalar_t > * qi_fft_backward
Handle to backward FFT kissfft instance for QI.
std::complex< scalar_t > complex_t
float * zluts
Pointer to the first data in the ZLUTs.
bool zlut_memoryOwner
Flag indicating if this instance is the owner of the zluts memory, or is it external. False in all normal operation.
void SetImage16Bit(ushort *srcImage, uint srcpitch)
Set an image with 16 bit type.