diff --git a/envi/bil.h b/envi/bil.h index c1ae161..a577252 100644 --- a/envi/bil.h +++ b/envi/bil.h @@ -29,8 +29,6 @@ public: return open(filename, vec(X, Y, B), header_offset); - return false; - } //save one band of the file into the memory, and return the pointer @@ -56,6 +54,10 @@ public: bool band( T * p, double wavelength){ + //if there are no wavelengths in the BSQ file + if(w.size() == 0) + return band_index(p, (unsigned int)wavelength); + unsigned int XY = R[0] * R[1]; //calculate the number of pixels in a band unsigned int S = XY * sizeof(T); //calculate the number of bytes of a band diff --git a/envi/binary.h b/envi/binary.h index 4ecf8f3..12c81c2 100644 --- a/envi/binary.h +++ b/envi/binary.h @@ -22,10 +22,13 @@ protected: unsigned int header; //header size (in bytes) + + //basic initialization void init(){ memset(R, 0, sizeof(unsigned int) * D); //initialize the resolution to zero header = 0; //initialize the header size to zero + } //returns the file size diff --git a/envi/bip.h b/envi/bip.h index 06b59f0..77f4212 100644 --- a/envi/bip.h +++ b/envi/bip.h @@ -34,8 +34,6 @@ public: offset = header_offset; return open(filename, vec(X, Y, B), header_offset); - - return false; } @@ -60,6 +58,10 @@ public: bool band( T * p, double wavelength){ + //if there are no wavelengths in the BSQ file + if(w.size() == 0) + return band_index(p, (unsigned int)wavelength); + unsigned int XY = R[0] * R[1]; //calculate the number of pixels in a band unsigned page=0; //bands around the wavelength diff --git a/envi/bsq.h b/envi/bsq.h index 089b420..50c6cda 100644 --- a/envi/bsq.h +++ b/envi/bsq.h @@ -37,8 +37,6 @@ public: offset = header_offset; return open(filename, vec(X, Y, B), header_offset); - - return false; } @@ -61,8 +59,11 @@ public: //retrieve one band (specified by the wavelength) bool band( T * p, double wavelength){ - unsigned int XY = R[0] * R[1]; //calculate the number of pixels in a band + //if there are no wavelengths in the BSQ file + if(w.size() == 0) + return band_index(p, (unsigned int)wavelength); + unsigned int XY = R[0] * R[1]; //calculate the number of pixels in a band unsigned page=0; //bands around the wavelength diff --git a/envi/envi.h b/envi/envi.h index de7603f..29a23c5 100644 --- a/envi/envi.h +++ b/envi/envi.h @@ -506,6 +506,7 @@ public: return ((bsq*)file)->band((float*)ptr, wavelength); } + return false; } diff --git a/envi/envi_header.h b/envi/envi_header.h index 249cd89..009bb06 100644 --- a/envi/envi_header.h +++ b/envi/envi_header.h @@ -305,7 +305,7 @@ struct envi_header //make sure the number of bands matches the number of wavelengths unsigned int wavelengths = wavelength.size(); - if(bands != wavelengths) + if(wavelengths && bands != wavelengths) { std::cout<<"ENVI Header Error -- Number of wavelengths doesn't match the number of bands. Bands = "< 1) a = 1; -- libgit2 0.21.4