From 177c7863f6a825e7100590197c6f12b68a034841 Mon Sep 17 00:00:00 2001 From: David Mayerich Date: Wed, 2 Sep 2015 16:46:33 -0500 Subject: [PATCH] updated the ENVI crop function to generate a header for the new file --- stim/envi/envi.h | 10 ++++++++++ 1 file changed, 10 insertions(+), 0 deletions(-) diff --git a/stim/envi/envi.h b/stim/envi/envi.h index e104f31..240c49c 100644 --- a/stim/envi/envi.h +++ b/stim/envi/envi.h @@ -1024,6 +1024,16 @@ public: /// @param y1 is the upper-right y pixel coordinate to be included in the cropped image bool crop(std::string outfile,unsigned x0, unsigned y0, unsigned x1, unsigned y1, unsigned b0, unsigned b1){ + //save the header for the cropped file + stim::envi_header new_header = header; + new_header.samples = x1 - x0; + new_header.lines = y1 - y0; + new_header.bands = b1 - b0; + std::vector::const_iterator first = new_header.wavelength.begin() + b0; + std::vector::const_iterator last = new_header.wavelength.begin() + b1; + new_header.wavelength = std::vector(first, last); + new_header.save(outfile + ".hdr"); + if (header.interleave == envi_header::BSQ){ if (header.data_type == envi_header::float32) return ((bsq*)file)->crop(outfile, x0, y0, x1, y1, b0, b1); -- libgit2 0.21.4