From 3d0b6243c6e8fe045c1aeef57b785c1a32711531 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 2 Mar 2016 13:49:08 -0600 Subject: [PATCH] fixed hsiproc bugs, added insert() method into stim::filename, added Matlab function to save ENVI files --- stim/envi/binary.h | 2 +- stim/envi/bsq.h | 61 +++++++++++++++++++++++++++++-------------------------------- stim/envi/envi.h | 15 +++++++++++++-- stim/envi/envi_header.h | 3 +++ stim/image/image.h | 22 ++++++++++++++++++++++ stim/parser/filename.h | 20 ++++++++++++++++++++ 6 files changed, 88 insertions(+), 35 deletions(-) diff --git a/stim/envi/binary.h b/stim/envi/binary.h index 22dafec..5483a3d 100644 --- a/stim/envi/binary.h +++ b/stim/envi/binary.h @@ -81,7 +81,7 @@ protected: //if the file isn't open, the user may only have read access if(!file.is_open()){ - std::cout<<"class BINARY - failed to open file, trying for read only"< operator=(T v){ + + unsigned int X = width() * height() * depth() * channels(); + + for(unsigned x = 0; x < X; x++) + img.data()[x] = v; + + return *this; + + } + /// Copy the given data to the specified channel /// @param c is the channel number that the data will be copied to @@ -134,6 +152,10 @@ public: return img.height(); } + unsigned int depth(){ + return img.depth(); + } + T* data(){ return img.data(); diff --git a/stim/parser/filename.h b/stim/parser/filename.h index 69e9ba0..d7f221a 100644 --- a/stim/parser/filename.h +++ b/stim/parser/filename.h @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -290,6 +291,25 @@ public: return result; } + /// This function replaces a wildcard in the prefix with the specified string + stim::filename insert(std::string str){ + + stim::filename result = *this; //initialize the result filename to the current filename + size_t loc = result.prefix.find('*'); //find a wild card in the string + if(loc == std::string::npos) //if a wildcard isn't found + return result; //return the original string + + result.prefix.replace(loc, 1, str); //replace the wildcard with the string + return result; //return the result + } + + stim::filename insert(unsigned i, unsigned int n = 2){ + + std::stringstream ss; + ss << std::setw(n) << std::setfill('0') << i; + return insert(ss.str()); + } + bool is_relative(){ return !absolute; } -- libgit2 0.21.4