[pktools] 126/375: support scramble and shift in pkfilter clean up of using namespace std in header files

Bas Couwenberg sebastic at xs4all.nl
Wed Dec 3 21:54:06 UTC 2014


This is an automated email from the git hooks/post-receive script.

sebastic-guest pushed a commit to branch upstream-master
in repository pktools.

commit 18957a35c7a95ed71933014d74c1d97dc252cb39
Author: Pieter Kempeneers <kempenep at gmail.com>
Date:   Wed Aug 28 16:55:42 2013 +0200

    support scramble and shift in pkfilter clean up of using namespace std in header files
---
 ChangeLog                         |   3 +
 src/algorithms/ConfusionMatrix.cc |  26 +++----
 src/algorithms/ConfusionMatrix.h  |  32 ++++----
 src/algorithms/Egcs.cc            |  42 +++++------
 src/algorithms/Egcs.h             |  10 +--
 src/algorithms/FeatureSelector.h  |  81 ++++++++++----------
 src/algorithms/Filter.h           |  79 ++++++++++----------
 src/algorithms/Filter2d.cc        |  29 ++++++++
 src/algorithms/Filter2d.h         | 152 +++++++++++++++++++++++++++++++-------
 src/apps/pkfillnodata.cc          |  27 +++----
 src/apps/pkfilter.cc              |  18 ++++-
 src/base/IndexValue.h             |   2 -
 src/base/Optionpk.h               |  30 ++++----
 src/base/Vector2d.h               |  47 ++++++------
 src/imageclasses/ImgReaderGdal.cc |  60 +++++++--------
 src/imageclasses/ImgReaderGdal.h  |  64 ++++++++--------
 src/imageclasses/ImgReaderOgr.cc  |  30 ++++----
 src/imageclasses/ImgReaderOgr.h   | 132 ++++++++++++++++-----------------
 18 files changed, 500 insertions(+), 364 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9ea47d5..19ccbe1 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -117,5 +117,8 @@ version 2.4.1
 	todo: take priors into account for cross validation
 	ordering of labels before training
 version 2.4.2
+ - clean up of using namespace std in header files
  - pkinfo
 	bug fixed with -min and -max
+ - pkfilter
+	new methods for scrambling and shifting images
diff --git a/src/algorithms/ConfusionMatrix.cc b/src/algorithms/ConfusionMatrix.cc
index a9a04f4..02a4653 100644
--- a/src/algorithms/ConfusionMatrix.cc
+++ b/src/algorithms/ConfusionMatrix.cc
@@ -21,7 +21,7 @@ along with pktools.  If not, see <http://www.gnu.org/licenses/>.
 #include <iostream>
 #include <numeric>
 
