#include #include #include #include #include using std::endl; using std::setw; void atrous1DReconstruct(long &xdim, float *&input,float *&output, Param &par) { /** * atrous1DReconstruct(xdim, input, output, 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, although a Filter object has to be declared * elsewhere previously. * The input array is in "input", of length "xdim", and the reconstructed * array is in "output". */ extern Filter reconFilter; const float SNR_THRESH=par.getAtrousCut(); const int MIN_SCALE=par.getMinScale(); bool flagBlank=par.getFlagBlankPix(); float blankPixValue = par.getBlankPixVal(); int numScales = reconFilter.getNumScales(xdim); double *sigmaFactors = new double[numScales+1]; for(int i=0;i<=numScales;i++){ if(i<=reconFilter.maxFactor(1)) sigmaFactors[i] = reconFilter.sigmaFactor(1,i); else sigmaFactors[i] = sigmaFactors[i-1] / sqrt(2.); } float mean,sigma,originalSigma,originalMean,oldsigma,newsigma; bool *isGood = new bool[xdim]; for(int pos=0;pos=xdim)){ if(x<0) x = 0 - x; // boundary conditions are else if(x>=xdim) x = 2*(xdim-1) - x; // reflection. } 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 "<