Commit d4aa4cf7e91c1ffb8d89f1a13ccde336031fafe4

Authored by David Mayerich
1 parent d0ef98e3

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

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