455 vector3f delta(0.001f,0.001f, 0.001f);
463 WriteJPEGFile( std::string(lutfile).substr(0, strlen(lutfile)-4).append(
"_bmlut.jpg").c_str(), lut );
474 std::vector<float> stdv;
484 trk.ComputeZBiasCorrection(lut.
h*10, &result, 4,
true);
496 trk.SetRadialWeights(&w[0]);
510 std::vector<vector3f> truepos, positions,crlb;
511 std::vector<float> stdevz;
512 for (
uint i=0;i<nstep;i++)
514 float z = 1 + i / (float)nstep * (rescaledLUT.
h-2);
516 truepos.push_back(pos);
518 crlb.push_back(
sqrt(invFisherLUT.
diag()));
522 for (
uint j=0;j<smpPerStep; j++) {
523 vector3f rndvec(rand_uniform<float>(), rand_uniform<float>(), rand_uniform<float>());
530 trk.ScheduleImageData(&img, &job);
531 positions.push_back(rndpos);
536 dbgprintf(
"[%d] z=%f Min std deviation: X=%f, Y=%f, Z=%f.\n", i, z, crlb[i].x,crlb[i].y,crlb[i].z);
540 std::vector<vector3f> trkmean(nstep), trkstd(nstep);
541 std::vector<vector3f> resultpos(nstep*smpPerStep);
542 for (
uint i=0;i<positions.size();i++) {
544 trk.FetchResults(&lr, 1);
547 for (
uint i=0;i<nstep;i++) {
548 for (
uint j=0;j<smpPerStep;j ++) {
549 vector3f err=resultpos[i*smpPerStep+j]-positions[i*smpPerStep+j];
552 trkmean[i]/=smpPerStep;
554 for (
uint j=0;j<smpPerStep;j ++) {
555 vector3f r = resultpos[i*smpPerStep+j];
556 vector3f t = positions[i*smpPerStep+j];;
562 dbgprintf(
"Result: x=%f,y=%f,z=%f. True: x=%f,y=%f,z=%f\n", r.
x,r.
y,r.
z,t.x,t.y,t.z);
566 else trkstd[i] =
sqrt(variance / (smpPerStep-1));
570 std::vector<float> output;
571 for(
uint i=0;i<nstep;i++) {
572 dbgprintf(
"trkstd[%d]:%f crlb=%f bias=%f true=%f\n", i, trkstd[i].z, crlb[i].z, trkmean[i].z, truepos[i].z);
573 output.push_back(truepos[i].z);
574 output.push_back(trkmean[i].x);
575 output.push_back(trkstd[i].x);
576 output.push_back(trkmean[i].z);
577 output.push_back(trkstd[i].z);
578 output.push_back(crlb[i].x);
579 output.push_back(crlb[i].z);
581 mean_std += trkstd[i];
583 dbgprintf(
"mean z err: %f\n", (mean_std/nstep).z);
584 WriteImageAsCSV(
SPrintf(
"%s_%d_flags%d_cl%d.txt",name, weightMode, extraFlags,clean_lut).c_str(), &output[0], 7, output.size()/7);
float zlut_minradius
Distance in pixels from the bead center from which to start sampling profiles. Default 1...
static double WaitForFinish(QueuedTracker *qtrk, int N)
float qi_minradius
Distance in pixels from the bead center from which to start sampling profiles. Default 1...
int width
Width of regions of interest to be handled. Typically equals height (square ROI). ...
static void CleanupLUT(ImageData &lut)
void ResampleLUT(T *qtrk, ImageData *lut, int zplanes, ImageData *newlut, const char *jpgfile=0, uint buildLUTFlags=0)
ImageData ReadLUTFile(const char *lutfile)
void GenerateImageFromLUT(ImageData *image, ImageData *zlut, float minradius, float maxradius, vector3f pos, bool splineInterp, int oversampleSubdiv)
void WriteJPEGFile(uchar *data, int w, int h, const char *filename, int quality)
Structure for job results.
int height
Height of regions of interest to be handled. Typically equals width (square ROI). ...
int zlut_radialsteps
Number of radial steps to sample on.
vector3< T > sqrt(const vector3< T > &a)
uint frame
Frame number this ROI belongs to.
static TImageData alloc(int w, int h)
std::vector< float > ComputeRadialBinWindow(int rsteps)
Calculate the radial weights for ZLUT profile comparisons.
Matrix3X3 Inverse() const
void Update()
Compute the derived settings.
vector3f pos
Final 3D position found. If no z localization was performed, the value of z will be 0...
Normalize found radial profiles.
LocalizationJob job
Job metadata. See LocalizationJob.
CPU implementation of the QueuedTracker interface.
Structure for derived settings computed from base settings in QTrkSettings.
vector3< float > vector3f
void dbgprintf(const char *fmt,...)
int qi_iterations
Number of times to run the QI algorithm, sampling around the last found position. ...
void WriteImageAsCSV(const char *file, float *d, int w, int h, const char *labels[])
Structure for region of interest metadata.
float zlut_maxradius
Max radius in pixels of the sampling circle.
std::string SPrintf(const char *fmt,...)
Do a ZLUT lookup with adjusted weights, for testing purposes.
void ApplyPoissonNoise(ImageData &img, float poissonMax, float maxval)