void mglCanvas::DefaultPlotParam() { /* NOTE: following variables and mutex will not be changed by DefaultPlotParam() long InUse; ///< Smart pointer (number of users) mglFont *fnt; ///< Class for printing vector text int Quality; ///< Quality of plot (0x0-pure, 0x1-fast; 0x2-fine; 0x4 - low memory) int Width; ///< Width of the image int Height; ///< Height of the image int Depth; ///< Depth of the image int CurFrameId; ///< Number of automaticle created frames GifFileType *gif;*/ SetDrawReg(1,1,0); Perspective(0); memcpy(mgl_mask_val, mgl_mask_def, 16*sizeof(uint64_t)); // should be > 16*8 ax.Clear(); ay.Clear(); az.Clear(); ac.Clear(); mgl_clear_fft(); DefMaskAn=0; ResetMask(); SetTickRotate(true); SetTickSkip(true); SetWarn(mglWarnNone,""); mglGlobalMess = ""; ObjId = -1; HighId = INT_MIN; SetFunc(0,0); CutOff(0); Ternary(0); Stop=false; event_cb = NULL; event_par=NULL; SetRanges(mglPoint(-1,-1,-1,-1), mglPoint(1,1,1,1)); SetOrigin(NAN,NAN,NAN,NAN); SetBarWidth(0.7); SetMarkSize(1); SetArrowSize(1); SetAlphaDef(0.5); FontDef[0]=0; SetTranspType(0); SetMeshNum(0); // NOTE: default MeshNum=0 SetRotatedText(true); CurrPal = 0; SetLegendMarks(); SetFontSize(4); SetTuneTicks(3); SetAmbient(); SetDiffuse(); clr(MGL_DISABLE_SCALE); clr(MGL_USE_GMTIME); clr(MGL_NOSUBTICKS); SetDifLight(false); SetReduceAcc(false); SetDefScheme(MGL_DEF_SCH); SetPalette(MGL_DEF_PAL); SetPenPal("k-1"); Alpha(false); stack.clear(); Restore(); DefColor('k'); SetPlotFactor(0); InPlot(0,1,0,1,false); SetTickLen(0); SetCut(true); AdjustTicks("xyzc",true); Clf('w'); for(int i=0;i<10;i++) { AddLight(i, mglPoint(0,0,1)); Light(i,false); } Light(0,true); Light(false); SetDifLight(true); }
void ComparatorNoiseCorrector::CorrectComparatorNoise_internal( bool verbose, bool aggressive_correction, int row_start, int row_end, bool hfonly) { int phase=-1; memset(mComparator_sigs,0,mComparator_sigs_len); memset(mComparator_noise,0,mComparator_noise_len); memset(mComparator_hf_noise,0,mComparator_hf_noise_len); memset(mAvg_num,0,mAvg_num_len); memset(mComparator_mask,0,mComparator_mask_len); memset(mComparator_hf_mask,0,mComparator_hf_mask_len); memset(mCorrection,0,mCorrection_len); ncomp=4; if (row_start == -1) { row_start = 0; row_end = rows; } // first, create the average comparator signals // making sure to avoid pinned pixels SumColumns(row_start, row_end); double startTime=CNCTimer(); // subtract DC offset from average comparator signals SetMeanToZero(mComparator_sigs); #ifdef DBG_SAVETEMPS DebugSaveComparatorSigs(0); #endif // now figure out which pair of signals go together // this function also combines pairs of signals accordingly // from this point forward, there are only cols*2 signals to deal with phase = DiscoverComparatorPhase(mComparator_sigs,cols*4); // change the data to be column major for the rest of the functions... #ifdef DBG_SAVETEMPS DebugSaveComparatorSigs(1); #endif #ifdef DBG_SAVETEMPS DebugSaveAvgNum(); #endif tm1 += CNCTimer()-startTime; startTime = CNCTimer(); { ResetMask(); double tm2_1_startTime = CNCTimer(); // now neighbor-subtract the comparator signals NNSubtractComparatorSigs(mComparator_noise,mComparator_sigs,mComparator_mask,NNSpan,cols*ncomp,frames); // measure noise in the neighbor-subtracted signals CalcComparatorSigRMS(mComparator_rms,mComparator_noise,cols*ncomp,frames); // find the noisiest 10% MaskIQR(mComparator_mask,mComparator_rms,cols*ncomp); #ifdef DBG_SAVETEMPS DebugSaveComparatorNoise(0); DebugSaveComparatorRMS(0); DebugSaveComparatorMask(0); #endif // neighbor-subtract again...avoiding noisiest 10% NNSubtractComparatorSigs(mComparator_noise,mComparator_sigs,mComparator_mask,NNSpan,cols*ncomp,frames); // measure noise in the neighbor-subtracted signals CalcComparatorSigRMS(mComparator_rms,mComparator_noise,cols*ncomp,frames); ResetMask(); MaskIQR(mComparator_mask,mComparator_rms,cols*ncomp, verbose); // neighbor-subtract again...avoiding noisiest 10% NNSubtractComparatorSigs(mComparator_noise,mComparator_sigs,mComparator_mask,NNSpan,cols*ncomp,frames); #ifdef DBG_SAVETEMPS DebugSaveComparatorRMS(1); DebugSaveComparatorNoise(1); DebugSaveComparatorMask(1); #endif tm2_1 += CNCTimer()-tm2_1_startTime; if (aggressive_correction) { // Newly added stuff. // subtracts some of what we detect as comparator noise from neighbors before forming the nn average // this cleans things up a little double tm2_2_startTime = CNCTimer(); // make another set of noise signals that have been run through a high-pass filter // filter low frequency noise out of noise signals double tm2_3_startTime = CNCTimer(); memcpy(mComparator_hf_noise,mComparator_noise,sizeof(float)*cols*ncomp*frames); HighPassFilter(mComparator_hf_noise,cols*ncomp,frames,10); tm2_3 += CNCTimer() - tm2_3_startTime; // neighbor-subtract again...now with some rejection of what we think the noise is NNSubtractComparatorSigs(mComparator_noise,mComparator_sigs,mComparator_mask,NNSpan,cols*ncomp,frames,mComparator_hf_noise); // measure noise in the neighbor-subtracted signals CalcComparatorSigRMS(mComparator_rms,mComparator_noise,cols*ncomp,frames); ResetMask(); // MaskIQR(mComparator_mask,mComparator_rms,cols*2, verbose); MaskUsingDynamicStdCutoff(mComparator_mask,mComparator_rms,cols*ncomp,1.0f); // even if some comparators didn't make the cut with the raw noise signal // we can correct more agressively if we put the noise signal through the high pass filter // redo the high-pass fitler memcpy(mComparator_hf_noise,mComparator_noise,sizeof(float)*cols*ncomp*frames); // get first principal component GetPrincComp(mPcomp,mComparator_hf_noise,mComparator_mask,cols*ncomp,frames); FilterUsingPrincComp(mComparator_hf_noise,mPcomp,cols*ncomp,frames); // measure high frequency noise CalcComparatorSigRMS(mComparator_hf_rms,mComparator_hf_noise,cols*ncomp,frames); for ( int cndx=0;cndx < cols*ncomp;cndx++ ) { if ( mAvg_num[cndx] == 0 ) { mComparator_hf_mask[cndx] = 1; } } MaskUsingDynamicStdCutoff(mComparator_hf_mask,mComparator_hf_rms,cols*ncomp,2.0f); tm2_2 += CNCTimer()-tm2_2_startTime; } // blanks comparator signal averages that didn't have any pixels to average (probably redundant) for ( int cndx=0;cndx < cols*ncomp;cndx++ ) { float *cptr; if ( mAvg_num[cndx] == 0 ) { // get a pointer to where we will build the comparator signal average cptr = mComparator_sigs + cndx*frames; memset(cptr,0,sizeof(float[frames])); } } tm2 += CNCTimer()-startTime; BuildCorrection(hfonly); #ifdef DBG_SAVETEMPS DebugSaveCorrection(row_start, row_end); #endif ApplyCorrection(phase, row_start, row_end, mCorrection); } }