#include #include #include #include #include #include #include #include #include using Statistics::madfmToSigma; void atrous1DReconstruct(long &xdim, float *&input, float *&output, Param &par) { /** * A routine that uses the a trous wavelet method to reconstruct a * 1-dimensional spectrum. * The Param object "par" contains all necessary info about the filter and * reconstruction parameters. * * If all pixels are BLANK (and we are testing for BLANKs), the * reconstruction will simply give BLANKs back, so we return the * input array as the output array. * * \param xdim The length of the spectrum. * \param input The input spectrum. * \param output The returned reconstructed spectrum. This array needs to * be declared beforehand. * \param par The Param set. */ const float SNR_THRESH=par.getAtrousCut(); const int MIN_SCALE=par.getMinScale(); float blankPixValue = par.getBlankPixVal(); int numScales = par.filter().getNumScales(xdim); double *sigmaFactors = new double[numScales+1]; for(int i=0;i<=numScales;i++){ if(i<=par.filter().maxFactor(1)) sigmaFactors[i] = par.filter().sigmaFactor(1,i); else sigmaFactors[i] = sigmaFactors[i-1] / sqrt(2.); } float mean,sigma,originalSigma,originalMean,oldsigma,newsigma; bool *isGood = new bool[xdim]; int goodSize=0; for(int pos=0;pos=xdim)){ // boundary conditions are reflection. if(x<0) x = 0 - x; else if(x>=xdim) x = 2*(xdim-1) - x; } int filterpos = (xoffset+filterHW); int oldpos = x; if(isGood[oldpos]) wavelet[pos] -= filter[filterpos]*coeffs[oldpos]; } //-> end of xoffset loop } //-> end of else{ ( from if(!isGood[pos]) ) } //-> end of xpos loop // Need to do this after we've done *all* the convolving for(int pos=0;pos=MIN_SCALE){ array = new float[xdim]; goodSize=0; for(int pos=0;pos (mean+SNR_THRESH*originalSigma*sigmaFactors[scale]) ) output[pos] += wavelet[pos]; } } spacing *= 2; } //-> end of scale loop for(int pos=0;pos reconTolerance) ); if(par.isVerbose()) std::cout << "Completed "<