Commit 177c7863f6a825e7100590197c6f12b68a034841

Authored by David Mayerich
1 parent e433d0d4

updated the ENVI crop function to generate a header for the new file

Showing 1 changed file with 10 additions and 0 deletions   Show diff stats
stim/envi/envi.h
... ... @@ -1024,6 +1024,16 @@ public:
1024 1024 /// @param y1 is the upper-right y pixel coordinate to be included in the cropped image
1025 1025 bool crop(std::string outfile,unsigned x0, unsigned y0, unsigned x1, unsigned y1, unsigned b0, unsigned b1){
1026 1026  
  1027 + //save the header for the cropped file
  1028 + stim::envi_header new_header = header;
  1029 + new_header.samples = x1 - x0;
  1030 + new_header.lines = y1 - y0;
  1031 + new_header.bands = b1 - b0;
  1032 + std::vector<double>::const_iterator first = new_header.wavelength.begin() + b0;
  1033 + std::vector<double>::const_iterator last = new_header.wavelength.begin() + b1;
  1034 + new_header.wavelength = std::vector<double>(first, last);
  1035 + new_header.save(outfile + ".hdr");
  1036 +
1027 1037 if (header.interleave == envi_header::BSQ){
1028 1038 if (header.data_type == envi_header::float32)
1029 1039 return ((bsq<float>*)file)->crop(outfile, x0, y0, x1, y1, b0, b1);
... ...