Commit d4aa4cf7e91c1ffb8d89f1a13ccde336031fafe4

Authored by David Mayerich
1 parent d0ef98e3

fixed the in-memory sifting functions for stim::envi to take NULL masks

stim/envi/bil.h
... ... @@ -884,7 +884,7 @@ public:
884 884 /// using the following indexing: i = p*B + b
885 885 /// @param matrix is the destination for the pixel data
886 886 /// @param mask is the mask
887   - bool sift(T* matrix, unsigned char* mask){
  887 + bool sift(T* matrix, unsigned char* mask = NULL){
888 888 size_t Lbytes = sizeof(T) * X();
889 889 T* line = (T*) malloc( Lbytes ); //allocate space for a line
890 890  
... ... @@ -897,7 +897,7 @@ public:
897 897 pl = 0; //initialize the pixel offset for the current line to zero (0)
898 898 file.read( (char*)line, Lbytes ); //read the current line
899 899 for(size_t x = 0; x < X(); x++){
900   - if(mask[y * X() + x]){ //if the current pixel is masked
  900 + if(mask == NULL || mask[y * X() + x]){ //if the current pixel is masked
901 901 size_t i = (p + pl) * Z() + b; //calculate the index in the sifted matrix
902 902 matrix[i] = line[x]; //store the current value in the line at the correct matrix location
903 903 pl++; //increment the pixel pointer
... ...
stim/envi/bip.h
... ... @@ -817,7 +817,7 @@ public:
817 817 /// using the following indexing: i = p*B + b
818 818 /// @param matrix is the destination for the pixel data
819 819 /// @param mask is the mask
820   - bool sift(T* matrix, unsigned char* mask){
  820 + bool sift(T* matrix, unsigned char* mask = NULL){
821 821 size_t Bbytes = sizeof(T) * Z();
822 822 size_t XY = X() * Y();
823 823 T* band = (T*) malloc( Bbytes ); //allocate space for a line
... ... @@ -826,7 +826,7 @@ public:
826 826  
827 827 size_t p = 0; //create counter variables
828 828 for(size_t xy = 0; xy < XY; xy++){ //for each pixel
829   - if(mask[xy]){ //if the current pixel is masked
  829 + if(mask == NULL || mask[xy]){ //if the current pixel is masked
830 830 file.read( (char*)band, Bbytes ); //read the current line
831 831 for(size_t b = 0; b < Z(); b++){ //copy each band value to the sifted matrix
832 832 size_t i = p * Z() + b; //calculate the index in the sifted matrix
... ...
stim/envi/bsq.h
... ... @@ -809,7 +809,7 @@ public:
809 809 /// using the following indexing: i = p*B + b
810 810 /// @param matrix is the destination for the pixel data
811 811 /// @param mask is the mask
812   - bool sift(T* matrix, unsigned char* mask){
  812 + bool sift(T* matrix, unsigned char* mask = NULL){
813 813 unsigned long long XY = X() * Y(); //Number of XY pixels
814 814 unsigned long long L = XY * sizeof(T); //size of XY plane (in bytes)
815 815  
... ...
stim/envi/envi.h
... ... @@ -665,7 +665,7 @@ public:
665 665 /// using the following indexing: i = b*P + p
666 666 /// @param matrix is the destination for the pixel data
667 667 /// @param p is the mask
668   - bool sift(void* matrix, unsigned char* p){
  668 + bool sift(void* matrix, unsigned char* p = NULL){
669 669  
670 670 if (header.interleave == envi_header::BSQ){ //if the infile is bsq file
671 671 if (header.data_type == envi_header::float32)
... ... @@ -1181,6 +1181,7 @@ public:
1181 1181 else if (header.interleave == envi_header::BIP){
1182 1182 if (header.data_type == envi_header::float32){
1183 1183 ((bip<float>*)file)->spectrum((float*)temp, n, PROGRESS);
  1184 + float test = ((float*)temp)[0];
1184 1185 cast<T, float>(ptr, (float*)temp, header.bands);
1185 1186 }
1186 1187 else if (header.data_type == envi_header::float64){
... ...
stim/parser/table.h
... ... @@ -34,6 +34,8 @@ namespace stim{
34 34 template<typename T>
35 35 T operator<<(T i){
36 36 std::stringstream ss;
  37 + if(std::is_fundamental<T>()) //if the data type is numeric
  38 + ss<<std::setprecision(std::numeric_limits<T>::digits10 + 3); //set the precision to account for all digits
37 39 ss<<i;
38 40 TABLE[y].push_back(ss.str());
39 41 x++;
... ...