[pktools] 07/375: support spectral filtering in pkfilter using tapz option

Bas Couwenberg sebastic at xs4all.nl
Wed Dec 3 21:53:53 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 3cc2c2b2893f0f6c02a9b4a4174b024fcce3729f
Author: Pieter Kempeneers <kempenep at gmail.com>
Date:   Thu Sep 13 11:00:02 2012 +0200

    support spectral filtering in pkfilter using tapz option
---
 INSTALL                  |  4 ++--
 README                   |  1 +
 configure                | 20 ++++++++++----------
 configure.ac             |  2 +-
 src/algorithms/Filter.cc | 40 +++++++++++++++++++++++++++++++++-------
 src/algorithms/Filter.h  |  1 +
 src/apps/pkfilter.cc     |  8 +++++++-
 7 files changed, 55 insertions(+), 21 deletions(-)

diff --git a/INSTALL b/INSTALL
index 58d150a..db6c84a 100644
--- a/INSTALL
+++ b/INSTALL
@@ -12,8 +12,8 @@ The simplest way to compile this package is:
      configure options (use ./configure --help for help info)
      
         --with-gdal=<path to gdal-config file>
-     	--with-fann=yes (to include pkclassify_nn when FANN is installed)
-	--with-las=yes (to include pklas2img when LIBLAS is installed)
+     	--enable-fann (to include pkclassify_nn when FANN is installed)
+	--enable-las (to include pklas2img when LIBLAS >= 1.6 is installed)
 
   2. Type `make' to compile the package.
 
diff --git a/README b/README
index 4030205..f42dc4f 100644
--- a/README
+++ b/README
@@ -15,3 +15,4 @@ To install the programs in pktools, refer to the file INSTALL
 Change history
 -------------
 June 25 2012, first public release of the code
+September 04 2012, introduced --enable-fann and --enable-las in configuration
diff --git a/configure b/configure
index 75879c2..8d67c8c 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.67 for pktools 2.1.
+# Generated by GNU Autoconf 2.67 for pktools 2.2.
 #
 # Report bugs to <kempenep at gmail.com>.
 #
@@ -552,8 +552,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='pktools'
 PACKAGE_TARNAME='pktools'
-PACKAGE_VERSION='2.1'
-PACKAGE_STRING='pktools 2.1'
+PACKAGE_VERSION='2.2'
+PACKAGE_STRING='pktools 2.2'
 PACKAGE_BUGREPORT='kempenep at gmail.com'
 PACKAGE_URL=''
 
@@ -1278,7 +1278,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures pktools 2.1 to adapt to many kinds of systems.
+\`configure' configures pktools 2.2 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1344,7 +1344,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of pktools 2.1:";;
+     short | recursive ) echo "Configuration of pktools 2.2:";;
    esac
   cat <<\_ACEOF
 
@@ -1450,7 +1450,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-pktools configure 2.1
+pktools configure 2.2
 generated by GNU Autoconf 2.67
 
 Copyright (C) 2010 Free Software Foundation, Inc.
@@ -1968,7 +1968,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by pktools $as_me 2.1, which was
+It was created by pktools $as_me 2.2, which was
 generated by GNU Autoconf 2.67.  Invocation command line was
 
   $ $0 $@
@@ -2783,7 +2783,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='pktools'
- VERSION='2.1'
+ VERSION='2.2'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -6278,7 +6278,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by pktools $as_me 2.1, which was
+This file was extended by pktools $as_me 2.2, which was
 generated by GNU Autoconf 2.67.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -6344,7 +6344,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-pktools config.status 2.1
+pktools config.status 2.2
 configured by $0, generated by GNU Autoconf 2.67,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
index f44206e..526576c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([pktools], [2.1], [kempenep at gmail.com])
+AC_INIT([pktools], [2.2], [kempenep at gmail.com])
 AM_INIT_AUTOMAKE([-Wall -Werror foreign])
 AC_CONFIG_MACRO_DIR([m4])
 AX_LIB_GDAL()
diff --git a/src/algorithms/Filter.cc b/src/algorithms/Filter.cc
index 46b8814..067ca12 100644
--- a/src/algorithms/Filter.cc
+++ b/src/algorithms/Filter.cc
@@ -54,14 +54,40 @@ void Filter::morphology(const ImgReaderGdal& input, ImgWriterGdal& output, int m
     vector<double> pixelOutput(input.nrOfBand());
     for(int x=0;x<input.nrOfCol();++x){
       pixelInput=lineInput.selectCol(x);
-      //test
-      if(y==168&&x==204){
-        cout << "m_class.size(): " << m_class.size() << endl;
-        cout << "y=" << y << ", x= " << x << endl;
-        morphology(pixelInput,pixelOutput,method,dim,down,offset,true);
+      morphology(pixelInput,pixelOutput,method,dim,down,offset);
+      for(int iband=0;iband<input.nrOfBand();++iband)
+        lineOutput[iband][x]=pixelOutput[iband];
+    }
+    for(int iband=0;iband<input.nrOfBand();++iband){
+      try{
+        output.writeData(lineOutput[iband],GDT_Float64,y,iband);
       }
-      else
-        morphology(pixelInput,pixelOutput,method,dim,down,offset);
+      catch(string errorstring){
+        cerr << errorstring << "in band " << iband << ", line " << y << endl;
+      }
+    }
+    progress=(1.0+y)/output.nrOfRow();
+    pfnProgress(progress,pszMessage,pProgressArg);
+  }
+}
+
+void Filter::doit(const ImgReaderGdal& input, ImgWriterGdal& output, short down, int offset)
+{
+  Vector2d<double> lineInput(input.nrOfBand(),input.nrOfCol());
+  Vector2d<double> lineOutput(input.nrOfBand(),input.nrOfCol());
+  const char* pszMessage;
+  void* pProgressArg=NULL;
+  GDALProgressFunc pfnProgress=GDALTermProgress;
+  double progress=0;
+  pfnProgress(progress,pszMessage,pProgressArg);
+  for(int y=0;y<input.nrOfRow();++y){
+    for(int iband=0;iband<input.nrOfBand();++iband)
+      input.readData(lineInput[iband],GDT_Float64,y,iband);
+    vector<double> pixelInput(input.nrOfBand());
+    vector<double> pixelOutput(input.nrOfBand());
+    for(int x=0;x<input.nrOfCol();++x){
+      pixelInput=lineInput.selectCol(x);
+      doit(pixelInput,pixelOutput,down,offset);
       for(int iband=0;iband<input.nrOfBand();++iband)
         lineOutput[iband][x]=pixelOutput[iband];
     }
diff --git a/src/algorithms/Filter.h b/src/algorithms/Filter.h
index 15c5ffa..ed7ae58 100644
--- a/src/algorithms/Filter.h
+++ b/src/algorithms/Filter.h
@@ -44,6 +44,7 @@ public:
   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, int method, int dim, short down=1, int offset=0, bool verbose=0);
   void morphology(const ImgReaderGdal& input, ImgWriterGdal& output, int method, int dim, short down=1, int offset=0);
+  void doit(const ImgReaderGdal& input, ImgWriterGdal& output, short down=1, int offset=0);
 
 private:
   vector<double> m_taps;
diff --git a/src/apps/pkfilter.cc b/src/apps/pkfilter.cc
index b78ac57..34018d5 100644
--- a/src/apps/pkfilter.cc
+++ b/src/apps/pkfilter.cc
@@ -61,7 +61,8 @@ int main(int argc,char **argv) {
   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)", 0);
   Optionpk<short> mask_opt("\0", "mask", "mask value(s) ");
-  Optionpk<std::string> tap_opt("tap", "tap", "text file conttaining taps used for filtering (from ul to lr). Use dimX and dimY to specify tap dimensions in x and y. Leave empty for not using taps", "");
+  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");
   Optionpk<std::string> colorTable_opt("\0", "ct", "color table (file with 5 columns: id R G B ALFA (0: transparent, 255: solid)", "");
   Optionpk<short> down_opt("d", "down", "down sampling factor. Use value 1 for no downsampling)", 1);
   Optionpk<short> verbose_opt("v", "verbose", "verbose mode if > 0", 0);
@@ -82,6 +83,7 @@ int main(int argc,char **argv) {
   threshold_opt.retrieveOption(argc,argv);
   mask_opt.retrieveOption(argc,argv);
   tap_opt.retrieveOption(argc,argv);
+  tapz_opt.retrieveOption(argc,argv);
   down_opt.retrieveOption(argc,argv);
   colorTable_opt.retrieveOption(argc,argv);
   verbose_opt.retrieveOption(argc,argv);
@@ -165,6 +167,10 @@ int main(int argc,char **argv) {
     filter2d.filter(input,output);
     tapfile.close();
   }
+  else if(tapz_opt.size()){
+    filter1d.setTaps(tapz_opt);    
+    filter1d.doit(input,output,down_opt[0]);
+  }
   else{
     if(colorTable_opt[0]!="")
       output.setColorTable(colorTable_opt[0]);

-- 
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