diff --git a/stim/envi/bil.h b/stim/envi/bil.h index d9874a8..6c3189b 100644 --- a/stim/envi/bil.h +++ b/stim/envi/bil.h @@ -818,7 +818,7 @@ public: /// @param outfile is the name of the masked output file /// @param p is a pointer to memory of size X * Y, where p(i) = 0 for pixels that will be set to zero. - bool apply_mask(std::string outfile, unsigned char* p){ + bool apply_mask(std::string outfile, unsigned char* p, bool PROGRESS = false){ std::ofstream target(outfile.c_str(), std::ios::binary); @@ -842,6 +842,7 @@ public: } } target.write(reinterpret_cast(temp), L); //write a band data into target file + if(PROGRESS) progress = (double)(i+1) / (double)Y() * 100; } target.close(); free(temp); diff --git a/stim/envi/bip.h b/stim/envi/bip.h index 9807229..2b7b1f9 100644 --- a/stim/envi/bip.h +++ b/stim/envi/bip.h @@ -745,7 +745,7 @@ public: /// @param outfile is the name of the masked output file /// @param p is a pointer to memory of size X * Y, where p(i) = 0 for pixels that will be set to zero. - bool apply_mask(std::string outfile, unsigned char* p){ + bool apply_mask(std::string outfile, unsigned char* p, bool PROGRESS = false){ std::ofstream target(outfile.c_str(), std::ios::binary); @@ -768,6 +768,7 @@ public: } } target.write(reinterpret_cast(temp), L); //write the edited band data into target file + if(PROGRESS) progress = (double)(i+1) / (double)Y() * 100; } target.close(); //close the target file free(temp); //free allocated memory diff --git a/stim/envi/bsq.h b/stim/envi/bsq.h index b7f4e45..c969536 100644 --- a/stim/envi/bsq.h +++ b/stim/envi/bsq.h @@ -734,7 +734,7 @@ public: /// @param outfile is the name of the masked output file /// @param p is a pointer to memory of size X * Y, where p(i) = 0 for pixels that will be set to zero. - bool apply_mask(std::string outfile, unsigned char* p){ + bool apply_mask(std::string outfile, unsigned char* p, bool PROGRESS = false){ std::ofstream target(outfile.c_str(), std::ios::binary); @@ -756,6 +756,7 @@ public: } } target.write(reinterpret_cast(temp), L); //write the XY slice at that band to disk + if(PROGRESS) progress = (double)(i + 1) / (double)Z() * 100; } target.close(); free(temp); diff --git a/stim/envi/envi.h b/stim/envi/envi.h index 6d949e1..99bd357 100644 --- a/stim/envi/envi.h +++ b/stim/envi/envi.h @@ -541,32 +541,31 @@ public: /// @param outfile is the name of the resulting masked output file /// @param p is memory of size X*Y containing the mask (0 = false, all other values are true) - bool apply_mask(std::string outfile, unsigned char* p) + void apply_mask(std::string outfile, unsigned char* p, bool PROGRESS = false) { - header.save(outfile + ".hdr"); if (header.interleave == envi_header::BSQ){ //if the infile is bsq file if (header.data_type == envi_header::float32) - return ((bsq*)file)->apply_mask(outfile, p); + ((bsq*)file)->apply_mask(outfile, p, PROGRESS); else if (header.data_type == envi_header::float64) - return ((bsq*)file)->apply_mask(outfile, p); + ((bsq*)file)->apply_mask(outfile, p, PROGRESS); else std::cout << "ERROR: unidentified data type" << std::endl; } else if (header.interleave == envi_header::BIL){ //if the infile is bil file if (header.data_type == envi_header::float32) - return ((bil*)file)->apply_mask(outfile, p); + ((bil*)file)->apply_mask(outfile, p, PROGRESS); else if (header.data_type == envi_header::float64) - return ((bil*)file)->apply_mask(outfile, p); + ((bil*)file)->apply_mask(outfile, p, PROGRESS); else std::cout << "ERROR: unidentified data type" << std::endl; } else if (header.interleave == envi_header::BIP){ //if the infile is bip file if (header.data_type == envi_header::float32) - return ((bip*)file)->apply_mask(outfile, p); + ((bip*)file)->apply_mask(outfile, p, PROGRESS); else if (header.data_type == envi_header::float64) - return ((bip*)file)->apply_mask(outfile, p); + ((bip*)file)->apply_mask(outfile, p, PROGRESS); else std::cout << "ERROR: unidentified data type" << std::endl; } @@ -575,7 +574,7 @@ public: std::cout << "ERROR: unidentified file type" << std::endl; exit(1); } - return false; + header.save(outfile + ".hdr"); } /// Copies all spectra corresponding to nonzero values of a mask into a pre-allocated matrix of size (P x B) -- libgit2 0.21.4