#include #include #include #include #include #include #include #include #include using Statistics::madfmToSigma; using std::endl; using std::setw; void atrous3DReconstruct(long &xdim, long &ydim, long &zdim, float *&input, float *&output, Param &par) { /** * A routine that uses the a trous wavelet method to reconstruct a * 3-dimensional image cube. * The Param object "par" contains all necessary info about the filter and * reconstruction parameters. * * If there are no non-BLANK pixels (and we are testing for * BLANKs), the reconstruction cannot be done, so we return the * input array as the output array and give a warning message. * * \param xdim The length of the x-axis. * \param ydim The length of the y-axis. * \param zdim The length of the z-axis. * \param input The input spectrum. * \param output The returned reconstructed spectrum. This array needs to be declared beforehand. * \param par The Param set. */ long size = xdim * ydim * zdim; long spatialSize = xdim * ydim; long mindim = xdim; if (ydimct1)&&(par.isBlank(input[row*xdim+ct2]))) ct2--; xLim1[row] = ct1; xLim2[row] = ct2; avGapX += ct2 - ct1 + 1; } avGapX /= float(ydim); for(int col=0;colct1)&&(par.isBlank(input[col+xdim*ct2]))) ct2--; yLim1[col] = ct1; yLim2[col] = ct2; avGapY += ct2 - ct1 + 1; } avGapY /= float(xdim); mindim = int(avGapX); if(avGapY < avGapX) mindim = int(avGapY); numScales = par.filter().getNumScales(mindim); } float threshold; int iteration=0; newsigma = 1.e9; for(int i=0;i=zdim) z = 2*(zdim-1) - z; // reflection. int oldchan = z * spatialSize; for(int yoffset=-filterHW; yoffset<=filterHW; yoffset++){ int y = ypos + spacing*yoffset; // Boundary conditions -- assume reflection at boundaries. // Use limits as calculated above if(yLim1[xpos]!=yLim2[xpos]){ // if these are equal we will get into an infinite loop while((yyLim2[xpos])){ if(yyLim2[xpos]) y = 2*yLim2[xpos] - y; } } int oldrow = y * xdim; for(int xoffset=-filterHW; xoffset<=filterHW; xoffset++){ int x = xpos + spacing*xoffset; // Boundary conditions -- assume reflection at boundaries. // Use limits as calculated above if(xLim1[ypos]!=xLim2[ypos]){ // if these are equal we will get into an infinite loop while((xxLim2[ypos])){ if(xxLim2[ypos]) x = 2*xLim2[ypos] - x; } } int oldpos = oldchan + oldrow + x; filterpos++; if(isGood[oldpos]) wavelet[pos] -= filter[filterpos]*coeffs[oldpos]; } //-> end of xoffset loop } //-> end of yoffset loop } //-> end of zoffset loop } //-> end of else{ ( from if(!isGood[pos]) ) } //-> end of xpos loop } //-> end of ypos loop } //-> end of zpos loop // Need to do this after we've done *all* the convolving for(int pos=0;pos=par.getMinScale()){ array = new float[size]; goodSize=0; for(int pos=0;pos threshold ){ output[pos] += wavelet[pos]; // only add to the output if the wavelet coefficient is significant } } } spacing *= 2; // double the scale of the filter. } //-> end of scale loop for(int pos=0;pos reconTolerance) ); if(par.isVerbose()) std::cout << "Completed "<