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 | 29 | |
30 | 30 | return open(filename, vec<unsigned int>(X, Y, B), header_offset); |
31 | 31 | |
32 | - return false; | |
33 | - | |
34 | 32 | } |
35 | 33 | |
36 | 34 | //save one band of the file into the memory, and return the pointer |
... | ... | @@ -56,6 +54,10 @@ public: |
56 | 54 | |
57 | 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 | 61 | unsigned int XY = R[0] * R[1]; //calculate the number of pixels in a band |
60 | 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 | 22 | unsigned int header; //header size (in bytes) |
23 | 23 | |
24 | 24 | |
25 | + | |
26 | + | |
25 | 27 | //basic initialization |
26 | 28 | void init(){ |
27 | 29 | memset(R, 0, sizeof(unsigned int) * D); //initialize the resolution to zero |
28 | 30 | header = 0; //initialize the header size to zero |
31 | + | |
29 | 32 | } |
30 | 33 | |
31 | 34 | //returns the file size | ... | ... |
envi/bip.h
... | ... | @@ -34,8 +34,6 @@ public: |
34 | 34 | offset = header_offset; |
35 | 35 | |
36 | 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 | 58 | |
61 | 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 | 65 | unsigned int XY = R[0] * R[1]; //calculate the number of pixels in a band |
64 | 66 | |
65 | 67 | unsigned page=0; //bands around the wavelength | ... | ... |
envi/bsq.h
... | ... | @@ -37,8 +37,6 @@ public: |
37 | 37 | offset = header_offset; |
38 | 38 | |
39 | 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 | 59 | //retrieve one band (specified by the wavelength) |
62 | 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 | 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 | 305 | |
306 | 306 | //make sure the number of bands matches the number of wavelengths |
307 | 307 | unsigned int wavelengths = wavelength.size(); |
308 | - if(bands != wavelengths) | |
308 | + if(wavelengths && bands != wavelengths) | |
309 | 309 | { |
310 | 310 | std::cout<<"ENVI Header Error -- Number of wavelengths doesn't match the number of bands. Bands = "<<bands<<", Wavelengths = "<<wavelength.size()<<std::endl; |
311 | 311 | exit(1); |
... | ... | @@ -365,10 +365,13 @@ struct envi_header |
365 | 365 | } |
366 | 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 | 376 | outfile.close(); |
374 | 377 | } | ... | ... |
visualization/colormap.h
... | ... | @@ -216,7 +216,6 @@ static void cpuApplyBrewer(T* cpuSource, unsigned char* cpuDest, unsigned int N, |
216 | 216 | for(int i=0; i<N; i++) |
217 | 217 | { |
218 | 218 | //compute the normalized value on [minVal maxVal] |
219 | - T v = cpuSource[i]; | |
220 | 219 | float a = (cpuSource[i] - minVal) / (maxVal - minVal); |
221 | 220 | if(a < 0) a = 0; |
222 | 221 | if(a > 1) a = 1; | ... | ... |