envi.h
1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef STIM_ENVI_H
#define STIM_ENVI_H
#include "../envi/envi_header.h"
#include "../envi/bsq.h"
#include "../envi/bip.h"
#include "../envi/bil.h"
namespace rts{
//container class for an ENVI binary file reader
class envi{
envi_header header;
void* file; //void pointer to the relevant file reader (bip, bsq, or bil - with appropriate data type)
public:
bool allocate(){
file = NULL; //set file to a NULL pointer
if(header.interleave == envi_header::BSQ)
if(header.data_type ==envi_header::float32)
return(file = new bsq<float>());
exit(1); //if the function hasn't already returned, we don't handle this state
}
bool open(std::string filename, std::string headername){
//allocate memory
allocate();
//load the header
header.load(headername);
//load the file
if(header.interleave == envi_header::BSQ)
if(header.data_type ==envi_header::float32)
return ((bsq<float>*)file)->open(filename, header.samples, header.lines, header.bands, header.header_offset, header.wavelength);
//handle other permutations.....
exit(1);
}
bool normalize(std::string outfile, double band){
if(header.interleave == envi_header::BSQ)
if(header.data_type ==envi_header::float32)
return ((bsq<float>*)file)->normalize(outfile, band);
exit(1);
}
bool save_header(std::string filename){
//save the header file here
header.save(filename);
return true;
}
};
} //end namespace rts
#endif