diff --git a/envi/bil.h b/envi/bil.h index 21dfdfa..9bdb7b7 100644 --- a/envi/bil.h +++ b/envi/bil.h @@ -309,7 +309,7 @@ public: } // normalize the BIL file - bool normalize(std::string outname, double w) + bool normalize(std::string outname, double w, double t = 0.0) { unsigned int B = R[2]; //calculate the number of bands unsigned int Y = R[1]; @@ -337,7 +337,10 @@ public: { for(unsigned m = 0; m < X; m++) { - c[m + i * X] = c[m + i * X] / b[m + j * X]; + if( b[m + j * X] < t ) + c[m + i * X] = (T)0.0; + else + c[m + i * X] = c[m + i * X] / b[m + j * X]; } } target.write(reinterpret_cast(c), L); //write normalized data into destination diff --git a/envi/bip.h b/envi/bip.h index 2f75e5f..33ff222 100644 --- a/envi/bip.h +++ b/envi/bip.h @@ -401,7 +401,7 @@ public: } // normalize the BIP file - bool normalize(std::string outname, double w) + bool normalize(std::string outname, double w, double t = 0.0) { unsigned int B = R[2]; //calculate the number of bands unsigned int Y = R[1]; @@ -431,7 +431,10 @@ public: unsigned iB = i * B; for(unsigned m = 0; m < B; m++) { - c[m + iB] = c[m + iB] / b[i + jX]; //perform normalization + if( b[i+jX] < t ) + c[m + iB] = (T)0.0; + else + c[m + iB] = c[m + iB] / b[i + jX]; //perform normalization } } target.write(reinterpret_cast(c), L); //write normalized data into destination diff --git a/envi/bsq.h b/envi/bsq.h index 8c475cb..154e549 100644 --- a/envi/bsq.h +++ b/envi/bsq.h @@ -252,7 +252,10 @@ public: } // normalize the BSQ file - bool normalize(std::string outname, double w) + // outname - output file name + // w - band to normalize to + // t - threshold (if w(c), S); //write normalized data into destination } diff --git a/envi/envi.h b/envi/envi.h index f87f601..0882f53 100644 --- a/envi/envi.h +++ b/envi/envi.h @@ -96,13 +96,13 @@ public: } //perform normalization - bool normalize(std::string outfile, double band){ + bool normalize(std::string outfile, double band, double threshold = 0.0){ if(header.interleave == envi_header::BSQ){ //if the infile is bsq file if(header.data_type ==envi_header::float32) - return ((bsq*)file)->normalize(outfile, band); + return ((bsq*)file)->normalize(outfile, band, threshold); else if(header.data_type == envi_header::float64) - return ((bsq*)file)->normalize(outfile,band); + return ((bsq*)file)->normalize(outfile,band, threshold); else std::cout<<"ERROR: unidentified data type"<