Commit ee4dea285cfc95a86578d9d804731343310f00ba
1 parent
517876d6
fixed errors in computing metrics.
Showing
7 changed files
with
24 additions
and
13 deletions
Show diff stats
envi/bil.h
@@ -29,8 +29,6 @@ public: | @@ -29,8 +29,6 @@ public: | ||
29 | 29 | ||
30 | return open(filename, vec<unsigned int>(X, Y, B), header_offset); | 30 | return open(filename, vec<unsigned int>(X, Y, B), header_offset); |
31 | 31 | ||
32 | - return false; | ||
33 | - | ||
34 | } | 32 | } |
35 | 33 | ||
36 | //save one band of the file into the memory, and return the pointer | 34 | //save one band of the file into the memory, and return the pointer |
@@ -56,6 +54,10 @@ public: | @@ -56,6 +54,10 @@ public: | ||
56 | 54 | ||
57 | bool band( T * p, double wavelength){ | 55 | bool band( T * p, double wavelength){ |
58 | 56 | ||
57 | + //if there are no wavelengths in the BSQ file | ||
58 | + if(w.size() == 0) | ||
59 | + return band_index(p, (unsigned int)wavelength); | ||
60 | + | ||
59 | unsigned int XY = R[0] * R[1]; //calculate the number of pixels in a band | 61 | unsigned int XY = R[0] * R[1]; //calculate the number of pixels in a band |
60 | unsigned int S = XY * sizeof(T); //calculate the number of bytes of a band | 62 | unsigned int S = XY * sizeof(T); //calculate the number of bytes of a band |
61 | 63 |
envi/binary.h
@@ -22,10 +22,13 @@ protected: | @@ -22,10 +22,13 @@ protected: | ||
22 | unsigned int header; //header size (in bytes) | 22 | unsigned int header; //header size (in bytes) |
23 | 23 | ||
24 | 24 | ||
25 | + | ||
26 | + | ||
25 | //basic initialization | 27 | //basic initialization |
26 | void init(){ | 28 | void init(){ |
27 | memset(R, 0, sizeof(unsigned int) * D); //initialize the resolution to zero | 29 | memset(R, 0, sizeof(unsigned int) * D); //initialize the resolution to zero |
28 | header = 0; //initialize the header size to zero | 30 | header = 0; //initialize the header size to zero |
31 | + | ||
29 | } | 32 | } |
30 | 33 | ||
31 | //returns the file size | 34 | //returns the file size |
envi/bip.h
@@ -34,8 +34,6 @@ public: | @@ -34,8 +34,6 @@ public: | ||
34 | offset = header_offset; | 34 | offset = header_offset; |
35 | 35 | ||
36 | return open(filename, vec<unsigned int>(X, Y, B), header_offset); | 36 | return open(filename, vec<unsigned int>(X, Y, B), header_offset); |
37 | - | ||
38 | - return false; | ||
39 | 37 | ||
40 | } | 38 | } |
41 | 39 | ||
@@ -60,6 +58,10 @@ public: | @@ -60,6 +58,10 @@ public: | ||
60 | 58 | ||
61 | bool band( T * p, double wavelength){ | 59 | bool band( T * p, double wavelength){ |
62 | 60 | ||
61 | + //if there are no wavelengths in the BSQ file | ||
62 | + if(w.size() == 0) | ||
63 | + return band_index(p, (unsigned int)wavelength); | ||
64 | + | ||
63 | unsigned int XY = R[0] * R[1]; //calculate the number of pixels in a band | 65 | unsigned int XY = R[0] * R[1]; //calculate the number of pixels in a band |
64 | 66 | ||
65 | unsigned page=0; //bands around the wavelength | 67 | unsigned page=0; //bands around the wavelength |
envi/bsq.h
@@ -37,8 +37,6 @@ public: | @@ -37,8 +37,6 @@ public: | ||
37 | offset = header_offset; | 37 | offset = header_offset; |
38 | 38 | ||
39 | return open(filename, vec<unsigned int>(X, Y, B), header_offset); | 39 | return open(filename, vec<unsigned int>(X, Y, B), header_offset); |
40 | - | ||
41 | - return false; | ||
42 | 40 | ||
43 | } | 41 | } |
44 | 42 | ||
@@ -61,8 +59,11 @@ public: | @@ -61,8 +59,11 @@ public: | ||
61 | //retrieve one band (specified by the wavelength) | 59 | //retrieve one band (specified by the wavelength) |
62 | bool band( T * p, double wavelength){ | 60 | bool band( T * p, double wavelength){ |
63 | 61 | ||
64 | - unsigned int XY = R[0] * R[1]; //calculate the number of pixels in a band | 62 | + //if there are no wavelengths in the BSQ file |
63 | + if(w.size() == 0) | ||
64 | + return band_index(p, (unsigned int)wavelength); | ||
65 | 65 | ||
66 | + unsigned int XY = R[0] * R[1]; //calculate the number of pixels in a band | ||
66 | unsigned page=0; //bands around the wavelength | 67 | unsigned page=0; //bands around the wavelength |
67 | 68 | ||
68 | 69 |
envi/envi.h
envi/envi_header.h
@@ -305,7 +305,7 @@ struct envi_header | @@ -305,7 +305,7 @@ struct envi_header | ||
305 | 305 | ||
306 | //make sure the number of bands matches the number of wavelengths | 306 | //make sure the number of bands matches the number of wavelengths |
307 | unsigned int wavelengths = wavelength.size(); | 307 | unsigned int wavelengths = wavelength.size(); |
308 | - if(bands != wavelengths) | 308 | + if(wavelengths && bands != wavelengths) |
309 | { | 309 | { |
310 | std::cout<<"ENVI Header Error -- Number of wavelengths doesn't match the number of bands. Bands = "<<bands<<", Wavelengths = "<<wavelength.size()<<std::endl; | 310 | std::cout<<"ENVI Header Error -- Number of wavelengths doesn't match the number of bands. Bands = "<<bands<<", Wavelengths = "<<wavelength.size()<<std::endl; |
311 | exit(1); | 311 | exit(1); |
@@ -365,10 +365,13 @@ struct envi_header | @@ -365,10 +365,13 @@ struct envi_header | ||
365 | } | 365 | } |
366 | outfile<<"}"<<std::endl; | 366 | outfile<<"}"<<std::endl; |
367 | } | 367 | } |
368 | - outfile<<"wavelength = {"<<std::endl; | ||
369 | - for(unsigned int i=0; i<wavelength.size()-1; i++) | ||
370 | - outfile<<wavelength[i]<<", "; | ||
371 | - outfile<<wavelength.back()<<"}"<<std::endl; | 368 | + //if there is a list of wavelengths, output it |
369 | + if(wavelength.size()){ | ||
370 | + outfile<<"wavelength = {"<<std::endl; | ||
371 | + for(unsigned int i=0; i<wavelength.size()-1; i++) | ||
372 | + outfile<<wavelength[i]<<", "; | ||
373 | + outfile<<wavelength.back()<<"}"<<std::endl; | ||
374 | + } | ||
372 | 375 | ||
373 | outfile.close(); | 376 | outfile.close(); |
374 | } | 377 | } |
visualization/colormap.h
@@ -216,7 +216,6 @@ static void cpuApplyBrewer(T* cpuSource, unsigned char* cpuDest, unsigned int N, | @@ -216,7 +216,6 @@ static void cpuApplyBrewer(T* cpuSource, unsigned char* cpuDest, unsigned int N, | ||
216 | for(int i=0; i<N; i++) | 216 | for(int i=0; i<N; i++) |
217 | { | 217 | { |
218 | //compute the normalized value on [minVal maxVal] | 218 | //compute the normalized value on [minVal maxVal] |
219 | - T v = cpuSource[i]; | ||
220 | float a = (cpuSource[i] - minVal) / (maxVal - minVal); | 219 | float a = (cpuSource[i] - minVal) / (maxVal - minVal); |
221 | if(a < 0) a = 0; | 220 | if(a < 0) a = 0; |
222 | if(a > 1) a = 1; | 221 | if(a > 1) a = 1; |