-bool compareClass(const string& string1, const string& string2){
+bool compareClass(const std::string& string1, const std::string& string2){
   int int1=string2type<int>(string1);
   int int2=string2type<int>(string2);
   return(int1<int2);
@@ -41,7 +41,7 @@ ConfusionMatrix::ConfusionMatrix(short nclass){
   resize(nclass);
 }
 
-ConfusionMatrix::ConfusionMatrix(const vector<string>& classNames){
+ConfusionMatrix::ConfusionMatrix(const std::vector<std::string>& classNames){
   setClassNames(classNames);
 }
 
@@ -107,14 +107,14 @@ ConfusionMatrix ConfusionMatrix::operator*(double weight)
 void ConfusionMatrix::resize(short nclass){
   m_classes.resize(nclass);
   for(short iclass=0;iclass<nclass;++iclass){
-    ostringstream osclass;
+    std::ostringstream osclass;
     osclass << iclass;
     m_classes[iclass]=osclass.str();
   }
   m_results.resize(nclass,nclass);
 }
 
-void ConfusionMatrix::setClassNames(const vector<string>& classNames, bool doSort){
+void ConfusionMatrix::setClassNames(const std::vector<std::string>& classNames, bool doSort){
   m_classes=classNames;
   if(doSort)
     sortClassNames();
@@ -122,7 +122,7 @@ void ConfusionMatrix::setClassNames(const vector<string>& classNames, bool doSor
     m_results.resize(m_classes.size(),m_classes.size());
 }
 
-void ConfusionMatrix::pushBackClassName(const string& className, bool doSort){
+void ConfusionMatrix::pushBackClassName(const std::string& className, bool doSort){
   m_classes.push_back(className);
   if(doSort)
     sortClassNames();
@@ -140,7 +140,7 @@ void ConfusionMatrix::clearResults(){
   m_results.resize(m_classes.size(),m_classes.size());
 }
 
-void ConfusionMatrix::setResult(const string& theRef, const string& theClass, double theResult){
+void ConfusionMatrix::setResult(const std::string& theRef, const std::string& theClass, double theResult){
   // int ir=distance(m_classes.begin(),find(m_classes.begin(),m_classes.end(),theRef));
   // int ic=distance(m_classes.begin(),find(m_classes.begin(),m_classes.end(),theClass));
   // assert(ir>=0);
@@ -152,7 +152,7 @@ void ConfusionMatrix::setResult(const string& theRef, const string& theClass, do
   m_results[ir][ic]=theResult;
 }
 
-void ConfusionMatrix::incrementResult(const string& theRef, const string& theClass, double theIncrement){
+void ConfusionMatrix::incrementResult(const std::string& theRef, const std::string& theClass, double theIncrement){
   int ir=distance(m_classes.begin(),find(m_classes.begin(),m_classes.end(),theRef));
   int ic=distance(m_classes.begin(),find(m_classes.begin(),m_classes.end(),theClass));
   assert(ir>=0);
@@ -164,7 +164,7 @@ void ConfusionMatrix::incrementResult(const string& theRef, const string& theCla
   m_results[ir][ic]+=theIncrement;
 }
 
-double ConfusionMatrix::nReference(const string& theRef) const{
+double ConfusionMatrix::nReference(const std::string& theRef) const{
   int ir=distance(m_classes.begin(),find(m_classes.begin(),m_classes.end(),theRef));
   return accumulate(m_results[ir].begin(),m_results[ir].end(),0);
 }
@@ -176,7 +176,7 @@ double ConfusionMatrix::nReference() const{
   return nref;
 }
 
-double ConfusionMatrix::nClassified(const string& theClass) const{
+double ConfusionMatrix::nClassified(const std::string& theClass) const{
   int ic=distance(m_classes.begin(),find(m_classes.begin(),m_classes.end(),theClass));
   double nclassified=0;
   for(int iref=0;iref<m_results.size();++iref){
@@ -186,7 +186,7 @@ double ConfusionMatrix::nClassified(const string& theClass) const{
   return(nclassified);
 }
 
-double ConfusionMatrix::pa(const string& theClass, double* se95) const{
+double ConfusionMatrix::pa(const std::string& theClass, double* se95) const{
   assert(m_results.size());
   assert(m_results.size()==m_classes.size());
   double producer=0;
@@ -205,7 +205,7 @@ double ConfusionMatrix::pa(const string& theClass, double* se95) const{
   return dpa;
 }
 
-int ConfusionMatrix::pa_pct(const string& theClass, double* se95) const{
+int ConfusionMatrix::pa_pct(const std::string& theClass, double* se95) const{
   double dpa=pa(theClass,se95);
   if(se95!=NULL)
     *se95=static_cast<double>(static_cast<int>(0.5+1000*(*se95)))/10.0;
@@ -213,7 +213,7 @@ int ConfusionMatrix::pa_pct(const string& theClass, double* se95) const{
 }
     
 
-double ConfusionMatrix::ua(const string& theClass, double* se95) const{
+double ConfusionMatrix::ua(const std::string& theClass, double* se95) const{
   assert(m_results.size());
   assert(m_results.size()==m_classes.size());
   double user=0;
@@ -231,7 +231,7 @@ double ConfusionMatrix::ua(const string& theClass, double* se95) const{
   return dua;
 }
 
-int ConfusionMatrix::ua_pct(const string& theClass,double* se95) const{
+int ConfusionMatrix::ua_pct(const std::string& theClass,double* se95) const{
   double dua=ua(theClass,se95);
   if(se95!=NULL)
     *se95=static_cast<double>(static_cast<int>(0.5+1000*(*se95)))/10.0;
diff --git a/src/algorithms/ConfusionMatrix.h b/src/algorithms/ConfusionMatrix.h
index e079eb9..fd3edc0 100644
--- a/src/algorithms/ConfusionMatrix.h
+++ b/src/algorithms/ConfusionMatrix.h
@@ -25,29 +25,27 @@ along with pktools.  If not, see <http://www.gnu.org/licenses/>.
 #include "base/Vector2d.h"
 #include "base/Optionpk.h"
 
-using namespace std;
-
 class ConfusionMatrix{
 public:
   ConfusionMatrix();
   ConfusionMatrix(short nclass);
-  ConfusionMatrix(const vector<string>& classNames);
+  ConfusionMatrix(const std::vector<std::string>& classNames);
   ConfusionMatrix(const ConfusionMatrix& cm);
   ConfusionMatrix& operator=(const ConfusionMatrix& cm);
   short size() const {return m_results.size();};
   void resize(short nclass);
-  void setClassNames(const vector<string>& classNames, bool doSort=false);
-  void pushBackClassName(const string& className, bool doSort=false);
+  void setClassNames(const std::vector<std::string>& classNames, bool doSort=false);
+  void pushBackClassName(const std::string& className, bool doSort=false);
   void setResults(const Vector2d<double>& theResults);
-  void setResult(const string& theRef, const string& theClass, double theResult);
-  void incrementResult(const string& theRef, const string& theClass, double theIncrement);
+  void setResult(const std::string& theRef, const std::string& theClass, double theResult);
+  void incrementResult(const std::string& theRef, const std::string& theClass, double theIncrement);
   void clearResults();
-  double nReference(const string& theRef) const;
+  double nReference(const std::string& theRef) const;
   double nReference() const;
-  double nClassified(const string& theRef) const;
+  double nClassified(const std::string& theRef) const;
   int nClasses() const {return m_classes.size();};
-  string getClass(int iclass) const {assert(iclass>=0);assert(iclass<m_classes.size());return m_classes[iclass];};
-  int getClassIndex(string className) const {
+  std::string getClass(int iclass) const {assert(iclass>=0);assert(iclass<m_classes.size());return m_classes[iclass];};
+  int getClassIndex(std::string className) const {
     int index=distance(m_classes.begin(),find(m_classes.begin(),m_classes.end(),className));
     assert(index>=0);
     if(index<m_results.size())
@@ -55,13 +53,13 @@ public:
     else
       return(-1);
   }
-  vector<string> getClassNames() const {return m_classes;};
+  std::vector<std::string> getClassNames() const {return m_classes;};
   ~ConfusionMatrix();
-  double pa(const string& theClass, double* se95=NULL) const;
-  double ua(const string& theClass, double* se95=NULL) const;
+  double pa(const std::string& theClass, double* se95=NULL) const;
+  double ua(const std::string& theClass, double* se95=NULL) const;
   double oa(double* se95=NULL) const;
-  int pa_pct(const string& theClass, double* se95=NULL) const;
-  int ua_pct(const string& theClass, double* se95=NULL) const;
+  int pa_pct(const std::string& theClass, double* se95=NULL) const;
+  int ua_pct(const std::string& theClass, double* se95=NULL) const;
   int oa_pct(double* se95=NULL) const;
   double kappa() const;
   ConfusionMatrix& operator*=(double weight);
@@ -85,7 +83,7 @@ public:
     return os;
   };
 private:
-  vector<string> m_classes;
+  std::vector<std::string> m_classes;
   Vector2d<double> m_results;
 };
 
diff --git a/src/algorithms/Egcs.cc b/src/algorithms/Egcs.cc
index dc286b3..ddbf20b 100644
--- a/src/algorithms/Egcs.cc
+++ b/src/algorithms/Egcs.cc
@@ -36,13 +36,13 @@ Egcs::Egcs(unsigned short level)
   m_level=level;
 }
 
-unsigned short Egcs::cell2level(const string& cellCode) const{
+unsigned short Egcs::cell2level(const std::string& cellCode) const{
   size_t pos=cellCode.find("-");
-  string TILE=cellCode.substr(0,pos);
+  std::string TILE=cellCode.substr(0,pos);
   unsigned short level=0;
   int base_level=19-(TILE.size()/2-1)*3;
   int quad_level=0;
-  if(pos!=string::npos)
+  if(pos!=std::string::npos)
     quad_level=cellCode.size()-pos-1;
   if(quad_level>1)
     level=base_level-2;
@@ -94,15 +94,15 @@ void Egcs::force2grid(double& ulx, double& uly, double& lrx, double &lry) const{
   lry-=static_cast<int>(lry)%(static_cast<int>(dy));
 }
 
-void Egcs::cell2bb(const string& cellCode, int &ulx, int &uly, int &lrx, int &lry) const{
+void Egcs::cell2bb(const std::string& cellCode, int &ulx, int &uly, int &lrx, int &lry) const{
   size_t pos=cellCode.find("-");
-  string TILE=cellCode.substr(0,pos);
-  string TILEX=TILE.substr(0,TILE.size()/2);
-  string TILEY=TILE.substr(TILE.size()/2);
-  string QUAD;
+  std::string TILE=cellCode.substr(0,pos);
+  std::string TILEX=TILE.substr(0,TILE.size()/2);
+  std::string TILEY=TILE.substr(TILE.size()/2);
+  std::string QUAD;
   char QUAD1,QUAD2;
-  istringstream stilex(TILEX);
-  istringstream stiley(TILEY);
+  std::istringstream stilex(TILEX);
+  std::istringstream stiley(TILEY);
   int llx,lly;
   stilex >> llx;
   stiley >> lly;
@@ -110,10 +110,10 @@ void Egcs::cell2bb(const string& cellCode, int &ulx, int &uly, int &lrx, int &lr
   lly*=getBaseSize();
   switch((19-m_level)%3){
   case(0)://there should be no QUAD
-    assert(pos==string::npos);
+    assert(pos==std::string::npos);
     break;
   case(2)://there is a QUAD2
-    assert(pos+1!=string::npos);
+    assert(pos+1!=std::string::npos);
     QUAD=cellCode.substr(pos+1);
     QUAD2=QUAD.substr(1,1).c_str()[0];
     switch(QUAD2){
@@ -130,7 +130,7 @@ void Egcs::cell2bb(const string& cellCode, int &ulx, int &uly, int &lrx, int &lr
     }
   case(1)://QUAD1: deliberate fall through from case(2)!
     if(!QUAD.size()){
-      assert(pos+1!=string::npos);
+      assert(pos+1!=std::string::npos);
       QUAD=cellCode.substr(pos+1);
     }
     QUAD1=QUAD.substr(0,1).c_str()[0];
@@ -154,27 +154,27 @@ void Egcs::cell2bb(const string& cellCode, int &ulx, int &uly, int &lrx, int &lr
   lry=lly;
 }
 
-void Egcs::cell2mid(const string& cellCode, double& midX, double& midY) const{
+void Egcs::cell2mid(const std::string& cellCode, double& midX, double& midY) const{
   int ulx,uly,lrx,lry;
   cell2bb(cellCode,ulx,uly,lrx,lry);
   midX=(ulx+lrx)/2.0;
   midY=(lry+uly)/2.0;
 }
 
-string Egcs::geo2cell(double geoX, double geoY) const{
+std::string Egcs::geo2cell(double geoX, double geoY) const{
   int ndgts=7-(m_level+1)/3;
   double xcel=static_cast<int>(geoX)/getBaseSize();
   double ycel=static_cast<int>(geoY)/getBaseSize();
-  ostringstream osx;
-  ostringstream osy, osxy;
+  std::ostringstream osx;
+  std::ostringstream osy, osxy;
   // osx << setprecision(ndgts) << xcel;
   // osy << setprecision(ndgts) << ycel;
   // osx << setprecision(0) << fixed << geoX;
   // osy << setprecision(0) << fixed << geoY;
-  osx << fixed << geoX;
-  osy << fixed << geoY;
-  string quad1="";
-  string quad2="";
+  osx << std::fixed << geoX;
+  osy << std::fixed << geoY;
+  std::string quad1="";
+  std::string quad2="";
   switch((19-m_level)%3){
   case(2):
     if(static_cast<int>(geoX)%(getBaseSize()/2)>=getBaseSize()/2.0){
diff --git a/src/algorithms/Egcs.h b/src/algorithms/Egcs.h
index d97c63b..d1fdafd 100644
--- a/src/algorithms/Egcs.h
+++ b/src/algorithms/Egcs.h
@@ -23,8 +23,6 @@ along with pktools.  If not, see <http://www.gnu.org/licenses/>.
 #ifndef _EGCS_H_
 #define _EGCS_H_
 
-using namespace std;
-
 class Egcs
 {
 public:
@@ -32,16 +30,16 @@ public:
   Egcs(unsigned short level);
   /* Egcs(unsigned short level); */
   ~Egcs();
-  unsigned short cell2level(const string& cellCode) const;
-  string geo2cell(double x, double y) const;
+  unsigned short cell2level(const std::string& cellCode) const;
+  std::string geo2cell(double x, double y) const;
   double getSize() const {return getBaseSize()*pow(2,(m_level-19)%3);};
   void setLevel(unsigned short level){m_level=level;};
   unsigned short getLevel() const{return m_level;};
   unsigned short res2level(double resolution) const;
   double getResolution() const;
   void force2grid(double& ulx, double& uly, double& lrx, double &lry) const;
-  void cell2bb(const string& cellCode, int &ulx, int &uly, int &lrx, int &lry) const;
-  void cell2mid(const string& cellCode, double& midX, double& midY) const;
+  void cell2bb(const std::string& cellCode, int &ulx, int &uly, int &lrx, int &lry) const;
+  void cell2mid(const std::string& cellCode, double& midX, double& midY) const;
 private:
   int getBaseSize() const {return pow(10,(m_level+1)/3);};
   unsigned short m_level;
diff --git a/src/algorithms/FeatureSelector.h b/src/algorithms/FeatureSelector.h
index 51f5f6e..e40cdb2 100644
--- a/src/algorithms/FeatureSelector.h
+++ b/src/algorithms/FeatureSelector.h
@@ -23,7 +23,6 @@ along with pktools.  If not, see <http://www.gnu.org/licenses/>.
 #include <math.h>
 #include <vector>
 #include <list>
-#include <map>
 #include <algorithm>
 #include <iostream>
 #include <iomanip>
@@ -31,35 +30,33 @@ along with pktools.  If not, see <http://www.gnu.org/licenses/>.
 #include "Vector2d.h"
 #include "gsl/gsl_combination.h"
 
-using namespace std;
-
 class FeatureSelector
 {
  public:
   FeatureSelector(){};
   ~FeatureSelector(){};
-  template<class T> double forwardUnivariate(vector< Vector2d<T> >& v, double (*getCost)(const vector< Vector2d<T> >&), list<int>& subset, int maxFeatures, short verbose=0);
-  template<class T> double forward(vector< Vector2d<T> >& v, double (*getCost)(const vector< Vector2d<T> >&), list<int>& subset, int maxFeatures, short verbose=0);
-  template<class T> double backward(vector< Vector2d<T> >& v, double (*getCost)(const vector< Vector2d<T> >&), list<int>& subset, int minFeatures, short verbose=0);
-  template<class T> double floating(vector< Vector2d<T> >& v, double (*getCost)(const vector< Vector2d<T> >&), list<int>& subset, int maxFeatures=0, short verbose=0);
-  template<class T> double bruteForce(vector< Vector2d<T> >& v, double (*getCost)(const vector< Vector2d<T> >&), list<int>& subset, int maxFeatures=0, short verbose=0);
+  template<class T> double forwardUnivariate(std::vector< Vector2d<T> >& v, double (*getCost)(const std::vector< Vector2d<T> >&), std::list<int>& subset, int maxFeatures, short verbose=0);
+  template<class T> double forward(std::vector< Vector2d<T> >& v, double (*getCost)(const std::vector< Vector2d<T> >&), std::list<int>& subset, int maxFeatures, short verbose=0);
+  template<class T> double backward(std::vector< Vector2d<T> >& v, double (*getCost)(const std::vector< Vector2d<T> >&), std::list<int>& subset, int minFeatures, short verbose=0);
+  template<class T> double floating(std::vector< Vector2d<T> >& v, double (*getCost)(const std::vector< Vector2d<T> >&), std::list<int>& subset, int maxFeatures=0, short verbose=0);
+  template<class T> double bruteForce(std::vector< Vector2d<T> >& v, double (*getCost)(const std::vector< Vector2d<T> >&), std::list<int>& subset, int maxFeatures=0, short verbose=0);
   
   private:
-    template<class T> double addFeature(vector< Vector2d<T> >& v, double (*getCost)(const vector< Vector2d<T> >&), list<int>& subset, short verbose=0);
-  template<class T> double removeFeature(vector< Vector2d<T> >& v, double (*getCost)(const vector< Vector2d<T> >&), list<int>& subset, int& r, short verbose=0);  
+    template<class T> double addFeature(std::vector< Vector2d<T> >& v, double (*getCost)(const std::vector< Vector2d<T> >&), std::list<int>& subset, short verbose=0);
+  template<class T> double removeFeature(std::vector< Vector2d<T> >& v, double (*getCost)(const std::vector< Vector2d<T> >&), std::list<int>& subset, int& r, short verbose=0);  
 };
 
 //sequential forward selection Univariate (N single best features)
-template<class T> double FeatureSelector::forwardUnivariate(vector< Vector2d<T> >& v, double (*getCost)(const vector< Vector2d<T> >&), list<int>& subset, int maxFeatures=0, short verbose){
+template<class T> double FeatureSelector::forwardUnivariate(std::vector< Vector2d<T> >& v, double (*getCost)(const std::vector< Vector2d<T> >&), std::list<int>& subset, int maxFeatures=0, short verbose){
   int maxLevels=v[0][0].size();
   if(!maxFeatures)
     maxFeatures=maxLevels;
   int k=subset.size();
   if(k>=maxFeatures)
     return -1;
-  vector<IndexValue> cost(maxLevels);
-  list<int> tmpset=subset;//temporary set of selected features (levels)
-  vector< Vector2d<T> > tmp(v.size());
+  std::vector<IndexValue> cost(maxLevels);
+  std::list<int> tmpset=subset;//temporary set of selected features (levels)
+  std::vector< Vector2d<T> > tmp(v.size());
   for(int ilevel=0;ilevel<maxLevels;++ilevel){
     if(find(tmpset.begin(),tmpset.end(),ilevel)==tmpset.end()){
       tmpset.push_back(ilevel);
@@ -109,7 +106,7 @@ template<class T> double FeatureSelector::forwardUnivariate(vector< Vector2d<T>
 }
 
 //sequential forward selection Multivariate (Combination of N best features)
-template<class T> double FeatureSelector::forward(vector< Vector2d<T> >& v, double (*getCost)(const vector< Vector2d<T> >&), list<int>& subset, int maxFeatures=0, short verbose){
+template<class T> double FeatureSelector::forward(std::vector< Vector2d<T> >& v, double (*getCost)(const std::vector< Vector2d<T> >&), std::list<int>& subset, int maxFeatures=0, short verbose){
   //Select feature with the best value (get maximal cost for 1 feature)
   double maxCost=0;
   int maxLevels=v[0][0].size();
@@ -118,7 +115,7 @@ template<class T> double FeatureSelector::forward(vector< Vector2d<T> >& v, doub
   while(subset.size()<maxFeatures){
     maxCost=addFeature(v,*getCost,subset,verbose);
     if(verbose){
-      for(list<int>::const_iterator lit=subset.begin();lit!=subset.end();++lit)
+      for(std::list<int>::const_iterator lit=subset.begin();lit!=subset.end();++lit)
         cout << *lit << " ";
       cout << endl;
       // cout << "added " << subset.back() << ", " << subset.size() << "/" << maxFeatures << " features selected with cost: " << maxCost << endl;
@@ -128,7 +125,7 @@ template<class T> double FeatureSelector::forward(vector< Vector2d<T> >& v, doub
 }
 
 //sequential backward selection
-template<class T> double FeatureSelector::backward(vector< Vector2d<T> >& v, double (*getCost)(const vector< Vector2d<T> >&), list<int>& subset, int minFeatures, short verbose){
+template<class T> double FeatureSelector::backward(std::vector< Vector2d<T> >& v, double (*getCost)(const std::vector< Vector2d<T> >&), std::list<int>& subset, int minFeatures, short verbose){
   //Select features with least effect on cost when removed (obtain minFeatures eventually)
   double maxCost=0;
   int removedFeature;
@@ -141,7 +138,7 @@ template<class T> double FeatureSelector::backward(vector< Vector2d<T> >& v, dou
   while(subset.size()>minFeatures){
     maxCost=removeFeature(v,*getCost,subset,removedFeature,verbose);
     if(verbose){
-      for(list<int>::const_iterator lit=subset.begin();lit!=subset.end();++lit)
+      for(std::list<int>::const_iterator lit=subset.begin();lit!=subset.end();++lit)
         cout << *lit << " ";
       cout << endl;
       // cout << "removed " << removedFeature << ", " << subset.size() << "/" << minFeatures << " features remain with cost: " << maxCost << endl;
@@ -151,9 +148,9 @@ template<class T> double FeatureSelector::backward(vector< Vector2d<T> >& v, dou
 }
 
 //floating search
-template<class T> double FeatureSelector::floating(vector< Vector2d<T> >& v, double (*getCost)(const vector< Vector2d<T> >&), list<int>& subset, int maxFeatures, short verbose){
+template<class T> double FeatureSelector::floating(std::vector< Vector2d<T> >& v, double (*getCost)(const std::vector< Vector2d<T> >&), std::list<int>& subset, int maxFeatures, short verbose){
   double epsilon=0.001;
-  vector<T> cost;
+  std::vector<T> cost;
   int maxLevels=v[0][0].size();
   if(maxFeatures<1)
     maxFeatures=maxLevels;
@@ -166,7 +163,7 @@ template<class T> double FeatureSelector::floating(vector< Vector2d<T> >& v, dou
   if(verbose>1)
     cout << "added " << subset.back() << ", " << cost.size()-1 << "/" << maxFeatures << " features selected with cost: " << cost.back() << endl;
   else if(verbose){
-    for(list<int>::const_iterator lit=subset.begin();lit!=subset.end();++lit)
+    for(std::list<int>::const_iterator lit=subset.begin();lit!=subset.end();++lit)
       cout << *lit << " ";
     cout << endl;
   }
@@ -176,7 +173,7 @@ template<class T> double FeatureSelector::floating(vector< Vector2d<T> >& v, dou
     if(verbose>1)
     cout << "added " << subset.back() << ", " << cost.size()-1 << "/" << maxFeatures << " features selected with cost: " << cost.back() << endl;
     else if(verbose){
-      for(list<int>::const_iterator lit=subset.begin();lit!=subset.end();++lit)
+      for(std::list<int>::const_iterator lit=subset.begin();lit!=subset.end();++lit)
         cout << *lit << " ";
       cout << " (cost: " << cost.back() << ")" << endl;
     }
@@ -191,7 +188,7 @@ template<class T> double FeatureSelector::floating(vector< Vector2d<T> >& v, dou
 	if(verbose>1)
 	  cout << "removed " << x_r << ", " << cost.size()-1 << "/" << maxFeatures << " features remain with cost: " << cost_r << endl;
         else if(verbose){
-          for(list<int>::const_iterator lit=subset.begin();lit!=subset.end();++lit)
+          for(std::list<int>::const_iterator lit=subset.begin();lit!=subset.end();++lit)
             cout << *lit << " ";
           cout << " (cost: " << cost.back() << ")" << endl;
         }
@@ -210,7 +207,7 @@ template<class T> double FeatureSelector::floating(vector< Vector2d<T> >& v, dou
 }
 
 //brute force search (search for all possible combinations and select best)
-template<class T> double FeatureSelector::bruteForce(vector< Vector2d<T> >& v, double (*getCost)(const vector< Vector2d<T> >&), list<int>& subset, int maxFeatures, short verbose){
+template<class T> double FeatureSelector::bruteForce(std::vector< Vector2d<T> >& v, double (*getCost)(const std::vector< Vector2d<T> >&), std::list<int>& subset, int maxFeatures, short verbose){
   int maxLevels=v[0][0].size();
   if(maxFeatures<1)
     maxFeatures=maxLevels;
@@ -221,9 +218,9 @@ template<class T> double FeatureSelector::bruteForce(vector< Vector2d<T> >& v, d
   gsl_combination *c;
   c=gsl_combination_calloc(v[0][0].size(),maxFeatures);
   
-  list<int> tmpset;//temporary set of selected features (levels)
-  vector< Vector2d<T> > tmpv(v.size());
-  list<int> catchset;//restore set in case of catch all the way to last level (no better cost)
+  std::list<int> tmpset;//temporary set of selected features (levels)
+  std::vector< Vector2d<T> > tmpv(v.size());
+  std::list<int> catchset;//restore set in case of catch all the way to last level (no better cost)
   //initialize maxCost with actual cost for current subset (-1 if empty subset) 
   double maxCost=-1;
   double cost;
@@ -259,18 +256,18 @@ template<class T> double FeatureSelector::bruteForce(vector< Vector2d<T> >& v, d
   if(maxCost<0) //no level added to better maxCost than current subset (catchset)
     subset=catchset;
   //test: assert list contains no duplicate elements
-  for(list<int>::iterator lit=subset.begin();lit!=subset.end();++lit){
-    list<int>::iterator lit2=lit;//start searching from next element
+  for(std::list<int>::iterator lit=subset.begin();lit!=subset.end();++lit){
+    std::list<int>::iterator lit2=lit;//start searching from next element
     assert(find(++lit2,subset.end(),*lit)==subset.end());
   }
   return maxCost;
 }
 
-template<class T> double FeatureSelector::addFeature(vector< Vector2d<T> >& v, double (*getCost)(const vector< Vector2d<T> >&), list<int>& subset, short verbose){
+template<class T> double FeatureSelector::addFeature(std::vector< Vector2d<T> >& v, double (*getCost)(const std::vector< Vector2d<T> >&), std::list<int>& subset, short verbose){
   //select feature with the best value (get maximal cost for 1 feature)
-  list<int> tmpset=subset;//temporary set of selected features (levels)
-  vector< Vector2d<T> > tmp(v.size());
-  list<int> catchset;//restore set in case of catch all the way to last level (no better cost)
+  std::list<int> tmpset=subset;//temporary set of selected features (levels)
+  std::vector< Vector2d<T> > tmp(v.size());
+  std::list<int> catchset;//restore set in case of catch all the way to last level (no better cost)
   //initialize maxCost with actual cost for current subset (-1 if empty subset) 
   double maxCost=-1;
   double cost;
@@ -304,19 +301,19 @@ template<class T> double FeatureSelector::addFeature(vector< Vector2d<T> >& v, d
   if(maxCost<0) //no level added to better maxCost than current subset (catchset)
     subset=catchset;
   //test: assert list contains no duplicate elements
-  for(list<int>::iterator lit=subset.begin();lit!=subset.end();++lit){
-    list<int>::iterator lit2=lit;//start searching from next element
+  for(std::list<int>::iterator lit=subset.begin();lit!=subset.end();++lit){
+    std::list<int>::iterator lit2=lit;//start searching from next element
     assert(find(++lit2,subset.end(),*lit)==subset.end());
   }
   return maxCost;
 }
 
-template<class T> double FeatureSelector::removeFeature(vector< Vector2d<T> >& v, double (*getCost)(const vector< Vector2d<T> >&), list<int>& subset, int& r, short verbose){
+template<class T> double FeatureSelector::removeFeature(std::vector< Vector2d<T> >& v, double (*getCost)(const std::vector< Vector2d<T> >&), std::list<int>& subset, int& r, short verbose){
   //find the feature that has the least effect on the cost when it is removed from subset
-  list<int> tmpset=subset;//temporary set of selected features (levels)
-  vector< Vector2d<T> > tmp(v.size());
+  std::list<int> tmpset=subset;//temporary set of selected features (levels)
+  std::vector< Vector2d<T> > tmp(v.size());
   int nFeatures=subset.size();
-  list<int> catchset;//restore set in case of catch all the way to last level (no better cost)
+  std::list<int> catchset;//restore set in case of catch all the way to last level (no better cost)
   //initialize maxCost with actual cost for current subset (-1 if empty subset) 
   double maxCost=-1;
   int last;
@@ -325,7 +322,7 @@ template<class T> double FeatureSelector::removeFeature(vector< Vector2d<T> >& v
   if(subset.size()>maxLevels||subset.empty()){
     return maxCost;
   }
-  list<int>::const_iterator it;
+  std::list<int>::const_iterator it;
   for(int i=0;i<nFeatures;++i){
     last=tmpset.back();
     tmpset.pop_back();
@@ -354,8 +351,8 @@ template<class T> double FeatureSelector::removeFeature(vector< Vector2d<T> >& v
     subset=catchset;
   }
   //test: assert list contains no duplicate elements
-  for(list<int>::iterator lit=subset.begin();lit!=subset.end();++lit){
-    list<int>::iterator lit2=lit;//start searching from next element
+  for(std::list<int>::iterator lit=subset.begin();lit!=subset.end();++lit){
+    std::list<int>::iterator lit2=lit;//start searching from next element
     assert(find(++lit2,subset.end(),*lit)==subset.end());
   }
   return maxCost;
diff --git a/src/algorithms/Filter.h b/src/algorithms/Filter.h
index 1b6d30e..65d0028 100644
--- a/src/algorithms/Filter.h
+++ b/src/algorithms/Filter.h
@@ -22,12 +22,13 @@ along with pktools.  If not, see <http://www.gnu.org/licenses/>.
 
 #include <vector>
 #include <iostream>
+extern "C" {
 #include <gsl/gsl_wavelet.h>
+}
 #include "StatFactory.h"
 #include "imageclasses/ImgReaderGdal.h"
 #include "imageclasses/ImgWriterGdal.h"
 
-using namespace std;
 namespace filter
 {
   
@@ -37,7 +38,7 @@ class Filter
 {
 public:
   Filter(void);
-  Filter(const vector<double> &taps);
+  Filter(const std::vector<double> &taps);
   virtual ~Filter(){};
   static const gsl_wavelet_type* getWaveletType(const std::string waveletType){
     if(waveletType=="daubechies") return(gsl_wavelet_daubechies);
@@ -52,20 +53,20 @@ public:
     initFilterMap(m_filterMap);
     return m_filterMap[filterType];
   };
-  void setTaps(const vector<double> &taps);
+  void setTaps(const std::vector<double> &taps);
   void pushClass(short theClass=1){m_class.push_back(theClass);};
   void pushMask(short theMask=0){m_mask.push_back(theMask);};
-  template<class T> void doit(const vector<T>& input, vector<T>& output, int down=1, int offset=0);
-  template<class T> void doit(T* input, int inputSize, vector<T>& output, int down=1, int offset=0);
-  template<class T> void morphology(const vector<T>& input, vector<T>& output, const std::string& method, int dim, short down=1, int offset=0, bool verbose=0);
+  template<class T> void doit(const std::vector<T>& input, std::vector<T>& output, int down=1, int offset=0);
+  template<class T> void doit(T* input, int inputSize, std::vector<T>& output, int down=1, int offset=0);
+  template<class T> void morphology(const std::vector<T>& input, std::vector<T>& output, const std::string& method, int dim, short down=1, int offset=0, bool verbose=0);
   void morphology(const ImgReaderGdal& input, ImgWriterGdal& output, const std::string& method, int dim, short down=1, int offset=0);
   void doit(const ImgReaderGdal& input, ImgWriterGdal& output, short down=1, int offset=0);
 
-  template<class T> double applySrf(const vector<double> &wavelengthIn, const vector<T>& input, const Vector2d<double>& srf, const std::string& interpolationType, T& output, double delta=1.0, bool normalize=false, bool verbose=false);
-  template<class T> double applySrf(const vector<double> &wavelengthIn, const Vector2d<T>& input, const Vector2d<double>& srf, const std::string& interpolationType, vector<T>& output, double delta=1.0, bool normalize=false, int down=1, bool transposeInput=false, bool verbose=false);
+  template<class T> double applySrf(const std::vector<double> &wavelengthIn, const std::vector<T>& input, const Vector2d<double>& srf, const std::string& interpolationType, T& output, double delta=1.0, bool normalize=false, bool verbose=false);
+  template<class T> double applySrf(const std::vector<double> &wavelengthIn, const Vector2d<T>& input, const Vector2d<double>& srf, const std::string& interpolationType, std::vector<T>& output, double delta=1.0, bool normalize=false, int down=1, bool transposeInput=false, bool verbose=false);
 
-  template<class T> void applyFwhm(const vector<double> &wavelengthIn, const vector<T>& input, const vector<double> &wavelengthOut, const vector<double> &fwhm, const std::string& interpolationType, vector<T>& output, bool verbose=false);
-  template<class T> void applyFwhm(const vector<double> &wavelengthIn, const Vector2d<T>& input, const vector<double> &wavelengthOut, const vector<double> &fwhm, const std::string& interpolationType, Vector2d<T>& output, int down=1, bool verbose=false);
+  template<class T> void applyFwhm(const std::vector<double> &wavelengthIn, const std::vector<T>& input, const std::vector<double> &wavelengthOut, const std::vector<double> &fwhm, const std::string& interpolationType, std::vector<T>& output, bool verbose=false);
+  template<class T> void applyFwhm(const std::vector<double> &wavelengthIn, const Vector2d<T>& input, const std::vector<double> &wavelengthOut, const std::vector<double> &fwhm, const std::string& interpolationType, Vector2d<T>& output, int down=1, bool verbose=false);
   void dwtForward(std::vector<double>& data, const std::string& wavelet_type, int family);
   void dwtInverse(std::vector<double>& data, const std::string& wavelet_type, int family);
 
@@ -104,14 +105,14 @@ private:
     m_filterMap["order"]=filter::order;
     m_filterMap["median"]=filter::median;
   }
-  vector<double> m_taps;
-  vector<short> m_class;
-  vector<short> m_mask;
+  std::vector<double> m_taps;
+  std::vector<short> m_class;
+  std::vector<short> m_mask;
 };
 
 //input[band], output
 //returns wavelength for which srf is maximum
-  template<class T> double Filter::applySrf(const vector<double> &wavelengthIn, const vector<T>& input, const Vector2d<double>& srf, const std::string& interpolationType, T& output, double delta, bool normalize, bool verbose)
+  template<class T> double Filter::applySrf(const std::vector<double> &wavelengthIn, const std::vector<T>& input, const Vector2d<double>& srf, const std::string& interpolationType, T& output, double delta, bool normalize, bool verbose)
 {  
   assert(srf.size()==2);//[0]: wavelength, [1]: response function
   int nband=srf[0].size(); 
@@ -137,13 +138,13 @@ private:
   gsl_interp_accel_free(acc);  
   //interpolate input and srf to delta
   
-  vector<double> wavelength_fine;
+  std::vector<double> wavelength_fine;
   for(double win=floor(wavelengthIn[0]);win<=ceil(wavelengthIn.back());win+=delta)
     wavelength_fine.push_back(win);
 
   if(verbose)
     std::cout << "interpolate wavelengths to " << wavelength_fine.size() << " entries " << std::endl;
-  vector<double> srf_fine;//spectral response function, interpolated for wavelength_fine
+  std::vector<double> srf_fine;//spectral response function, interpolated for wavelength_fine
 
   stat.interpolateUp(srf[0],srf[1],wavelength_fine,interpolationType,srf_fine,verbose);
   assert(srf_fine.size()==wavelength_fine.size());
@@ -155,8 +156,8 @@ private:
   assert(splineOut);
 
   assert(wavelengthIn.size()==input.size());
-  vector<double> input_fine;
-  vector<double> product(wavelength_fine.size());
+  std::vector<double> input_fine;
+  std::vector<double> product(wavelength_fine.size());
   stat.interpolateUp(wavelengthIn,input,wavelength_fine,interpolationType,input_fine,verbose);
 
   if(verbose)
@@ -187,7 +188,7 @@ private:
 
 //input[band][sample], output[sample] (if !transposeInput)
 //returns wavelength for which srf is maximum
-  template<class T> double Filter::applySrf(const vector<double> &wavelengthIn, const Vector2d<T>& input, const Vector2d<double>& srf, const std::string& interpolationType, vector<T>& output, double delta, bool normalize, int down, bool transposeInput, bool verbose)
+  template<class T> double Filter::applySrf(const std::vector<double> &wavelengthIn, const Vector2d<T>& input, const Vector2d<double>& srf, const std::string& interpolationType, std::vector<T>& output, double delta, bool normalize, int down, bool transposeInput, bool verbose)
 {  
   assert(srf.size()==2);//[0]: wavelength, [1]: response function
   int nband=srf[0].size(); 
@@ -215,13 +216,13 @@ private:
   gsl_interp_accel_free(acc);  
   //interpolate input and srf to delta
   
-  vector<double> wavelength_fine;
+  std::vector<double> wavelength_fine;
   for(double win=floor(wavelengthIn[0]);win<=ceil(wavelengthIn.back());win+=delta)
     wavelength_fine.push_back(win);
 
   if(verbose)
     std::cout << "interpolate wavelengths to " << wavelength_fine.size() << " entries " << std::endl;
-  vector<double> srf_fine;//spectral response function, interpolated for wavelength_fine
+  std::vector<double> srf_fine;//spectral response function, interpolated for wavelength_fine
 
   stat.interpolateUp(srf[0],srf[1],wavelength_fine,interpolationType,srf_fine,verbose);
   assert(srf_fine.size()==wavelength_fine.size());
@@ -235,14 +236,14 @@ private:
   for(int isample=0;isample<nsample;++isample){
     if((isample+1+down/2)%down)
       continue;
-    vector<T> inputValues;
+    std::vector<T> inputValues;
     if(transposeInput)
       inputValues=input[isample];
     else
       input.selectCol(isample,inputValues);
     assert(wavelengthIn.size()==inputValues.size());
-    vector<double> input_fine;
-    vector<double> product(wavelength_fine.size());
+    std::vector<double> input_fine;
+    std::vector<double> product(wavelength_fine.size());
     stat.interpolateUp(wavelengthIn,inputValues,wavelength_fine,interpolationType,input_fine,verbose);
 
     for(int iband=0;iband<input_fine.size();++iband)
@@ -270,9 +271,9 @@ private:
   return(srf[0][maxIndex]);
 }
 
-template<class T> void Filter::applyFwhm(const vector<double> &wavelengthIn, const vector<T>& input, const vector<double> &wavelengthOut, const vector<double> &fwhm, const std::string& interpolationType, vector<T>& output, bool verbose){
+template<class T> void Filter::applyFwhm(const std::vector<double> &wavelengthIn, const std::vector<T>& input, const std::vector<double> &wavelengthOut, const std::vector<double> &fwhm, const std::string& interpolationType, std::vector<T>& output, bool verbose){
   double delta=1;//1 nm resolution
-  vector<double> stddev(fwhm.size());
+  std::vector<double> stddev(fwhm.size());
   for(int index=0;index<fwhm.size();++index)
     stddev[index]=fwhm[index]/2.0/sqrt(2*log(2.0));//http://mathworld.wolfram.com/FullWidthatHalfMaximum.html
   assert(wavelengthOut.size()==fwhm.size());
@@ -280,8 +281,8 @@ template<class T> void Filter::applyFwhm(const vector<double> &wavelengthIn, con
   assert(wavelengthIn[0]<=wavelengthOut[0]);
   assert(wavelengthIn.back()>=wavelengthOut.back());
   statfactory::StatFactory stat;
-  vector<double> input_fine;
-  vector<double> wavelength_fine;
+  std::vector<double> input_fine;
+  std::vector<double> wavelength_fine;
   for(double win=floor(wavelengthIn[0]);win<=ceil(wavelengthIn.back());win+=delta)
     wavelength_fine.push_back(win);
   if(verbose){
@@ -317,13 +318,13 @@ template<class T> void Filter::applyFwhm(const vector<double> &wavelengthIn, con
 
 
   //input[inBand][sample], output[outBand][sample]
-  template<class T> void Filter::applyFwhm(const vector<double> &wavelengthIn, const Vector2d<T>& input, const vector<double> &wavelengthOut, const vector<double> &fwhm, const std::string& interpolationType, Vector2d<T>& output, int down, bool verbose){
+  template<class T> void Filter::applyFwhm(const std::vector<double> &wavelengthIn, const Vector2d<T>& input, const std::vector<double> &wavelengthOut, const std::vector<double> &fwhm, const std::string& interpolationType, Vector2d<T>& output, int down, bool verbose){
   double delta=1;//1 nm resolution
-  vector<double> stddev(fwhm.size());
+  std::vector<double> stddev(fwhm.size());
   for(int index=0;index<fwhm.size();++index)
     stddev[index]=fwhm[index]/2.0/sqrt(2*log(2.0));//http://mathworld.wolfram.com/FullWidthatHalfMaximum.html
   statfactory::StatFactory stat;
-  vector<double> wavelength_fine;
+  std::vector<double> wavelength_fine;
   for(double win=floor(wavelengthIn[0]);win<=ceil(wavelengthIn.back());win+=delta)
     wavelength_fine.push_back(win);
   assert(wavelengthOut.size()==fwhm.size());
@@ -340,7 +341,7 @@ template<class T> void Filter::applyFwhm(const vector<double> &wavelengthIn, con
   output.resize(nbandOut,(input[0].size()+down-1)/down);
 
   Vector2d<double> tf(nbandIn,nbandOut);
-  vector<double> norm(nbandOut);
+  std::vector<double> norm(nbandOut);
   for(int indexOut=0;indexOut<nbandOut;++indexOut){
     norm[indexOut]=0;
     for(int indexIn=0;indexIn<nbandIn;++indexIn){
@@ -358,11 +359,11 @@ template<class T> void Filter::applyFwhm(const vector<double> &wavelengthIn, con
   for(int isample=0;isample<input[0].size();++isample){
     if((isample+1+down/2)%down)
       continue;
-    vector<T> inputValues;
+    std::vector<T> inputValues;
     input.selectCol(isample,inputValues);
     assert(wavelengthIn.size()==inputValues.size());
     for(int indexOut=0;indexOut<nbandOut;++indexOut){
-      vector<double> input_fine;
+      std::vector<double> input_fine;
       stat.interpolateUp(wavelengthIn,inputValues,wavelength_fine,interpolationType,input_fine,verbose);
       output[indexOut][(isample+down-1)/down]=0;
       for(int indexIn=0;indexIn<nbandIn;++indexIn){
@@ -372,7 +373,7 @@ template<class T> void Filter::applyFwhm(const vector<double> &wavelengthIn, con
   }
 }
 
-template<class T> void Filter::doit(const vector<T>& input, vector<T>& output, int down, int offset)
+template<class T> void Filter::doit(const std::vector<T>& input, std::vector<T>& output, int down, int offset)
 {
   output.resize((input.size()-offset+down-1)/down);
   int i=0;
@@ -404,13 +405,13 @@ template<class T> void Filter::doit(const vector<T>& input, vector<T>& output, i
   }
 }
 
-template<class T> void Filter::morphology(const vector<T>& input, vector<T>& output, const std::string& method, int dim, short down, int offset, bool verbose)
+template<class T> void Filter::morphology(const std::vector<T>& input, std::vector<T>& output, const std::string& method, int dim, short down, int offset, bool verbose)
 {
   assert(dim);
   output.resize((input.size()-offset+down-1)/down);
   int i=0;
   statfactory::StatFactory stat;
-  vector<T> statBuffer;
+  std::vector<T> statBuffer;
   short binValue=0;
   //start: extend input with mirrored version of itself
   for(i=offset;i<dim/2;++i){
@@ -549,7 +550,7 @@ template<class T> void Filter::morphology(const vector<T>& input, vector<T>& out
       output[(i-offset+down-1)/down]=stat.min(statBuffer);
       break;
     default:
-      string errorString="method not supported";
+      std::string errorString="method not supported";
       throw(errorString);
       break;
     }
@@ -562,7 +563,7 @@ template<class T> void Filter::morphology(const vector<T>& input, vector<T>& out
   }
 }
 
-template<class T> void Filter::doit(T* input, int inputSize, vector<T>& output, int down, int offset)
+template<class T> void Filter::doit(T* input, int inputSize, std::vector<T>& output, int down, int offset)
 {
   output.resize((inputSize-offset+down-1)/down);
   int i=0;
diff --git a/src/algorithms/Filter2d.cc b/src/algorithms/Filter2d.cc
index 3cb5e73..8c6e9ef 100644
--- a/src/algorithms/Filter2d.cc
+++ b/src/algorithms/Filter2d.cc
@@ -645,6 +645,15 @@ void filter2d::Filter2d::doit(const ImgReaderGdal& input, ImgWriterGdal& output,
 	    outBuffer[x/down]=m_noValue;
           break;
         }
+        case(filter2d::scramble):{//could be done more efficiently window by window with random shuffling entire buffer and assigning entire buffer at once to output image...
+	  if(windowBuffer.size()){
+            int randomIndex=std::rand()%windowBuffer.size();
+            outBuffer[x/down]=windowBuffer[randomIndex];
+          }
+          else
+	    outBuffer[x/down]=m_noValue;
+          break;
+        }
         case(filter2d::mixed):{
           enum Type { BF=11, CF=12, MF=13, NF=20, W=30 };
           double nBF=occurrence[BF];
@@ -829,6 +838,26 @@ void filter2d::Filter2d::mrf(const ImgReaderGdal& input, ImgWriterGdal& output,
   }
 }
 
+void filter2d::Filter2d::shift(const ImgReaderGdal& input, ImgWriterGdal& output, int offsetX, int offsetY, double randomSigma, RESAMPLE resample, bool verbose)
+{
+  assert(input.nrOfCol()==output.nrOfCol());
+  assert(input.nrOfRow()==output.nrOfRow());
+  assert(input.nrOfBand()==output.nrOfBand());
+  const char* pszMessage;
+  void* pProgressArg=NULL;
+  GDALProgressFunc pfnProgress=GDALTermProgress;
+  double progress=0;
+  pfnProgress(progress,pszMessage,pProgressArg);
+  //process band per band in memory
+  Vector2d<double> inBuffer(input.nrOfRow(),output.nrOfCol());
+  Vector2d<double> outBuffer(input.nrOfRow(),output.nrOfCol());
+  for(int iband=0;iband<input.nrOfBand();++iband){
+    input.readDataBlock(inBuffer,GDT_Float64,0,inBuffer.nCols()-1,0,inBuffer.nRows()-1,iband);
+    shift(inBuffer,outBuffer,offsetX,offsetY,randomSigma,resample,verbose);
+    output.writeDataBlock(outBuffer,GDT_Float64,0,outBuffer.nCols()-1,0,outBuffer.nRows()-1,iband);
+  }
+}
+
 //todo: re-implement without dependency of CImg and reg libraries
 // void filter2d::Filter2d::dwt_texture(const string& inputFilename, const string& outputFilename,int dim, int scale, int down, int iband, bool verbose)
 // {
diff --git a/src/algorithms/Filter2d.h b/src/algorithms/Filter2d.h
index b136eac..4b7a8a0 100644
--- a/src/algorithms/Filter2d.h
+++ b/src/algorithms/Filter2d.h
@@ -34,20 +34,24 @@ along with pktools.  If not, see <http://www.gnu.org/licenses/>.
 #include <vector>
 #include <string>
 #include <map>
+extern "C" {
 #include <gsl/gsl_sort.h>
 #include <gsl/gsl_wavelet.h>
 #include <gsl/gsl_wavelet2d.h>
+#include <gsl/gsl_rng.h>
+#include <gsl/gsl_randist.h>
+}
 #include "base/Vector2d.h"
 #include "Filter.h"
 #include "imageclasses/ImgReaderGdal.h"
 #include "imageclasses/ImgWriterGdal.h"
 #include "algorithms/StatFactory.h"
 
-using namespace std;
-// using namespace cimg_library;
 namespace filter2d
 {
-  enum FILTER_TYPE { median=0, var=1 , min=2, max=3, sum=4, mean=5, minmax=6, dilate=7, erode=8, close=9, open=10, homog=11, sobelx=12, sobely=13, sobelxy=14, sobelyx=-14, smooth=15, density=16, majority=17, mixed=18, smoothnodata=19, threshold=20, ismin=21, ismax=22, heterog=23, order=24, stdev=25, mrf=26, dwtForward=27, dwtInverse=28, dwtQuantize=29};
+  enum FILTER_TYPE { median=0, var=1 , min=2, max=3, sum=4, mean=5, minmax=6, dilate=7, erode=8, close=9, open=10, homog=11, sobelx=12, sobely=13, sobelxy=14, sobelyx=-14, smooth=15, density=16, majority=17, mixed=18, smoothnodata=19, threshold=20, ismin=21, ismax=22, heterog=23, order=24, stdev=25, mrf=26, dwtForward=27, dwtInverse=28, dwtQuantize=29, scramble=30, shift=31};
+
+  enum RESAMPLE { NEAR = 0, BILINEAR = 1, BICUBIC = 2 };//bicubic not supported yet...
   
 class Filter2d
 {
@@ -60,14 +64,24 @@ public:
     initMap(m_filterMap);
     return m_filterMap[filterType];
   };
+  static const RESAMPLE getResampleType(const std::string resampleType){
+    if(resampleType=="near") return(NEAR);
+    else if(resampleType=="bilinear") return(BILINEAR);
+    else{
+      std::string errorString="resampling type not supported: ";
+      errorString+=resampleType;
+      errorString+=" use near or bilinear";
+      throw(errorString);
+    }
+  };
 
   void setTaps(const Vector2d<double> &taps);
   void setNoValue(double noValue=0){m_noValue=noValue;};
   void pushClass(short theClass=1){m_class.push_back(theClass);};
   void pushMask(short theMask=0){m_mask.push_back(theMask);};
   void pushThreshold(double theThreshold){m_threshold.push_back(theThreshold);};
-  void setThresholds(const vector<double>& theThresholds){m_threshold=theThresholds;};
-  void setClasses(const vector<short>& theClasses){m_class=theClasses;};
+  void setThresholds(const std::vector<double>& theThresholds){m_threshold=theThresholds;};
+  void setClasses(const std::vector<short>& theClasses){m_class=theClasses;};
   void filter(const ImgReaderGdal& input, ImgWriterGdal& output, bool absolute=false, bool normalize=true, bool noData=false);
   void smooth(const ImgReaderGdal& input, ImgWriterGdal& output,int dim);
   void smooth(const ImgReaderGdal& input, ImgWriterGdal& output,int dimX, int dimY);
@@ -81,20 +95,23 @@ public:
   template<class T> void dwtForward(Vector2d<T>& data, const std::string& wavelet_type, int family);
   template<class T> void dwtQuantize(Vector2d<T>& data, const std::string& wavelet_type, int family, double quantize);
   template<class T> void dwtInverse(Vector2d<T>& data, const std::string& wavelet_type, int family);
-  void majorVoting(const string& inputFilename, const string& outputFilename,int dim=0,const vector<int> &prior=vector<int>());
-  /* void homogeneousSpatial(const string& inputFilename, const string& outputFilename, int dim, bool disc=false, int noValue=0); */
+  void majorVoting(const std::string& inputFilename, const std::string& outputFilename,int dim=0,const std::vector<int> &prior=std::vector<int>());
+  /* void homogeneousSpatial(const std::string& inputFilename, const std::string& outputFilename, int dim, bool disc=false, int noValue=0); */
   void doit(const ImgReaderGdal& input, ImgWriterGdal& output, const std::string& method, int dim, short down=2, bool disc=false);
   void doit(const ImgReaderGdal& input, ImgWriterGdal& output, const std::string& method, int dimX, int dimY, short down=1, bool disc=false);
   void mrf(const ImgReaderGdal& input, ImgWriterGdal& output, int dimX, int dimY, double beta, bool eightConnectivity=true, short down=1, bool verbose=false);
   void mrf(const ImgReaderGdal& input, ImgWriterGdal& output, int dimX, int dimY, Vector2d<double> beta, bool eightConnectivity=true, short down=1, bool verbose=false);
   template<class T1, class T2> void doit(const Vector2d<T1>& inputVector, Vector2d<T2>& outputVector, const std::string& method, int dimX, int dimY, short down=1, bool disc=false);
-  void median(const string& inputFilename, const string& outputFilename, int dim, bool disc=false);
-  void var(const string& inputFilename, const string& outputFilename, int dim, bool disc=false);
-  void morphology(const ImgReaderGdal& input, ImgWriterGdal& output, const std::string& method, int dimX, int dimY, const vector<double> &angle, bool disc=false);
+  void median(const std::string& inputFilename, const std::string& outputFilename, int dim, bool disc=false);
+  void var(const std::string& inputFilename, const std::string& outputFilename, int dim, bool disc=false);
+  void morphology(const ImgReaderGdal& input, ImgWriterGdal& output, const std::string& method, int dimX, int dimY, const std::vector<double> &angle, bool disc=false);
   template<class T> unsigned long int morphology(const Vector2d<T>& input, Vector2d<T>& output, const std::string& method, int dimX, int dimY, bool disc=false, double hThreshold=0);
   template<class T> void shadowDsm(const Vector2d<T>& input, Vector2d<T>& output, double sza, double saa, double pixelSize, short shadowFlag=1);
   void shadowDsm(const ImgReaderGdal& input, ImgWriterGdal& output, double sza, double saa, double pixelSize, short shadowFlag=1);
-  void dwt_texture(const string& inputFilename, const string& outputFilename,int dim, int scale, int down=1, int iband=0, bool verbose=false);
+  void dwt_texture(const std::string& inputFilename, const std::string& outputFilename,int dim, int scale, int down=1, int iband=0, bool verbose=false);
+  void shift(const ImgReaderGdal& input, ImgWriterGdal& output, int offsetX=0, int offsetY=0, double randomSigma=0, RESAMPLE resample=BILINEAR, bool verbose=false);
+  template<class T> void shift(const Vector2d<T>& input, Vector2d<T>& output, int offsetX=0, int offsetY=0, double randomSigma=0, RESAMPLE resample=0, bool verbose=false);
+
   
 private:
   static void initMap(std::map<std::string, FILTER_TYPE>& m_filterMap){
@@ -128,13 +145,15 @@ private:
     m_filterMap["order"]=filter2d::order;
     m_filterMap["median"]=filter2d::median;
     m_filterMap["dwtQuantize"]=filter2d::dwtQuantize;
+    m_filterMap["scramble"]=filter2d::scramble;
+    m_filterMap["shift"]=filter2d::shift;
   }
 
   Vector2d<double> m_taps;
   double m_noValue;
-  vector<short> m_class;
-  vector<short> m_mask;
-  vector<double> m_threshold;
+  std::vector<short> m_class;
+  std::vector<short> m_mask;
+  std::vector<double> m_threshold;
 };
 
  template<class T1, class T2> void Filter2d::smooth(const Vector2d<T1>& inputVector, Vector2d<T2>& outputVector,int dim)
@@ -159,7 +178,7 @@ private:
     int dimX=m_taps[0].size();//horizontal!!!
     int dimY=m_taps.size();//vertical!!!
     Vector2d<T1> inBuffer(dimY);
-    vector<T2> outBuffer(inputVector[0].size());
+    std::vector<T2> outBuffer(inputVector[0].size());
     //initialize last half of inBuffer
     int indexI=0;
     int indexJ=0;
@@ -205,7 +224,7 @@ template<class T1, class T2> void Filter2d::doit(const Vector2d<T1>& inputVector
   statfactory::StatFactory stat;
   outputVector.resize((inputVector.size()+down-1)/down);
   Vector2d<T1> inBuffer(dimY);
-  vector<T2> outBuffer((inputVector[0].size()+down-1)/down);
+  std::vector<T2> outBuffer((inputVector[0].size()+down-1)/down);
   //initialize last half of inBuffer
   int indexI=0;
   int indexJ=0;
@@ -240,8 +259,8 @@ template<class T1, class T2> void Filter2d::doit(const Vector2d<T1>& inputVector
       if((x+1+down/2)%down)
         continue;
       outBuffer[x/down]=0;
-      vector<double> windowBuffer;
-      map<int,int> occurrence;
+      std::vector<double> windowBuffer;
+      std::map<int,int> occurrence;
       for(int j=-dimY/2;j<(dimY+1)/2;++j){
 	for(int i=-dimX/2;i<(dimX+1)/2;++i){
 	  indexI=x+i;
@@ -263,7 +282,7 @@ template<class T1, class T2> void Filter2d::doit(const Vector2d<T1>& inputVector
             }
           }
           if(!masked){
-            vector<short>::const_iterator vit=m_class.begin();
+            std::vector<short>::const_iterator vit=m_class.begin();
             //todo: test if this works (only add occurrence if within defined classes)!
             if(!m_class.size())
               ++occurrence[inBuffer[indexJ][indexI]];
@@ -371,7 +390,7 @@ template<class T1, class T2> void Filter2d::doit(const Vector2d<T1>& inputVector
           outBuffer[x/down]=m_noValue;
         break;
       case(filter2d::heterog):{
-        for(vector<double>::const_iterator wit=windowBuffer.begin();wit!=windowBuffer.end();++wit){
+        for(std::vector<double>::const_iterator wit=windowBuffer.begin();wit!=windowBuffer.end();++wit){
           if(wit==windowBuffer.begin()+windowBuffer.size()/2)
             continue;
           else if(*wit!=inBuffer[dimY/2][x])
@@ -385,7 +404,7 @@ template<class T1, class T2> void Filter2d::doit(const Vector2d<T1>& inputVector
       }
       case(filter2d::density):{
         if(windowBuffer.size()){
-          vector<short>::const_iterator vit=m_class.begin();
+          std::vector<short>::const_iterator vit=m_class.begin();
           while(vit!=m_class.end())
             outBuffer[x/down]+=100.0*occurrence[*(vit++)]/windowBuffer.size();
         }
@@ -395,8 +414,8 @@ template<class T1, class T2> void Filter2d::doit(const Vector2d<T1>& inputVector
       }
       case(filter2d::majority):{
         if(occurrence.size()){
-          map<int,int>::const_iterator maxit=occurrence.begin();
-          for(map<int,int>::const_iterator mit=occurrence.begin();mit!=occurrence.end();++mit){
+          std::map<int,int>::const_iterator maxit=occurrence.begin();
+          for(std::map<int,int>::const_iterator mit=occurrence.begin();mit!=occurrence.end();++mit){
             if(mit->second>maxit->second)
               maxit=mit;
           }
@@ -469,6 +488,89 @@ template<class T1, class T2> void Filter2d::doit(const Vector2d<T1>& inputVector
 //   }
 // };
 
+template<class T> void Filter2d::shift(const Vector2d<T>& input, Vector2d<T>& output, int offsetX, int offsetY, double randomSigma, RESAMPLE resample, bool verbose){
+  output.resize(input.nRows(),input.nCols());
+  const gsl_rng_type *rangenType;
+  gsl_rng *rangen;
+  gsl_rng_env_setup();
+  rangenType=gsl_rng_default;
+  rangen=gsl_rng_alloc(rangenType);
+  long seed=time(NULL)*getpid();
+  gsl_rng_set(rangen,seed);
+  const char* pszMessage;
+  void* pProgressArg=NULL;
+  GDALProgressFunc pfnProgress=GDALTermProgress;
+  double progress=0;
+  pfnProgress(progress,pszMessage,pProgressArg);
+  for(int j=0;j<input.nRows();++j){
+    for(int i=0;i<input.nCols();++i){
+      T theValue=0;
+      double randomX=0;
+      double randomY=0;
+      if(randomSigma>0){
+        randomX=gsl_ran_gaussian(rangen,randomSigma);
+        randomY=gsl_ran_gaussian(rangen,randomSigma);
+      }
+      double readCol=i+offsetX+randomX;
+      double readRow=j+offsetY+randomY;
+      if(readRow<0)
+        readRow=0;
+      if(readRow>input.nRows()-1)
+        readRow=input.nRows()-1;
+      if(readCol<0)
+        readCol=0;
+      if(readCol>input.nCols()-1)
+        readCol=input.nCols()-1;
+      switch(resample){
+      case(BILINEAR):{
+        double lowerRow=readRow-0.5;
+        double upperRow=readRow+0.5;
+        lowerRow=static_cast<int>(lowerRow);
+        upperRow=static_cast<int>(upperRow);
+        double lowerCol=readCol-0.5;
+        double upperCol=readCol+0.5;
+        lowerCol=static_cast<int>(lowerCol);
+        upperCol=static_cast<int>(upperCol);
+        assert(lowerRow>=0);
+        assert(lowerRow<input.nRows());
+        assert(lowerCol>=0);
+        assert(lowerCol<input.nCols());
+        assert(upperRow>=0);
+        assert(upperRow<input.nRows());
+        assert(upperCol>=0);
+        if(upperCol>=input.nCols()){
+          std::cout << "upperCol: " << upperCol << std::endl;
+          std::cout << "readCol: " << readCol << std::endl;
+          std::cout << "readCol+0.5: " << readCol+0.5 << std::endl;
+          std::cout << "static_cast<int>(readCol+0.5): " << static_cast<int>(readCol+0.5) << std::endl;
+        }
+        assert(upperCol<input.nCols());
+        double c00=input[lowerRow][lowerCol];
+        double c11=input[upperRow][upperCol];
+        double c01=input[lowerRow][upperCol];
+        double c10=input[upperRow][lowerCol];
+        double a=(upperCol-readCol)*c00+(readCol-lowerCol)*c01;
+        double b=(upperCol-readCol)*c10+(readCol-lowerCol)*c11;
+        theValue=(upperRow-readRow)*a+(readRow-lowerRow)*b;
+        break;
+      }
+      default:
+        theValue=input[static_cast<int>(readRow)][static_cast<int>(readCol)];
+        break;
+      }
+      assert(j>=0);
+      assert(j<output.nRows());
+      assert(i>=0);
+      assert(i<output.nCols());
+      output[j][i]=theValue;
+    }
+    progress=(1.0+j);
+    progress/=output.nRows();
+    pfnProgress(progress,pszMessage,pProgressArg);
+  }
+  gsl_rng_free(rangen);
+}
+
 template<class T> unsigned long int Filter2d::morphology(const Vector2d<T>& input, Vector2d<T>& output, const std::string& method, int dimX, int dimY, bool disc, double hThreshold)
 {
   unsigned long int nchange=0;
@@ -506,7 +608,7 @@ template<class T> unsigned long int Filter2d::morphology(const Vector2d<T>& inpu
     for(int x=0;x<input.nCols();++x){
       output[y][x]=0;
       double currentValue=inBuffer[dimY/2][x];
-      vector<double> statBuffer;
+      std::vector<double> statBuffer;
       bool currentMasked=false;
       for(int imask=0;imask<m_mask.size();++imask){
         if(currentValue==m_mask[imask]){
@@ -574,7 +676,7 @@ template<class T> unsigned long int Filter2d::morphology(const Vector2d<T>& inpu
             }
             break;
           default:
-            ostringstream ess;
+            std::ostringstream ess;
             ess << "Error:  morphology method " << method << " not supported, choose " << filter2d::dilate << " (dilate) or " << filter2d::erode << " (erode)" << endl;
             throw(ess.str());
             break;
diff --git a/src/apps/pkfillnodata.cc b/src/apps/pkfillnodata.cc
index 90136b9..5f7a84c 100644
--- a/src/apps/pkfillnodata.cc
+++ b/src/apps/pkfillnodata.cc
@@ -23,13 +23,14 @@ along with pktools.  If not, see <http://www.gnu.org/licenses/>.
 extern "C" {
 #include "gdal_alg.h"
 }
+#include <string>
 #include "base/Optionpk.h"
 
 int main(int argc,char **argv) {
-  Optionpk<string> input_opt("i", "input", "Input image file (WARNING: will be overwritten with output!", "");
+  Optionpk<std::string> input_opt("i", "input", "Input image file (WARNING: will be overwritten with output!", "");
   Optionpk<int> band_opt("b", "band", "band(s) to process (Default is -1: process all bands)", -1);
-  Optionpk<string> mask_opt("m", "mask", "Mask band indicating pixels to be interpolated (zero valued) ", "");
-  Optionpk<string> output_opt("o", "output", "Output image file", "");
+  Optionpk<std::string> mask_opt("m", "mask", "Mask band indicating pixels to be interpolated (zero valued) ", "");
+  Optionpk<std::string> output_opt("o", "output", "Output image file", "");
   Optionpk<double> distance_opt("d", "distance", "Maximum number of pixels to search in all directions to find values to interpolate from (default is 3", 3);
   Optionpk<int> iteration_opt("it", "iteration", "Number of 3x3 smoothing filter passes to run (default 0)", 0);
   Optionpk<short> verbose_opt("v", "verbose", "verbose", 0);
@@ -44,7 +45,7 @@ int main(int argc,char **argv) {
     iteration_opt.retrieveOption(argc,argv);
     verbose_opt.retrieveOption(argc,argv);
   }
-  catch(string predefinedString){
+  catch(std::string predefinedString){
     std::cout << predefinedString << std::endl;
     exit(0);
   }
@@ -56,35 +57,35 @@ int main(int argc,char **argv) {
   GDALAllRegister();
   GDALDataset *gds_input;
   if(verbose_opt[0])
-    cout << "opening input file " << input_opt[0] << endl;
+    std::cout << "opening input file " << input_opt[0] << std::endl;
   gds_input = (GDALDataset *) GDALOpen(input_opt[0].c_str(), GA_ReadOnly);
   if(gds_input == NULL){
-    string errorString="FileOpenError";
+    std::string errorString="FileOpenError";
     throw(errorString);
   }
 
   GDALDataset *gds_mask;
   if(verbose_opt[0])
-    cout << "opening mask file " << mask_opt[0] << endl;
+    std::cout << "opening mask file " << mask_opt[0] << std::endl;
   gds_mask = (GDALDataset *) GDALOpen(mask_opt[0].c_str(), GA_ReadOnly );
   if(gds_mask == NULL){
-    string errorString="FileOpenError";
+    std::string errorString="FileOpenError";
     throw(errorString);
   }
   GDALRasterBand *maskBand;
   if(verbose_opt[0])
-    cout << "get mask raster band" << endl;
+    std::cout << "get mask raster band" << std::endl;
   maskBand=gds_mask->GetRasterBand(1);
   
 
   GDALDriver *poDriver;
   poDriver = GetGDALDriverManager()->GetDriverByName(gds_input->GetDriver()->GetDescription());
   if( poDriver == NULL ){
-    string errorString="FileOpenError";
+    std::string errorString="FileOpenError";
     throw(errorString);
   }
   if(verbose_opt[0])
-    cout << "copying input file to " << output_opt[0] << endl;
+    std::cout << "copying input file to " << output_opt[0] << std::endl;
   poDriver->CopyFiles(output_opt[0].c_str(),input_opt[0].c_str());
   GDALDataset *gds_out;
   gds_out=(GDALDataset *) GDALOpen(output_opt[0].c_str(), GA_Update);
@@ -98,14 +99,14 @@ int main(int argc,char **argv) {
   for(unsigned short iband=0;iband<band_opt.size();++iband){
     targetBand=gds_out->GetRasterBand(band_opt[iband]+1);
     if(verbose_opt[0])
-      cout << "copying input file to " << output_opt[0] << endl;
+      std::cout << "copying input file to " << output_opt[0] << std::endl;
     double dfComplete=0.0;
     const char* pszMessage;
     void* pProgressArg=NULL;
     GDALProgressFunc pfnProgress=GDALTermProgress;
     pfnProgress(dfComplete,pszMessage,pProgressArg);
     if(GDALFillNodata(targetBand,maskBand,distance_opt[0],0,iteration_opt[0],NULL,pfnProgress,pProgressArg)!=CE_None){
-      cerr << CPLGetLastErrorMsg() << endl;
+      std::cerr << CPLGetLastErrorMsg() << std::endl;
       exit(1);
     }
     else{
diff --git a/src/apps/pkfilter.cc b/src/apps/pkfilter.cc
index 8de6a8f..eede73a 100644
--- a/src/apps/pkfilter.cc
+++ b/src/apps/pkfilter.cc
@@ -41,14 +41,15 @@ int main(int argc,char **argv) {
   Optionpk<std::string> output_opt("o", "output", "Output image file");
   Optionpk<bool> disc_opt("c", "circular", "circular disc kernel for dilation and erosion", false);
   Optionpk<double> angle_opt("a", "angle", "angle used for directional filtering in dilation (North=0, East=90, South=180, West=270).");
-  Optionpk<std::string> method_opt("f", "filter", "filter function (median,var,min,max,sum,mean,minmax,dilate,erode,close,open,spatially homogeneous (central pixel must be identical to all other pixels within window),SobelX edge detection in X,SobelY edge detection in Y,SobelXY,SobelYX,smooth,density,majority voting (only for classes),forest aggregation (mixed),smooth no data (mask) values,threshold local filtering,ismin,ismax,heterogeneous (central pixel must be different than all other [...]
+  Optionpk<std::string> method_opt("f", "filter", "filter function (median,var,min,max,sum,mean,minmax,dilate,erode,close,open,spatially homogeneous (central pixel must be identical to all other pixels within window),SobelX edge detection in X,SobelY edge detection in Y,SobelXY,SobelYX,smooth,density,majority voting (only for classes),forest aggregation (mixed),smooth no data (mask) values,threshold local filtering,ismin,ismax,heterogeneous (central pixel must be different than all other [...]
+  Optionpk<std::string> resample_opt("r", "resampling-method", "Resampling method for shifting operation (near: nearest neighbour, bilinear: bi-linear interpolation).", "near");
   Optionpk<int> dimX_opt("dx", "dx", "filter kernel size in x, must be odd", 3);
   Optionpk<int> dimY_opt("dy", "dy", "filter kernel size in y, must be odd", 3);
   Optionpk<int> dimZ_opt("dz", "dz", "filter kernel size in z (band or spectral dimension), must be odd (example: 3).. Set dz>0 if 1-D filter must be used in band domain");
   Optionpk<std::string> wavelet_type_opt("wt", "wavelet", "wavelet type: daubechies,daubechies_centered, haar, haar_centered, bspline, bspline_centered", "daubechies");
   Optionpk<int> family_opt("wf", "family", "wavelet family (vanishing moment, see also http://www.gnu.org/software/gsl/manual/html_node/DWT-Initialization.html)", 4);
   Optionpk<short> class_opt("class", "class", "class value(s) to use for density, erosion, dilation, openening and closing, thresholding");
-  Optionpk<double> threshold_opt("t", "threshold", "threshold value(s) to use for threshold filter (one for each class), or quantization for dwtQuantize", 0);
+  Optionpk<double> threshold_opt("t", "threshold", "threshold value(s) to use for threshold filter (one for each class), or quantization for dwtQuantize, or sigma for shift", 0);
   Optionpk<short> mask_opt("m", "mask", "mask value(s) ");
   Optionpk<std::string> tap_opt("tap", "tap", "text file containing taps used for spatial filtering (from ul to lr). Use dimX and dimY to specify tap dimensions in x and y. Leave empty for not using taps");
   Optionpk<double> tapz_opt("tapz", "tapz", "taps used for spectral filtering");
@@ -72,6 +73,7 @@ int main(int argc,char **argv) {
     disc_opt.retrieveOption(argc,argv);
     angle_opt.retrieveOption(argc,argv);
     method_opt.retrieveOption(argc,argv);
+    resample_opt.retrieveOption(argc,argv);
     dimX_opt.retrieveOption(argc,argv);
     dimY_opt.retrieveOption(argc,argv);
     dimZ_opt.retrieveOption(argc,argv);
@@ -410,6 +412,18 @@ int main(int argc,char **argv) {
       filter2d.doit(input,output,"heterog",dimX_opt[0],dimY_opt[0],down_opt[0],disc_opt[0]);
       break;
     }
+    case(filter2d::shift):{//spatially heterogeneous
+      assert(input.nrOfBand());
+      assert(input.nrOfCol());
+      assert(input.nrOfRow());
+      try{
+        filter2d.shift(input,output,dimX_opt[0],dimY_opt[0],threshold_opt[0],filter2d::Filter2d::getResampleType(resample_opt[0]));
+      }
+      catch(string errorstring){
+        cerr << errorstring << endl;
+      }
+      break;
+    }
     case(filter2d::mrf):{//Markov Random Field
       if(verbose_opt[0])
 	std::cout << "Markov Random Field filtering" << std::endl;
diff --git a/src/base/IndexValue.h b/src/base/IndexValue.h
index 02f2482..c380982 100644
--- a/src/base/IndexValue.h
+++ b/src/base/IndexValue.h
@@ -20,8 +20,6 @@ along with pktools.  If not, see <http://www.gnu.org/licenses/>.
 #ifndef _INDEXVALUE_H_
 #define _INDEXVALUE_H_
 
-using namespace std;
-
 struct IndexValue{
   int position;
   double value;
diff --git a/src/base/Optionpk.h b/src/base/Optionpk.h
index 4155218..b1fdbaf 100644
--- a/src/base/Optionpk.h
+++ b/src/base/Optionpk.h
@@ -36,12 +36,10 @@ along with pktools.  If not, see <http://www.gnu.org/licenses/>.
 #include <config.h>
 #endif
 
-using namespace std;
-
 ///throw this class when syntax error in command line option
-class BadConversion : public runtime_error {
+class BadConversion : public std::runtime_error {
  public:
- BadConversion(string const& s)
+ BadConversion(std::string const& s)
    : runtime_error(s)
     { }
 };
@@ -164,7 +162,7 @@ public:
   ///set help information
   void setHelp(const std::string& helpInfo){m_help=helpInfo;};
   bool retrieveOption(int argc, char ** argv);
-  template<class T1> friend ostream& operator<<(ostream & os, const Optionpk<T1>& theOption);
+  template<class T1> friend std::ostream& operator<<(std::ostream & os, const Optionpk<T1>& theOption);
 
   void setAll(const std::string& shortName, const std::string& longName, const std::string& helpInfo);
   void setAll(const std::string& shortName, const std::string& longName, const std::string& helpInfo,const T& defaultValue, short hide);
@@ -207,7 +205,7 @@ private:
   short m_hide;
 };
 
-template<class T1> ostream& operator<<(ostream& os, const Optionpk<T1>& theOption)
+template<class T1> std::ostream& operator<<(std::ostream& os, const Optionpk<T1>& theOption)
 {
   os << theOption.getLongName() << ": ";
   for(int index=0;index<theOption.size();++index)
@@ -256,13 +254,13 @@ template<class T> std::string Optionpk<T>::usage() const
   shortOption.insert(0,"-");
   longOption.insert(0,"--");
   if(hasShortOption())
-    helpss << "   " << setiosflags(ios::left) << setw(4) << shortOption;
+    helpss << "   " << std::setiosflags(std::ios::left) << std::setw(4) << shortOption;
   else
-    helpss << "   " << setiosflags(ios::left) << setw(4) << " ";
+    helpss << "   " << std::setiosflags(std::ios::left) << std::setw(4) << " ";
   if(hasLongOption())
-    helpss << "   " << setiosflags(ios::left) << setw(20) << longOption;
+    helpss << "   " << std::setiosflags(std::ios::left) << std::setw(20) << longOption;
   else
-    helpss << "   " << setiosflags(ios::left) << setw(20) << " ";
+    helpss << "   " << std::setiosflags(std::ios::left) << std::setw(20) << " ";
   helpss << "   " << m_help;
   if(m_hasDefault)
     helpss << " (default: " << type2string<T>(m_defaultValue) << ")";
@@ -276,17 +274,17 @@ template<class T> std::string Optionpk<T>::usageDoxygen() const
   std::string longOption=m_longName;
 
   if(hasShortOption())
-    helpss << " | " << setiosflags(ios::left) << setw(6) << shortOption << " | ";
+    helpss << " | " << std::setiosflags(std::ios::left) << std::setw(6) << shortOption << " | ";
   else
-    helpss << " | " << setiosflags(ios::left) << "       | ";
+    helpss << " | " << std::setiosflags(std::ios::left) << "       | ";
   if(hasLongOption())
-    helpss << setiosflags(ios::left) << setw(20) << longOption << " | ";
+    helpss << std::setiosflags(std::ios::left) << std::setw(20) << longOption << " | ";
   else
-    helpss << setiosflags(ios::left) << "                     | ";
+    helpss << std::setiosflags(std::ios::left) << "                     | ";
   int status;
-  helpss << setiosflags(ios::left) << setw(4) << abi::__cxa_demangle(typeid(T).name(),0,0,&status) << " | ";
+  helpss << std::setiosflags(std::ios::left) << std::setw(4) << abi::__cxa_demangle(typeid(T).name(),0,0,&status) << " | ";
   if(m_hasDefault)
-    helpss <<setiosflags(ios::left) << setw(5) << type2string<T>(m_defaultValue) << " |";
+    helpss <<std::setiosflags(std::ios::left) << std::setw(5) << type2string<T>(m_defaultValue) << " |";
   else
     helpss << "      |";
   helpss << m_help << " | ";
diff --git a/src/base/Vector2d.h b/src/base/Vector2d.h
index a8f0ba7..3cb8703 100644
--- a/src/base/Vector2d.h
+++ b/src/base/Vector2d.h
@@ -28,8 +28,7 @@ along with pktools.  If not, see <http://www.gnu.org/licenses/>.
 #include "IndexValue.h"
 #include "algorithms/StatFactory.h"
 
-using namespace std;
-template<class T> class Vector2d: public vector<vector <T> >
+template<class T> class Vector2d: public std::vector<std::vector <T> >
 {
 public:
   Vector2d();
@@ -41,15 +40,15 @@ public:
   Vector2d(const gsl_matrix* gsl_m);
   void resize(int nrow)
   {
-    vector< vector<T> >::resize(nrow);
+    std::vector< std::vector<T> >::resize(nrow);
   };
   void resize(int nrow, int ncol);
   int nRows() const {return this->size();};
   int nCols() const {if(this->size()) return this->begin()->size(); else return 0;};
-  void selectCol(int col, vector<T> &output) const;
+  void selectCol(int col, std::vector<T> &output) const;
   void selectCol(int col, T* output) const;
-  vector<T> selectCol(int col);
-  void selectCols(const list<int> &cols, Vector2d<T> &output) const;
+  std::vector<T> selectCol(int col);
+  void selectCols(const std::list<int> &cols, Vector2d<T> &output) const;
   void transpose(Vector2d<T> &output) const{
     output.resize(nCols(),nRows());
     for(int irow=0;irow<nRows();++irow){
@@ -58,10 +57,10 @@ public:
       }
     }
   };
-  void selectCols(const list<int> &cols);
+  void selectCols(const std::list<int> &cols);
   void sort(Vector2d<T>& output);  
-  void scale(const vector<double> &scaleVector, const vector<double> &offsetVector, Vector2d<T>& scaledOutput);
-  void scale(const T lbound, const T ubound, vector<double> &scaleVector, vector<double> &offsetVector, Vector2d<T>& scaledOutput);
+  void scale(const std::vector<double> &scaleVector, const std::vector<double> &offsetVector, Vector2d<T>& scaledOutput);
+  void scale(const T lbound, const T ubound, std::vector<double> &scaleVector, std::vector<double> &offsetVector, Vector2d<T>& scaledOutput);
   Vector2d<T> operator=(const Vector2d<T>& v1);
 //   ostream& operator<<(ostream& os, const Vector2d<T>& v);
 //   template<class T> ostream& operator<<(ostream& os, const Vector2d<T>& v);
@@ -73,7 +72,7 @@ public:
 };
   
 template<class T> Vector2d<T>::Vector2d() 
-  : vector< vector<T> >()
+  : std::vector< std::vector<T> >()
 {
 }
 
@@ -101,12 +100,12 @@ template<class T> Vector2d<T> Vector2d<T>::operator=(const Vector2d<T>& v1){
 }
 
 template<class T> Vector2d<T>::Vector2d(int nrow) 
-  : vector< vector<T> >(nrow)
+  : std::vector< std::vector<T> >(nrow)
 {
 }
 
 template<class T> Vector2d<T>::Vector2d(int nrow, int ncol) 
-//   : vector< vector<T> >(nrow)
+//   : std::vector< std::vector<T> >(nrow)
 {
   this->resize(nrow);
   for(int irow=0;irow<nrow;++irow){
@@ -138,16 +137,16 @@ template<class T> Vector2d<T>::Vector2d(const gsl_matrix* gsl_m)
 
 template<class T> void Vector2d<T>::resize(int nrow, int ncol)
 {
-    this->vector< vector<T> >::resize(nrow);
+    this->std::vector< std::vector<T> >::resize(nrow);
     for(int irow=0;irow<nrow;++irow){
       (this->operator[](irow)).resize(ncol);
     }
 }
 
-template<class T> void Vector2d<T>::selectCols(const list<int> &cols, Vector2d<T> &output) const
+template<class T> void Vector2d<T>::selectCols(const std::list<int> &cols, Vector2d<T> &output) const
 {
   output.resize(this->size());
-  list<int>::const_iterator it;
+  std::list<int>::const_iterator it;
   for(int irow=0;irow<this->size();++irow){
     output[irow].resize(cols.size());
     it=cols.begin();
@@ -156,7 +155,7 @@ template<class T> void Vector2d<T>::selectCols(const list<int> &cols, Vector2d<T
   }
 }
 
-template<class T> void Vector2d<T>::selectCol(int col, vector<T> &output) const
+template<class T> void Vector2d<T>::selectCol(int col, std::vector<T> &output) const
 {
   assert(col>=0);
   assert(col<(*this)[0].size());
@@ -166,11 +165,11 @@ template<class T> void Vector2d<T>::selectCol(int col, vector<T> &output) const
   }
 }
 
-template<class T> vector<T> Vector2d<T>::selectCol(int col)
+template<class T> std::vector<T> Vector2d<T>::selectCol(int col)
 {
   assert(col>=0);
   assert(col<(*this)[0].size());
-  vector<T> output(this->size());
+  std::vector<T> output(this->size());
   for(int irow=0;irow<this->size();++irow)
     output[irow]=(*this)[irow][col];
   return(output);
@@ -185,7 +184,7 @@ template<class T> void Vector2d<T>::selectCol(int col, T* output) const
   }
 }
 
-template<class T> void Vector2d<T>::selectCols(const list<int> &cols)
+template<class T> void Vector2d<T>::selectCols(const std::list<int> &cols)
 {
   for(int irow=0;irow<this->size();++irow)
     for(int icol=((*this)[irow]).size()-1;icol>=0;--icol)
@@ -214,7 +213,7 @@ template<class T> void Vector2d<T>::sort(Vector2d<T>& output)
   //sort according to first sample (ex. wavelength)
   int nsample=this->size();//including first sample (ex. wavelength)
   int nband=(*this)[0].size();  
-  vector<IndexValue> sortW(nband);
+  std::vector<IndexValue> sortW(nband);
   for(int ilevel=0;ilevel<nband;++ilevel){
     IndexValue pv;
     pv.position=ilevel;
@@ -230,27 +229,27 @@ template<class T> void Vector2d<T>::sort(Vector2d<T>& output)
   }
 }
 
-template<class T> void Vector2d<T>::scale(const vector<double> &scaleVector,const vector<double> &offsetVector, Vector2d<T>& scaledOutput)
+template<class T> void Vector2d<T>::scale(const std::vector<double> &scaleVector,const std::vector<double> &offsetVector, Vector2d<T>& scaledOutput)
 {
   int nsample=this->size();//including first sample (ex. wavelength)
   int nband=(*this)[0].size();
   assert(scaleVector.size()==nband);
   assert(offsetVector.size()==nband);
-  vector<T> pixel(nband);
+  std::vector<T> pixel(nband);
   scaledOutput.resize(nsample,nband);
   for(int isample=0;isample<nsample;++isample)
     for(int iband=0;iband<nband;++iband)
       scaledOutput[isample][iband]=((*this)[isample][iband])*scaleVector[iband]+offsetVector[iband];
 }
 
-template<class T> void Vector2d<T>::scale(const T lbound, const T ubound, vector<double> &scaleVector, vector<double> &offsetVector, Vector2d<T>& scaledOutput)
+template<class T> void Vector2d<T>::scale(const T lbound, const T ubound, std::vector<double> &scaleVector, std::vector<double> &offsetVector, Vector2d<T>& scaledOutput)
 {
   //scale to lbound and ubound
   int nsample=this->size();//including first sample (ex. wavelength)
   int nband=(*this)[0].size();
   scaleVector.resize(nband);
   offsetVector.resize(nband);
-  vector<T> pixel(nsample);
+  std::vector<T> pixel(nsample);
   T theMin;
   T theMax;
   statfactory::StatFactory stat;
diff --git a/src/imageclasses/ImgReaderGdal.cc b/src/imageclasses/ImgReaderGdal.cc
index 7c1991c..fa46a30 100644
--- a/src/imageclasses/ImgReaderGdal.cc
+++ b/src/imageclasses/ImgReaderGdal.cc
@@ -26,7 +26,7 @@ ImgReaderGdal::ImgReaderGdal(void)
   : m_gds(NULL), m_isGeoRef(false), m_ncol(0), m_nrow(0), m_nband(0)
 {}
 
-void ImgReaderGdal::open(const string& filename)//, double magicX, double magicY)
+void ImgReaderGdal::open(const std::string& filename)//, double magicX, double magicY)
 {
   m_filename = filename;
   setCodec();//magicX,magicY);
@@ -50,13 +50,13 @@ void ImgReaderGdal::setCodec()//double magicX, double magicY)
   GDALAllRegister();
   m_gds = (GDALDataset *) GDALOpen(m_filename.c_str(), GA_ReadOnly );
   if(m_gds == NULL){
-    string errorString="FileOpenError";
+    std::string errorString="FileOpenError";
     throw(errorString);
   }
   m_ncol= m_gds->GetRasterXSize();
   m_nrow= m_gds->GetRasterYSize();
   m_nband= m_gds->GetRasterCount();
-  m_isGeoRef=( static_cast<string>(m_gds->GetProjectionRef())  != "" );
+  m_isGeoRef=( static_cast<std::string>(m_gds->GetProjectionRef())  != "" );
   // m_magic_x=magicX;
   // m_magic_y=magicY;
   if(m_isGeoRef){
@@ -77,20 +77,20 @@ void ImgReaderGdal::setCodec()//double magicX, double magicY)
   }
 }
 
-string ImgReaderGdal::getProjection(void) const 
+std::string ImgReaderGdal::getProjection(void) const 
 {
-  string theProjection=m_gds->GetProjectionRef();
+  std::string theProjection=m_gds->GetProjectionRef();
   // size_t startpos,endpos;
-  // while((startpos=theProjection.find(",AUTHORITY"))!=string::npos){
+  // while((startpos=theProjection.find(",AUTHORITY"))!=std::string::npos){
   //   endpos=theProjection.find("]",startpos+1,1)+1;
   //   theProjection.erase(startpos,endpos-startpos);
   // }
   return theProjection;
 }
 
-string ImgReaderGdal::getProjectionRef(void) const 
+std::string ImgReaderGdal::getProjectionRef(void) const 
 {
-  string theProjection;
+  std::string theProjection;
   if(m_gds->GetProjectionRef())
     return(m_gds->GetProjectionRef());
   else
@@ -115,7 +115,7 @@ GDALColorTable* ImgReaderGdal::getColorTable(int band) const
   return (m_gds->GetRasterBand(band+1))->GetColorTable();
 }
 
-string ImgReaderGdal::getDriverDescription() const
+std::string ImgReaderGdal::getDriverDescription() const
 {
   return m_gds->GetDriver()->GetDescription();
 }
@@ -132,7 +132,7 @@ void ImgReaderGdal::getGeoTransform(double& ulx, double& uly, double& deltaX, do
   deltaY=-adfGeoTransform[5];//convention of GDAL!
 }
 
-string ImgReaderGdal::getGeoTransform() const
+std::string ImgReaderGdal::getGeoTransform() const
 {
   if(!isGeoRef())
     return("");
@@ -145,7 +145,7 @@ string ImgReaderGdal::getGeoTransform() const
     double uly=adfGeoTransform[3];
     double rot2=adfGeoTransform[4];
     double deltaY=-adfGeoTransform[5];//convention of GDAL!
-    ostringstream s;
+    std::ostringstream s;
     s << "[" << ulx << "," << deltaX << "," << rot1 << "," << uly << "," << rot2 << "," << -deltaY << "]";
     return(s.str());
   }
@@ -167,7 +167,7 @@ char** ImgReaderGdal::getMetadata() const
     return (char**)"";
 }
 
-void ImgReaderGdal::getMetadata(list<string>& metadata) const
+void ImgReaderGdal::getMetadata(std::list<std::string>& metadata) const
 {
   char** cmetadata=m_gds->GetMetadata();
   while(*cmetadata!=NULL){
@@ -176,7 +176,7 @@ void ImgReaderGdal::getMetadata(list<string>& metadata) const
   }
 }
 
-string ImgReaderGdal::getDescription() const
+std::string ImgReaderGdal::getDescription() const
 {
   if(m_gds->GetDriver()->GetDescription()!=NULL)
     return m_gds->GetDriver()->GetDescription();
@@ -184,14 +184,14 @@ string ImgReaderGdal::getDescription() const
     return "";
 }
 
-string ImgReaderGdal::getMetadataItem() const 
+std::string ImgReaderGdal::getMetadataItem() const 
 {
   if(m_gds->GetDriver()->GetMetadataItem( GDAL_DMD_LONGNAME )!=NULL)
     return m_gds->GetDriver()->GetMetadataItem( GDAL_DMD_LONGNAME );
   else
     return "";
 }
-string ImgReaderGdal::getImageDescription() const 
+std::string ImgReaderGdal::getImageDescription() const 
 {
   if(m_gds->GetDriver()->GetMetadataItem("TIFFTAG_IMAGEDESCRIPTION")!=NULL)
     return m_gds->GetDriver()->GetMetadataItem("TIFFTAG_IMAGEDESCRIPTION");
@@ -199,7 +199,7 @@ string ImgReaderGdal::getImageDescription() const
     return "";
 }
 
-string ImgReaderGdal::getInterleave() const
+std::string ImgReaderGdal::getInterleave() const
 {
   if(m_gds->GetMetadataItem( "INTERLEAVE", "IMAGE_STRUCTURE"))
     return m_gds->GetMetadataItem( "INTERLEAVE", "IMAGE_STRUCTURE");
@@ -207,7 +207,7 @@ string ImgReaderGdal::getInterleave() const
     return("BAND");
 }
 
-string ImgReaderGdal::getCompression() const
+std::string ImgReaderGdal::getCompression() const
 {
   if(m_gds->GetMetadataItem( "COMPRESSION", "IMAGE_STRUCTURE"))
     return m_gds->GetMetadataItem( "COMPRESSION", "IMAGE_STRUCTURE");
@@ -307,7 +307,7 @@ bool ImgReaderGdal::covers(double ulx, double  uly, double lrx, double lry) cons
 
 double ImgReaderGdal::getMin(int& x, int& y, int band) const{
   double minValue=0;
-  vector<double> lineBuffer(nrOfCol());
+  std::vector<double> lineBuffer(nrOfCol());
   bool init=false;
   for(int irow=0;irow<nrOfRow();++irow){
     readData(lineBuffer,GDT_Float64,irow,band);
@@ -331,12 +331,12 @@ double ImgReaderGdal::getMin(int& x, int& y, int band) const{
   if(init)
     return minValue;
   else
-    throw(static_cast<string>("Warning: not initialized"));
+    throw(static_cast<std::string>("Warning: not initialized"));
 }
 
 double ImgReaderGdal::getMax(int& x, int& y, int band) const{
   double maxValue=0;
-  vector<double> lineBuffer(nrOfCol());
+  std::vector<double> lineBuffer(nrOfCol());
   bool init=false;
   for(int irow=0;irow<nrOfRow();++irow){
     readData(lineBuffer,GDT_Float64,irow,band);
@@ -360,7 +360,7 @@ double ImgReaderGdal::getMax(int& x, int& y, int band) const{
   if(init)
     return maxValue;
   else
-    throw(static_cast<string>("Warning: not initialized"));
+    throw(static_cast<std::string>("Warning: not initialized"));
 }
 
 void ImgReaderGdal::getMinMax(int startCol, int endCol, int startRow, int endRow, int band, double& minValue, double& maxValue) const
@@ -378,7 +378,7 @@ void ImgReaderGdal::getMinMax(int startCol, int endCol, int startRow, int endRow
   minValue=adfMinMax[0];
   maxValue=adfMinMax[1];
 
-  vector<double> lineBuffer(endCol-startCol+1);
+  std::vector<double> lineBuffer(endCol-startCol+1);
   bool init=false;
   assert(endRow<nrOfRow());
   for(int irow=startCol;irow<endRow+1;++irow){
@@ -401,7 +401,7 @@ void ImgReaderGdal::getMinMax(int startCol, int endCol, int startRow, int endRow
     }
   }
   if(!init)
-    throw(static_cast<string>("Warning: not initialized"));
+    throw(static_cast<std::string>("Warning: not initialized"));
 }
 
 void ImgReaderGdal::getMinMax(double& minValue, double& maxValue, int band, bool exhaustiveSearch) const
@@ -419,7 +419,7 @@ void ImgReaderGdal::getMinMax(double& minValue, double& maxValue, int band, bool
   minValue=adfMinMax[0];
   maxValue=adfMinMax[1];
   if(exhaustiveSearch){//force exhaustive search
-    vector<double> lineBuffer(nrOfCol());
+    std::vector<double> lineBuffer(nrOfCol());
     bool init=false;
     for(int irow=0;irow<nrOfRow();++irow){
       readData(lineBuffer,GDT_Float64,irow,band);
@@ -441,11 +441,11 @@ void ImgReaderGdal::getMinMax(double& minValue, double& maxValue, int band, bool
       }
     }
     if(!init)
-      throw(static_cast<string>("Warning: not initialized"));
+      throw(static_cast<std::string>("Warning: not initialized"));
   }
 }
 
-unsigned long int ImgReaderGdal::getHistogram(vector<unsigned long int>& histvector, double& min, double& max, int& nbin, int theBand) const{
+unsigned long int ImgReaderGdal::getHistogram(std::vector<unsigned long int>& histvector, double& min, double& max, int& nbin, int theBand) const{
   double minValue=0;
   double maxValue=0;
   getMinMax(minValue,maxValue,theBand);
@@ -484,9 +484,9 @@ unsigned long int ImgReaderGdal::getHistogram(vector<unsigned long int>& histvec
   return nvalid;
 }
 
-void ImgReaderGdal::getRange(vector<short>& range, int band) const
+void ImgReaderGdal::getRange(std::vector<short>& range, int band) const
 {
-  vector<short> lineBuffer(nrOfCol());
+  std::vector<short> lineBuffer(nrOfCol());
   range.clear();
   for(int irow=0;irow<nrOfRow();++irow){
     readData(lineBuffer,GDT_Int16,irow,band);
@@ -498,7 +498,7 @@ void ImgReaderGdal::getRange(vector<short>& range, int band) const
   sort(range.begin(),range.end());
 }
 
-int ImgReaderGdal::getNoDataValues(vector<double>& noDataValues) const
+int ImgReaderGdal::getNoDataValues(std::vector<double>& noDataValues) const
 {
   if(m_noDataValues.size()){
     noDataValues=m_noDataValues;
@@ -527,7 +527,7 @@ int ImgReaderGdal::pushNoDataValue(double noDataValue)
 
 void ImgReaderGdal::getRefPix(double& refX, double &refY, int band) const
 {
-  vector<double> lineBuffer(nrOfCol());
+  std::vector<double> lineBuffer(nrOfCol());
   double validCol=0;
   double validRow=0;
   int nvalidCol=0;
diff --git a/src/imageclasses/ImgReaderGdal.h b/src/imageclasses/ImgReaderGdal.h
index cb053d6..b46a659 100644
--- a/src/imageclasses/ImgReaderGdal.h
+++ b/src/imageclasses/ImgReaderGdal.h
@@ -27,7 +27,7 @@ along with pktools.  If not, see <http://www.gnu.org/licenses/>.
 #include "gdal_priv.h"
 #include "base/Vector2d.h"
 
-using namespace std;
+// using namespace std;
 
 enum RESAMPLE { NEAR = 0, BILINEAR = 1, BICUBIC = 2 };
 
@@ -36,21 +36,21 @@ class ImgReaderGdal
 {
 public:
   ImgReaderGdal(void);
-  ImgReaderGdal(const string& filename){open(filename);};
+  ImgReaderGdal(const std::string& filename){open(filename);};
   ~ImgReaderGdal(void);
-  void open(const string& filename);//, double magicX=1, double magicY=1);
+  void open(const std::string& filename);//, double magicX=1, double magicY=1);
   void close(void);
   int nrOfCol(void) const { return m_ncol;};
   int nrOfRow(void) const { return m_nrow;};
   int nrOfBand(void) const { return m_nband;};
   bool isGeoRef() const {return m_isGeoRef;};
-  string getProjection(void) const;
-  string getProjectionRef(void) const;
-  string getGeoTransform() const;
+  std::string getProjection(void) const;
+  std::string getProjectionRef(void) const;
+  std::string getGeoTransform() const;
   void getGeoTransform(double& ulx, double& uly, double& deltaX, double& deltaY, double& rot1, double& rot2) const;
-  string getDescription() const;
-  string getMetadataItem() const;
-  string getImageDescription() const;
+  std::string getDescription() const;
+  std::string getMetadataItem() const;
+  std::string getImageDescription() const;
   bool getBoundingBox (double& ulx, double& uly, double& lrx, double& lry) const;
   bool getCentrePos(double& x, double& y) const;
   double getUlx() const {return (m_isGeoRef)? m_ulx : 0;};
@@ -58,7 +58,7 @@ public:
   double getLrx() const {return (m_isGeoRef)? m_ulx+nrOfCol()*m_delta_x : nrOfCol()-1;};
   double getLry() const {return (m_isGeoRef)? m_uly-nrOfRow()*m_delta_y : 0;};
   // bool getMagicPixel(double& magicX, double& magicY) const {magicX=m_magic_x;magicY=m_magic_y;};
-  int getNoDataValues(vector<double>& noDataValues) const;
+  int getNoDataValues(std::vector<double>& noDataValues) const;
   bool isNoData(double value) const{return find(m_noDataValues.begin(),m_noDataValues.end(),value)!=m_noDataValues.end();};
   int pushNoDataValue(double noDataValue);
   CPLErr GDALSetNoDataValue(double noDataValue, int band=0) {getRasterBand(band)->SetNoDataValue(noDataValue);};
@@ -69,36 +69,36 @@ public:
   double getDeltaX(void) const {return m_delta_x;};
   double getDeltaY(void) const {return m_delta_y;};
   template<typename T> void readData(T& value, const GDALDataType& dataType, int col, int row, int band=0) const;
-  template<typename T> void readData(vector<T>& buffer, const GDALDataType& dataType , int minCol, int maxCol, int row, int band=0) const;
-  template<typename T> void readData(vector<T>& buffer, const GDALDataType& dataType , int minCol, int maxCol, double row, int band=0, RESAMPLE resample=0) const;
+  template<typename T> void readData(std::vector<T>& buffer, const GDALDataType& dataType , int minCol, int maxCol, int row, int band=0) const;
+  template<typename T> void readData(std::vector<T>& buffer, const GDALDataType& dataType , int minCol, int maxCol, double row, int band=0, RESAMPLE resample=0) const;
   template<typename T> void readDataBlock(Vector2d<T>& buffer, const GDALDataType& dataType , int minCol, int maxCol, int minRow, int maxRow, int band=0) const;
-  template<typename T> void readDataBlock(vector<T>& buffer, const GDALDataType& dataType , int minCol, int maxCol, int minRow, int maxRow, int band=0) const;
-  template<typename T> void readData(vector<T>& buffer, const GDALDataType& dataType, int row, int band=0) const;
-  template<typename T> void readData(vector<T>& buffer, const GDALDataType& dataType, double row, int band=0, RESAMPLE resample=0) const;
+  template<typename T> void readDataBlock(std::vector<T>& buffer, const GDALDataType& dataType , int minCol, int maxCol, int minRow, int maxRow, int band=0) const;
+  template<typename T> void readData(std::vector<T>& buffer, const GDALDataType& dataType, int row, int band=0) const;
+  template<typename T> void readData(std::vector<T>& buffer, const GDALDataType& dataType, double row, int band=0, RESAMPLE resample=0) const;
   void getMinMax(int startCol, int endCol, int startRow, int endRow, int band, double& minValue, double& maxValue) const;
   void getMinMax(double& minValue, double& maxValue, int band=0, bool exhaustiveSearch=false) const;
   double getMin(int& col, int& row, int band=0) const;
-  unsigned long int getHistogram(vector<unsigned long int>& histvector, double& min, double& max,int& nbin, int theBand=0) const;
+  unsigned long int getHistogram(std::vector<unsigned long int>& histvector, double& min, double& max,int& nbin, int theBand=0) const;
   double getMax(int& col, int& row, int band=0) const;
   void getRefPix(double& refX, double &refY, int band=0) const;
-  void getRange(vector<short>& range, int Band=0) const;
+  void getRange(std::vector<short>& range, int Band=0) const;
   GDALDataType getDataType(int band=0) const;
   GDALRasterBand* getRasterBand(int band=0);
   GDALColorTable* getColorTable(int band=0) const;
-  string getDriverDescription() const;
-  string getImageType() const{return getDriverDescription();};
-//   string getImageType() const{return "GTiff";};
-  string getInterleave() const;
-  string getCompression() const;
+  std::string getDriverDescription() const;
+  std::string getImageType() const{return getDriverDescription();};
+//   std::string getImageType() const{return "GTiff";};
+  std::string getInterleave() const;
+  std::string getCompression() const;
   GDALDataset* getDataset(){return m_gds;};
   char** getMetadata();
   char** getMetadata() const;
-  void getMetadata(list<string>& metadata) const;
+  void getMetadata(std::list<std::string>& metadata) const;
 
 protected:
   void setCodec();//double magicX, double magicY);
 
-  string m_filename;
+  std::string m_filename;
   GDALDataset *m_gds;
   int m_ncol;
   int m_nrow;
@@ -110,7 +110,7 @@ protected:
   // double m_magic_x;
   // double m_magic_y;
   bool m_isGeoRef;
-  vector<double> m_noDataValues;
+  std::vector<double> m_noDataValues;
 };
 
 //     adfGeoTransform[0] /* top left x */
@@ -133,7 +133,7 @@ template<typename T> void ImgReaderGdal::readData(T& value, const GDALDataType&
   poBand->RasterIO(GF_Read,col,row,1,1,&value,1,1,dataType,0,0);
 }
 
-template<typename T> void ImgReaderGdal::readData(vector<T>& buffer, const GDALDataType& dataType, int minCol, int maxCol, int row, int band) const
+template<typename T> void ImgReaderGdal::readData(std::vector<T>& buffer, const GDALDataType& dataType, int minCol, int maxCol, int row, int band) const
 {
   //fetch raster band
   GDALRasterBand  *poBand;
@@ -150,10 +150,10 @@ template<typename T> void ImgReaderGdal::readData(vector<T>& buffer, const GDALD
   poBand->RasterIO(GF_Read,minCol,row,buffer.size(),1,&(buffer[0]),buffer.size(),1,dataType,0,0);
 }
 
-template<typename T> void ImgReaderGdal::readData(vector<T>& buffer, const GDALDataType& dataType , int minCol, int maxCol, double row, int band, RESAMPLE resample) const
+template<typename T> void ImgReaderGdal::readData(std::vector<T>& buffer, const GDALDataType& dataType , int minCol, int maxCol, double row, int band, RESAMPLE resample) const
 {
-  vector<T> readBuffer_upper;
-  vector<T> readBuffer_lower;
+  std::vector<T> readBuffer_upper;
+  std::vector<T> readBuffer_lower;
   if(buffer.size()!=maxCol-minCol+1)
     buffer.resize(maxCol-minCol+1);
   double upperRow=row-0.5;
@@ -188,7 +188,7 @@ template<typename T> void ImgReaderGdal::readDataBlock(Vector2d<T>& buffer, cons
   }
 }
   
-template<typename T> void ImgReaderGdal::readDataBlock(vector<T>& buffer, const GDALDataType& dataType , int minCol, int maxCol, int minRow, int maxRow, int band) const
+template<typename T> void ImgReaderGdal::readDataBlock(std::vector<T>& buffer, const GDALDataType& dataType , int minCol, int maxCol, int minRow, int maxRow, int band) const
 {
   //fetch raster band
   GDALRasterBand  *poBand;
@@ -228,12 +228,12 @@ template<typename T> void ImgReaderGdal::readDataBlock(vector<T>& buffer, const
 //     poBand->RasterIO(GF_Read,minCol,minRow+irow,maxCol-minCol+1,1,&(buffer[irow*(maxCol-minCol+1)]),maxCol-minCol+1,1,dataType,0,0);
 // }
   
-template<typename T> void ImgReaderGdal::readData(vector<T>& buffer, const GDALDataType& dataType, int row, int band) const
+template<typename T> void ImgReaderGdal::readData(std::vector<T>& buffer, const GDALDataType& dataType, int row, int band) const
 {
   readData(buffer,dataType,0,nrOfCol()-1,row,band);
 }
 
-template<typename T> void ImgReaderGdal::readData(vector<T>& buffer, const GDALDataType& dataType, double row, int band, RESAMPLE resample) const
+template<typename T> void ImgReaderGdal::readData(std::vector<T>& buffer, const GDALDataType& dataType, double row, int band, RESAMPLE resample) const
 {
   readData(buffer,dataType,0,nrOfCol()-1,row,band,resample);
 }
diff --git a/src/imageclasses/ImgReaderOgr.cc b/src/imageclasses/ImgReaderOgr.cc
index 075f7be..fe172ba 100644
--- a/src/imageclasses/ImgReaderOgr.cc
+++ b/src/imageclasses/ImgReaderOgr.cc
@@ -26,7 +26,7 @@ along with pktools.  If not, see <http://www.gnu.org/licenses/>.
 ImgReaderOgr::ImgReaderOgr(void)
 {}
 
-ImgReaderOgr::ImgReaderOgr(const string& filename)
+ImgReaderOgr::ImgReaderOgr(const std::string& filename)
 {
   open(filename);
 }
@@ -37,7 +37,7 @@ ImgReaderOgr::~ImgReaderOgr(void)
 
 //---------------------------------------------------------------------------
 
-void ImgReaderOgr::open(const string& filename)
+void ImgReaderOgr::open(const std::string& filename)
 {
   m_filename = filename;
   setCodec();
@@ -56,7 +56,7 @@ void ImgReaderOgr::setCodec(void){
   //open the input OGR datasource. Datasources can be files, RDBMSes, directories full of files, or even remote web services depending on the driver being used. However, the datasource name is always a single string.
   m_datasource = OGRSFDriverRegistrar::Open(m_filename.c_str(), FALSE);//FAlSE: do not update
   if( m_datasource == NULL ){
-    string errorString="Open failed";
+    std::string errorString="Open failed";
     throw(errorString);
   }
 }
@@ -87,21 +87,21 @@ int ImgReaderOgr::getFieldCount(int layer) const
   assert(m_datasource->GetLayerCount()>layer);
   OGRLayer  *poLayer;
   if((poLayer = m_datasource->GetLayer(layer))==NULL){
-    string errorstring="Could not get layer";
+    std::string errorstring="Could not get layer";
     throw(errorstring);
   }
   OGRFeatureDefn *poFDefn = poLayer->GetLayerDefn();
   return(poFDefn->GetFieldCount());
 }
 
-int ImgReaderOgr::getFields(vector<string>& fields, int layer) const
+int ImgReaderOgr::getFields(std::vector<std::string>& fields, int layer) const
 {
   if(layer<0)
     layer=m_datasource->GetLayerCount()-1;
   assert(m_datasource->GetLayerCount()>layer);
   OGRLayer  *poLayer;
   if((poLayer = m_datasource->GetLayer(layer))==NULL){
-    string errorstring="Could not get layer";
+    std::string errorstring="Could not get layer";
     throw(errorstring);
   }
   OGRFeatureDefn *poFDefn = poLayer->GetLayerDefn();
@@ -114,14 +114,14 @@ int ImgReaderOgr::getFields(vector<string>& fields, int layer) const
   return(fields.size());
 }
 
-int ImgReaderOgr::getFields(vector<OGRFieldDefn*>& fields, int layer) const
+int ImgReaderOgr::getFields(std::vector<OGRFieldDefn*>& fields, int layer) const
 {
   if(layer<0)
     layer=m_datasource->GetLayerCount()-1;
   assert(m_datasource->GetLayerCount()>layer);
   OGRLayer  *poLayer;
   if((poLayer = m_datasource->GetLayer(layer))==NULL){
-    string errorstring="Could not get layer";
+    std::string errorstring="Could not get layer";
     throw(errorstring);
   }
   OGRFeatureDefn *poFDefn = poLayer->GetLayerDefn();
@@ -135,7 +135,7 @@ int ImgReaderOgr::getFields(vector<OGRFieldDefn*>& fields, int layer) const
   return(fields.size());
 }
 
-string ImgReaderOgr::getProjection(int layer) const
+std::string ImgReaderOgr::getProjection(int layer) const
 {
   if(m_datasource->GetLayer(layer)->GetSpatialRef()){
     char* ppszResult;
@@ -151,7 +151,7 @@ OGRwkbGeometryType ImgReaderOgr::getGeometryType(int layer) const
   return m_datasource->GetLayer(layer)->GetLayerDefn()->GetGeomType();
 }
 
-ostream& operator<<(ostream& theOstream, ImgReaderOgr& theImageReader){
+std::ostream& operator<<(std::ostream& theOstream, ImgReaderOgr& theImageReader){
   //An OGRDataSource can potentially have many layers associated with it. The number of layers available can be queried with OGRDataSource::GetLayerCount() and individual layers fetched by index using OGRDataSource::GetLayer(). However, we wil just fetch the layer by name.
   //todo: try to open and catch if failure...
   // ofstream fpoints(filename.c_str(),ios::out);
@@ -166,7 +166,7 @@ ostream& operator<<(ostream& theOstream, ImgReaderOgr& theImageReader){
   // theOstream << "X" << " " << "Y" << " ";
   for(int iField=0;iField<poFDefn->GetFieldCount();++iField){
       OGRFieldDefn *poFieldDefn = poFDefn->GetFieldDefn(iField);
-      string fieldname=poFieldDefn->GetNameRef();
+      std::string fieldname=poFieldDefn->GetNameRef();
       theOstream << fieldname << " ";
   }
   theOstream << std::endl;
@@ -186,9 +186,9 @@ ostream& operator<<(ostream& theOstream, ImgReaderOgr& theImageReader){
       x=poPoint->getX();
       y=poPoint->getY();
     }
-    vector<string> vfields(poFDefn->GetFieldCount());
-    string featurename;
-    vector<string>::iterator fit=vfields.begin();
+    std::vector<std::string> vfields(poFDefn->GetFieldCount());
+    std::string featurename;
+    std::vector<std::string>::iterator fit=vfields.begin();
     for(int iField=0;iField<poFDefn->GetFieldCount();++iField){
       *(fit++)=poFeature->GetFieldAsString(iField);
     }
@@ -203,7 +203,7 @@ ostream& operator<<(ostream& theOstream, ImgReaderOgr& theImageReader){
   return(theOstream);
 }
 
-// OGRLayer * ImgReaderOgr::executeSql(const string& output, const string& sqlStatement, OGRGeometry* spatialFilter)
+// OGRLayer * ImgReaderOgr::executeSql(const std::string& output, const std::string& sqlStatement, OGRGeometry* spatialFilter)
 // {
 //   OGRLayer *poResultSet;
 //   poResultSet = m_datasource->ExecuteSQL(sqlStatement.c_str(), spatialFilter,NULL );
diff --git a/src/imageclasses/ImgReaderOgr.h b/src/imageclasses/ImgReaderOgr.h
index 36a7d0c..ecf06f3 100644
--- a/src/imageclasses/ImgReaderOgr.h
+++ b/src/imageclasses/ImgReaderOgr.h
@@ -31,40 +31,38 @@ along with pktools.  If not, see <http://www.gnu.org/licenses/>.
 #include "base/Vector2d.h"
 #include "ImgReaderGdal.h"
 
-using namespace std;
-
 //--------------------------------------------------------------------------
 class ImgReaderOgr
 {
 public:
   ImgReaderOgr(void);
-  ImgReaderOgr(const string& filename);
+  ImgReaderOgr(const std::string& filename);
   ~ImgReaderOgr(void);
-  void open(const string& filename);
+  void open(const std::string& filename);
   void close(void);
-  //   int readData(Vector2d<double>& data, const OGRFieldType& fieldType, vector<string>& fields, int layer=0, bool pos=false);//default layer 0 and no pos information in data
-  template <typename T> int readXY(vector<T>& xVector, vector<T>& yVector, int layer=0, bool verbose=false);
-  template <typename T> int readY(vector<T>& yVector, int layer=0, bool verbose=false);
-  template <typename T> int readData(vector<T>& data, const OGRFieldType& fieldType, vector<string>& fields, OGRFeature *poFeature, int layer=0, bool pos=false, bool verbose=false);
-  template <typename T> int readData(vector<T>& data, const OGRFieldType& fieldType, const string& theField, int layer=0, bool verbose=false);
-  template <typename T> int readData(Vector2d<T>& data, const OGRFieldType& fieldType, vector<string>& fields, int layer=0, bool pos=false, bool verbose=false);//default layer 0 and no pos information in data
-  template <typename T> int readData(map<int,Vector2d<T> >& data, const OGRFieldType& fieldType, vector<string>& fields, const string& label, int layer=0, bool pos=false, bool verbose=false);//default layer 0 and no pos information in data
-  template <typename T> int readData(map<string,Vector2d<T> >& data, const OGRFieldType& fieldType, vector<string>& fields, const string& label, int layer=0, bool pos=false, bool verbose=false);//default layer 0 and no pos information in data
-  void shape2ascii(ostream& theOstream, const string& pointname, int layer=0, bool verbose=false);
+  //   int readData(Vector2d<double>& data, const OGRFieldType& fieldType, std::vector<std::string>& fields, int layer=0, bool pos=false);//default layer 0 and no pos information in data
+  template <typename T> int readXY(std::vector<T>& xVector, std::vector<T>& yVector, int layer=0, bool verbose=false);
+  template <typename T> int readY(std::vector<T>& yVector, int layer=0, bool verbose=false);
+  template <typename T> int readData(std::vector<T>& data, const OGRFieldType& fieldType, std::vector<std::string>& fields, OGRFeature *poFeature, int layer=0, bool pos=false, bool verbose=false);
+  template <typename T> int readData(std::vector<T>& data, const OGRFieldType& fieldType, const std::string& theField, int layer=0, bool verbose=false);
+  template <typename T> int readData(Vector2d<T>& data, const OGRFieldType& fieldType, std::vector<std::string>& fields, int layer=0, bool pos=false, bool verbose=false);//default layer 0 and no pos information in data
+  template <typename T> int readData(std::map<int,Vector2d<T> >& data, const OGRFieldType& fieldType, std::vector<std::string>& fields, const std::string& label, int layer=0, bool pos=false, bool verbose=false);//default layer 0 and no pos information in data
+  template <typename T> int readData(std::map<std::string,Vector2d<T> >& data, const OGRFieldType& fieldType, std::vector<std::string>& fields, const std::string& label, int layer=0, bool pos=false, bool verbose=false);//default layer 0 and no pos information in data
+  void shape2ascii(ostream& theOstream, const std::string& pointname, int layer=0, bool verbose=false);
   unsigned long int getFeatureCount(int layer=0) const;
   int getFieldCount(int layer=0) const;
   OGRLayer* getLayer(int layer=0){return m_datasource->GetLayer(layer);};
-  string getProjection(int layer=0) const;
+  std::string getProjection(int layer=0) const;
   OGRwkbGeometryType getGeometryType(int layer=0) const;
-  string getLayerName(int layer=0){return m_datasource->GetLayer(layer)->GetLayerDefn()->GetName();};
+  std::string getLayerName(int layer=0){return m_datasource->GetLayer(layer)->GetLayerDefn()->GetName();};
   //  int getLayer(int layer=0) const;
-  int getFields(vector<string>& fields, int layer=0) const;
-  int getFields(vector<OGRFieldDefn*>& fields, int layer=0) const;
+  int getFields(std::vector<std::string>& fields, int layer=0) const;
+  int getFields(std::vector<OGRFieldDefn*>& fields, int layer=0) const;
   OGRDataSource* getDataSource(void) {return m_datasource;};
   OGRSFDriver* getDriver(void) const {return m_datasource->GetDriver();};
-//   OGRLayer *executeSql(const string& output,const string& sqlStatement, OGRGeometry* spatialFilter=NULL);
-  template<typename T> int readSql(Vector2d<T>& data, const OGRFieldType& fieldType, vector<string>& fields, const string& sqlStatement, OGRGeometry* spatialFilter=NULL, int layer=0, bool pos=false, bool verbose=false);
-  template<typename T> int readSql(map<int,Vector2d<T> >& data, const OGRFieldType& fieldType, vector<string>& fields, const string& label, const string& sqlStatement, OGRGeometry* spatialFilter, int layer=0, bool pos=false, bool verbose=false);
+//   OGRLayer *executeSql(const std::string& output,const std::string& sqlStatement, OGRGeometry* spatialFilter=NULL);
+  template<typename T> int readSql(Vector2d<T>& data, const OGRFieldType& fieldType, std::vector<std::string>& fields, const std::string& sqlStatement, OGRGeometry* spatialFilter=NULL, int layer=0, bool pos=false, bool verbose=false);
+  template<typename T> int readSql(std::map<int,Vector2d<T> >& data, const OGRFieldType& fieldType, std::vector<std::string>& fields, const std::string& label, const std::string& sqlStatement, OGRGeometry* spatialFilter, int layer=0, bool pos=false, bool verbose=false);
   bool getExtent(double& ulx, double& uly, double& lrx, double& lry, int layer=0);
 
   friend ostream& operator<<(ostream& theOstream, ImgReaderOgr& theImageReader);
@@ -72,12 +70,12 @@ public:
 protected:
   void setCodec(void);
 
-  string m_filename;
+  std::string m_filename;
   OGRDataSource *m_datasource;
 };
 
 //read data from all features in a map, organized by classes
-template <typename T> int ImgReaderOgr::readData(map<int,Vector2d<T> >& data, const OGRFieldType& fieldType, vector<string>& fields, const string& label, int layer, bool pos, bool verbose)
+template <typename T> int ImgReaderOgr::readData(std::map<int,Vector2d<T> >& data, const OGRFieldType& fieldType, std::vector<std::string>& fields, const std::string& label, int layer, bool pos, bool verbose)
 {
   if(layer<0)
     layer=m_datasource->GetLayerCount()-1;
@@ -104,7 +102,7 @@ template <typename T> int ImgReaderOgr::readData(map<int,Vector2d<T> >& data, co
       cout << "going through features" << endl << flush;
     int theClass=0;
     while( (poFeature = poLayer->GetNextFeature()) != NULL ){
-      vector<T> theFeature;//(fields.size()+posOffset);//x,y+selectedfields
+      std::vector<T> theFeature;//(fields.size()+posOffset);//x,y+selectedfields
       if(verbose)
         cout << "reading feature " << ifeature << endl << flush;
       OGRGeometry *poGeometry;
@@ -140,10 +138,10 @@ template <typename T> int ImgReaderOgr::readData(map<int,Vector2d<T> >& data, co
         }       
       }
       // OGRFeatureDefn *poFDefn = poLayer->GetLayerDefn();
-      string featurename;
+      std::string featurename;
       for(int iField=0;iField<poFDefn->GetFieldCount();++iField){
         OGRFieldDefn *poFieldDefn = poFDefn->GetFieldDefn(iField);
-        string fieldname=poFieldDefn->GetNameRef();
+        std::string fieldname=poFieldDefn->GetNameRef();
         if(fieldname==label)
           theClass=poFeature->GetFieldAsInteger(iField);
         else{
@@ -170,7 +168,7 @@ template <typename T> int ImgReaderOgr::readData(map<int,Vector2d<T> >& data, co
             break;
           default:
             {
-              string errorstring="field type not supported in ImgReaderOgr::ReadData";
+              std::string errorstring="field type not supported in ImgReaderOgr::ReadData";
               throw(errorstring);
             }
             break;
@@ -183,7 +181,7 @@ template <typename T> int ImgReaderOgr::readData(map<int,Vector2d<T> >& data, co
     }
     if(verbose)
       cout << "number of features read: " << ifeature << endl << flush;
-    typename map<int,Vector2d<T> >::const_iterator mit=data.begin();
+    typename std::map<int,Vector2d<T> >::const_iterator mit=data.begin();
     int nband=0;
     if(verbose)
       cout << "read classes: " << flush;
@@ -203,14 +201,14 @@ template <typename T> int ImgReaderOgr::readData(map<int,Vector2d<T> >& data, co
     return(nband);
   }
   else{
-    ostringstream ess;
+    std::ostringstream ess;
     ess << "no layer in " << m_filename;
     throw(ess.str());
   }
 }
 
 //read data from all features in a map, organized by class names
-template <typename T> int ImgReaderOgr::readData(map<string,Vector2d<T> >& data, const OGRFieldType& fieldType, vector<string>& fields, const string& label, int layer, bool pos, bool verbose)
+template <typename T> int ImgReaderOgr::readData(std::map<std::string,Vector2d<T> >& data, const OGRFieldType& fieldType, std::vector<std::string>& fields, const std::string& label, int layer, bool pos, bool verbose)
 {
   if(layer<0)
     layer=m_datasource->GetLayerCount()-1;
@@ -238,9 +236,9 @@ template <typename T> int ImgReaderOgr::readData(map<string,Vector2d<T> >& data,
     int posOffset=(pos)?2:0;
     if(verbose)
       cout << "going through features to fill in string map" << endl << flush;
-    string theClass;
+    std::string theClass;
     while( (poFeature = poLayer->GetNextFeature()) != NULL ){
-      vector<T> theFeature;//(fields.size()+posOffset);//x,y+selectedfields
+      std::vector<T> theFeature;//(fields.size()+posOffset);//x,y+selectedfields
       if(verbose)
         cout << "reading feature " << ifeature << endl << flush;
       OGRGeometry *poGeometry;
@@ -275,10 +273,10 @@ template <typename T> int ImgReaderOgr::readData(map<string,Vector2d<T> >& data,
         }       
       }
       // OGRFeatureDefn *poFDefn = poLayer->GetLayerDefn();//got LayerDefn already...
-      string featurename;
+      std::string featurename;
       for(int iField=0;iField<poFDefn->GetFieldCount();++iField){
         OGRFieldDefn *poFieldDefn = poFDefn->GetFieldDefn(iField);
-        string fieldname=poFieldDefn->GetNameRef();
+        std::string fieldname=poFieldDefn->GetNameRef();
         if(fieldname==label){
           theClass=poFeature->GetFieldAsString(iField);
           if(verbose)
@@ -308,7 +306,7 @@ template <typename T> int ImgReaderOgr::readData(map<string,Vector2d<T> >& data,
             break;
           default:
             {
-              string errorstring="field type not supported in ImgReaderOgr::ReadData";
+              std::string errorstring="field type not supported in ImgReaderOgr::ReadData";
               throw(errorstring);
             }
             break;
@@ -321,7 +319,7 @@ template <typename T> int ImgReaderOgr::readData(map<string,Vector2d<T> >& data,
     }
     if(verbose)
       cout << "number of features read: " << ifeature << endl << flush;
-    typename map<string,Vector2d<T> >::const_iterator mit=data.begin();
+    typename std::map<std::string,Vector2d<T> >::const_iterator mit=data.begin();
     int nband=0;
     if(verbose)
       cout << "read classes: " << flush;
@@ -341,14 +339,14 @@ template <typename T> int ImgReaderOgr::readData(map<string,Vector2d<T> >& data,
     return(nband);
   }
   else{
-    ostringstream ess;
+    std::ostringstream ess;
     ess << "no layer in " << m_filename;
     throw(ess.str());
   }
 }
 
 //read x positions
-template <typename T> int ImgReaderOgr::readXY(vector<T>& xVector, vector<T>& yVector, int layer, bool verbose){
+template <typename T> int ImgReaderOgr::readXY(std::vector<T>& xVector, std::vector<T>& yVector, int layer, bool verbose){
   if(layer<0)
     layer=m_datasource->GetLayerCount()-1;
   assert(m_datasource->GetLayerCount()>layer);
@@ -388,14 +386,14 @@ template <typename T> int ImgReaderOgr::readXY(vector<T>& xVector, vector<T>& yV
     return xVector.size();
   }
   else{
-    ostringstream ess;
+    std::ostringstream ess;
     ess << "no layer in " << m_filename;
     throw(ess.str());
   }
 }
 
 //read data from a single feature
-template <typename T> int ImgReaderOgr::readData(vector<T>& data, const OGRFieldType& fieldType, vector<string>& fields, OGRFeature *poFeature, int layer, bool pos, bool verbose)
+template <typename T> int ImgReaderOgr::readData(std::vector<T>& data, const OGRFieldType& fieldType, std::vector<std::string>& fields, OGRFeature *poFeature, int layer, bool pos, bool verbose)
 {
   if(layer<0)
     layer=m_datasource->GetLayerCount()-1;
@@ -443,10 +441,10 @@ template <typename T> int ImgReaderOgr::readData(vector<T>& data, const OGRField
     }       
 
   }
-  string featurename;
+  std::string featurename;
   for(int iField=0;iField<poFDefn->GetFieldCount();++iField){
     OGRFieldDefn *poFieldDefn = poFDefn->GetFieldDefn(iField);
-    string fieldname=poFieldDefn->GetNameRef();
+    std::string fieldname=poFieldDefn->GetNameRef();
     switch(fieldType){
     case(OFTReal):
       if(fields.size()<poFDefn->GetFieldCount()){
@@ -470,7 +468,7 @@ template <typename T> int ImgReaderOgr::readData(vector<T>& data, const OGRField
       break;
     default:
       {
-        string errorstring="field type not supported in ImgReaderOgr::ReadData";
+        std::string errorstring="field type not supported in ImgReaderOgr::ReadData";
         throw(errorstring);
       }
       break;
@@ -485,14 +483,14 @@ template <typename T> int ImgReaderOgr::readData(vector<T>& data, const OGRField
     return fields.size();
   }
   else{
-    ostringstream ess;
+    std::ostringstream ess;
     ess << "no layer in " << m_filename;
     throw(ess.str());
   }
 }
 
 //read one field from all features
-template <typename T> int ImgReaderOgr::readData(vector<T>& data, const OGRFieldType& fieldType, const string& theField, int layer, bool verbose)
+template <typename T> int ImgReaderOgr::readData(std::vector<T>& data, const OGRFieldType& fieldType, const std::string& theField, int layer, bool verbose)
 {
   if(layer<0)
     layer=m_datasource->GetLayerCount()-1;
@@ -518,7 +516,7 @@ template <typename T> int ImgReaderOgr::readData(vector<T>& data, const OGRField
   if(verbose)
     cout << "going through features" << endl << flush;
   while( (poFeature = poLayer->GetNextFeature()) != NULL ){
-    // vector<T> theFeature;//(fields.size()+posOffset);//x,y+selectedfields
+    // std::vector<T> theFeature;//(fields.size()+posOffset);//x,y+selectedfields
     T theFeature;
     if(verbose)
       cout << "reading feature " << ifeature << endl << flush;
@@ -536,7 +534,7 @@ template <typename T> int ImgReaderOgr::readData(vector<T>& data, const OGRField
 
     for(int iField=0;iField<nfield;++iField){
       OGRFieldDefn *poFieldDefn = poFDefn->GetFieldDefn(iField);
-      string fieldname=poFieldDefn->GetNameRef();
+      std::string fieldname=poFieldDefn->GetNameRef();
       if(fieldname!=theField)
         continue;
       switch(fieldType){
@@ -546,7 +544,7 @@ template <typename T> int ImgReaderOgr::readData(vector<T>& data, const OGRField
       break;
       default:
         {
-          string errorstring="field type not supported in ImgReaderOgr::ReadData";
+          std::string errorstring="field type not supported in ImgReaderOgr::ReadData";
           throw(errorstring);
         }
         break;
@@ -561,14 +559,14 @@ template <typename T> int ImgReaderOgr::readData(vector<T>& data, const OGRField
     return data.size();
   }
   else{
-    ostringstream ess;
+    std::ostringstream ess;
     ess << "no layer in " << m_filename;
     throw(ess.str());
   }
 }
 
 //read data from all features  
-template <typename T> int ImgReaderOgr::readData(Vector2d<T>& data, const OGRFieldType& fieldType, vector<string>& fields, int layer, bool pos, bool verbose)
+template <typename T> int ImgReaderOgr::readData(Vector2d<T>& data, const OGRFieldType& fieldType, std::vector<std::string>& fields, int layer, bool pos, bool verbose)
 {
   if(layer<0)
     layer=m_datasource->GetLayerCount()-1;
@@ -593,7 +591,7 @@ template <typename T> int ImgReaderOgr::readData(Vector2d<T>& data, const OGRFie
   if(verbose)
     cout << "going through features" << endl << flush;
   while( (poFeature = poLayer->GetNextFeature()) != NULL ){
-    vector<T> theFeature;//(fields.size()+posOffset);//x,y+selectedfields
+    std::vector<T> theFeature;//(fields.size()+posOffset);//x,y+selectedfields
     if(verbose)
       cout << "reading feature " << ifeature << endl << flush;
     OGRGeometry *poGeometry;
@@ -612,10 +610,10 @@ template <typename T> int ImgReaderOgr::readData(Vector2d<T>& data, const OGRFie
       theFeature.push_back(poPoint->getY());
     }
     OGRFeatureDefn *poFDefn = poLayer->GetLayerDefn();
-    string featurename;
+    std::string featurename;
     for(int iField=0;iField<poFDefn->GetFieldCount();++iField){
       OGRFieldDefn *poFieldDefn = poFDefn->GetFieldDefn(iField);
-      string fieldname=poFieldDefn->GetNameRef();
+      std::string fieldname=poFieldDefn->GetNameRef();
       switch(fieldType){
       case(OFTReal):
         if(fields.size()<poFDefn->GetFieldCount()){
@@ -639,7 +637,7 @@ template <typename T> int ImgReaderOgr::readData(Vector2d<T>& data, const OGRFie
         break;
       default:
         {
-          string errorstring="field type not supported in ImgReaderOgr::ReadData";
+          std::string errorstring="field type not supported in ImgReaderOgr::ReadData";
           throw(errorstring);
         }
         break;
@@ -657,13 +655,13 @@ template <typename T> int ImgReaderOgr::readData(Vector2d<T>& data, const OGRFie
     return fields.size();
   }
   else{
-    ostringstream ess;
+    std::ostringstream ess;
     ess << "no layer in " << m_filename;
     throw(ess.str());
   }
 }
 
-template<typename T> int ImgReaderOgr::readSql(map<int, Vector2d<T> >& data, const OGRFieldType& fieldType, vector<string>& fields, const string& label, const string& sqlStatement, OGRGeometry* spatialFilter, int layer, bool pos, bool verbose)
+template<typename T> int ImgReaderOgr::readSql(std::map<int, Vector2d<T> >& data, const OGRFieldType& fieldType, std::vector<std::string>& fields, const std::string& label, const std::string& sqlStatement, OGRGeometry* spatialFilter, int layer, bool pos, bool verbose)
 {
   if(layer<0)
     layer=m_datasource->GetLayerCount()-1;
@@ -688,7 +686,7 @@ template<typename T> int ImgReaderOgr::readSql(map<int, Vector2d<T> >& data, con
       cout << "going through features" << endl << flush;
     int theClass=0;
     while( (poFeature = poLayer->GetNextFeature()) != NULL ){
-      vector<T> theFeature;//(fields.size()+posOffset);//x,y+selectedfields
+      std::vector<T> theFeature;//(fields.size()+posOffset);//x,y+selectedfields
       if(verbose)
         cout << "reading feature " << ifeature << endl << flush;
       OGRGeometry *poGeometry;
@@ -707,10 +705,10 @@ template<typename T> int ImgReaderOgr::readSql(map<int, Vector2d<T> >& data, con
         theFeature.push_back(poPoint->getY());
       }
       OGRFeatureDefn *poFDefn = poLayer->GetLayerDefn();
-      string featurename;
+      std::string featurename;
       for(int iField=0;iField<poFDefn->GetFieldCount();++iField){
         OGRFieldDefn *poFieldDefn = poFDefn->GetFieldDefn(iField);
-        string fieldname=poFieldDefn->GetNameRef();
+        std::string fieldname=poFieldDefn->GetNameRef();
         if(fieldname==label)
           theClass=poFeature->GetFieldAsInteger(iField);
         else{
@@ -737,7 +735,7 @@ template<typename T> int ImgReaderOgr::readSql(map<int, Vector2d<T> >& data, con
             break;
           default:
             {
-              string errorstring="field type not supported in ImgReaderOgr::ReadData";
+              std::string errorstring="field type not supported in ImgReaderOgr::ReadData";
               throw(errorstring);
             }
             break;
@@ -749,7 +747,7 @@ template<typename T> int ImgReaderOgr::readSql(map<int, Vector2d<T> >& data, con
     }
     if(verbose)
       cout << "number of features read: " << ifeature << endl << flush;
-    typename map<int,Vector2d<T> >::const_iterator mit=data.begin();
+    typename std::map<int,Vector2d<T> >::const_iterator mit=data.begin();
     int nband=0;
     if(verbose)
       cout << "read classes: " << flush;
@@ -769,13 +767,13 @@ template<typename T> int ImgReaderOgr::readSql(map<int, Vector2d<T> >& data, con
     return(nband);
   }
   else{
-    ostringstream ess;
+    std::ostringstream ess;
     ess << "no layer in " << m_filename;
     throw(ess.str());
   }
 }
 
-template<typename T> int ImgReaderOgr::readSql(Vector2d<T>& data, const OGRFieldType& fieldType, vector<string>& fields, const string& sqlStatement, OGRGeometry* spatialFilter, int layer, bool pos, bool verbose)
+template<typename T> int ImgReaderOgr::readSql(Vector2d<T>& data, const OGRFieldType& fieldType, std::vector<std::string>& fields, const std::string& sqlStatement, OGRGeometry* spatialFilter, int layer, bool pos, bool verbose)
 {
   if(layer<0)
     layer=m_datasource->GetLayerCount()-1;
@@ -799,7 +797,7 @@ template<typename T> int ImgReaderOgr::readSql(Vector2d<T>& data, const OGRField
     if(verbose)
       cout << "going through features" << endl << flush;
     while( (poFeature = poLayer->GetNextFeature()) != NULL ){
-      vector<T> theFeature;//(fields.size()+posOffset);//x,y+selectedfields
+      std::vector<T> theFeature;//(fields.size()+posOffset);//x,y+selectedfields
       if(verbose)
         cout << "reading feature " << ifeature << endl << flush;
       OGRGeometry *poGeometry;
@@ -818,10 +816,10 @@ template<typename T> int ImgReaderOgr::readSql(Vector2d<T>& data, const OGRField
         theFeature.push_back(poPoint->getY());
       }
       OGRFeatureDefn *poFDefn = poLayer->GetLayerDefn();
-      string featurename;
+      std::string featurename;
       for(int iField=0;iField<poFDefn->GetFieldCount();++iField){
         OGRFieldDefn *poFieldDefn = poFDefn->GetFieldDefn(iField);
-        string fieldname=poFieldDefn->GetNameRef();
+        std::string fieldname=poFieldDefn->GetNameRef();
         switch(fieldType){
         case(OFTReal):
           if(fields.size()<poFDefn->GetFieldCount()){
@@ -845,7 +843,7 @@ template<typename T> int ImgReaderOgr::readSql(Vector2d<T>& data, const OGRField
           break;
         default:
           {
-            string errorstring="field type not supported in ImgReaderOgr::ReadData";
+            std::string errorstring="field type not supported in ImgReaderOgr::ReadData";
             throw(errorstring);
           }
           break;
@@ -867,7 +865,7 @@ template<typename T> int ImgReaderOgr::readSql(Vector2d<T>& data, const OGRField
       return(0);
   }
   else{
-    ostringstream ess;
+    std::ostringstream ess;
     ess << "no layer in " << m_filename;
     throw(ess.str());
   }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/pktools.git



More information about the Pkg-grass-devel mailing list