[pktools] 272/375: new method countid for Giuseppe in pkfilter.cc and Filter2d

Bas Couwenberg sebastic at xs4all.nl
Wed Dec 3 21:54:21 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 f32012f5e9214a8ccfb97d9bd7753c51f076e593
Author: Pieter Kempeneers <kempenep at gmail.com>
Date:   Sat May 17 00:06:25 2014 +0200

    new method countid for Giuseppe in pkfilter.cc and Filter2d
---
 src/algorithms/Filter2d.cc |  7 +++++++
 src/algorithms/Filter2d.h  |  2 +-
 src/apps/pkdiff.cc         | 13 ++++++++-----
 src/apps/pkextract.cc      |  2 +-
 src/apps/pkfilter.cc       |  2 +-
 src/apps/pksvm.cc          |  2 +-
 6 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/src/algorithms/Filter2d.cc b/src/algorithms/Filter2d.cc
index 8cf0db0..e2e95eb 100644
--- a/src/algorithms/Filter2d.cc
+++ b/src/algorithms/Filter2d.cc
@@ -574,6 +574,13 @@ void filter2d::Filter2d::doit(const ImgReaderGdal& input, ImgWriterGdal& output,
 	    outBuffer[x/down]=(m_noDataValues.size())? m_noDataValues[0] : 0;
           break;
 	}
+        case(filter2d::countid):{
+	  if(windowBuffer.size())
+	    outBuffer[x/down]+=occurrence.size();
+	  else
+	    outBuffer[x/down]=(m_noDataValues.size())? m_noDataValues[0] : 0;
+          break;
+	}
         case(filter2d::majority):{
 	  if(occurrence.size()){
             std::map<int,int>::const_iterator maxit=occurrence.begin();
diff --git a/src/algorithms/Filter2d.h b/src/algorithms/Filter2d.h
index c623b07..30ef9da 100644
--- a/src/algorithms/Filter2d.h
+++ b/src/algorithms/Filter2d.h
@@ -58,7 +58,7 @@ extern "C" {
 
 namespace filter2d
 {
-  enum FILTER_TYPE { median=100, var=101 , min=102, max=103, sum=104, mean=105, minmax=106, dilate=107, erode=108, close=109, open=110, homog=111, sobelx=112, sobely=113, sobelxy=114, sobelyx=115, smooth=116, density=117, majority=118, mixed=119, threshold=120, ismin=121, ismax=122, heterog=123, order=124, stdev=125, mrf=126, dwt=127, dwti=128, dwt_cut=129, scramble=130, shift=131, linearfeature=132, smoothnodata=133};
+  enum FILTER_TYPE { median=100, var=101 , min=102, max=103, sum=104, mean=105, minmax=106, dilate=107, erode=108, close=109, open=110, homog=111, sobelx=112, sobely=113, sobelxy=114, sobelyx=115, smooth=116, density=117, majority=118, mixed=119, threshold=120, ismin=121, ismax=122, heterog=123, order=124, stdev=125, mrf=126, dwt=127, dwti=128, dwt_cut=129, scramble=130, shift=131, linearfeature=132, smoothnodata=133, countid=134};
 
   enum RESAMPLE { NEAR = 0, BILINEAR = 1, BICUBIC = 2 };//bicubic not supported yet...
   
diff --git a/src/apps/pkdiff.cc b/src/apps/pkdiff.cc
index 411c1c4..84ff21c 100644
--- a/src/apps/pkdiff.cc
+++ b/src/apps/pkdiff.cc
@@ -43,8 +43,8 @@ int main(int argc, char *argv[])
   Optionpk<short> nodata_opt("nodata", "nodata", "No data value(s) in input or reference dataset are ignored");
   Optionpk<short> band_opt("b", "band", "Input band", 0);
   Optionpk<bool> confusion_opt("cm", "confusion", "create confusion matrix (to std out)", false);
-  Optionpk<string> labelref_opt("lr", "lref", "name of the reference label in case reference is OGR vector file", "label");
-  Optionpk<string> labelclass_opt("lc", "lclass", "name of the classified label in case output is OGR vector file", "class");
+  Optionpk<string> labelref_opt("lr", "lref", "attribute name of the reference label in case reference is OGR vector file", "label");
+  Optionpk<string> labelclass_opt("lc", "lclass", "attribute name of the classified label in case output is OGR vector file", "class");
   Optionpk<short> boundary_opt("bnd", "boundary", "boundary for selecting the sample", 1,1);
   Optionpk<bool> disc_opt("circ", "circular", "use circular disc kernel boundary)", false,1);
   Optionpk<bool> homogeneous_opt("hom", "homogeneous", "only take homogeneous regions into account", false,1);
@@ -69,11 +69,11 @@ int main(int argc, char *argv[])
     ogrformat_opt.retrieveOption(argc,argv);
     labelclass_opt.retrieveOption(argc,argv);
     colorTable_opt.retrieveOption(argc,argv);
-    option_opt.retrieveOption(argc,argv);
     valueE_opt.retrieveOption(argc,argv);
     valueO_opt.retrieveOption(argc,argv);
     valueC_opt.retrieveOption(argc,argv);
     band_opt.retrieveOption(argc,argv);
+    option_opt.retrieveOption(argc,argv);
     // class_opt.retrieveOption(argc,argv);
     boundary_opt.retrieveOption(argc,argv);
     disc_opt.retrieveOption(argc,argv);
@@ -208,7 +208,8 @@ int main(int argc, char *argv[])
   // if(reference_opt[0].find(".shp")!=string::npos){
   if(!refIsRaster){
     for(int iinput=0;iinput<input_opt.size();++iinput){
-      cout << "Processing input " << input_opt[iinput] << endl;
+      if(verbose_opt[0])
+	cout << "Processing input " << input_opt[iinput] << endl;
       if(output_opt.size())
         assert(reference_opt.size()==output_opt.size());
       for(int iref=0;iref<reference_opt.size();++iref){
@@ -249,9 +250,11 @@ int main(int argc, char *argv[])
 	  if(layer_opt.size())
 	    if(find(layer_opt.begin(),layer_opt.end(),currentLayername)==layer_opt.end())
 	      continue;
-	  cout << "processing layer " << readLayer->GetName() << endl;
 	  if(!verbose_opt[0])
 	    pfnProgress(progress,pszMessage,pProgressArg);
+	  else
+	    cout << "processing layer " << readLayer->GetName() << endl;
+
 	  readLayer->ResetReading();
 	  OGRLayer *writeLayer;
 	  if(output_opt.size()){
diff --git a/src/apps/pkextract.cc b/src/apps/pkextract.cc
index ec234ee..81f4be8 100644
--- a/src/apps/pkextract.cc
+++ b/src/apps/pkextract.cc
@@ -61,7 +61,7 @@ int main(int argc, char *argv[])
   // Optionpk<string> bufferOutput_opt("bu", "bu", "Buffer output shape file");
   Optionpk<float> polythreshold_opt("tp", "thresholdPolygon", "(absolute) threshold for selecting samples in each polygon");
   Optionpk<string> test_opt("test", "test", "Test sample file (use this option in combination with threshold<100 to create a training (output) and test set");
-  Optionpk<string> fieldname_opt("bn", "bname", "For single band input data, this extra attribute name will correspond to the raster values. For multi-band input data, multiple attributes with this prefix will be added (e.g. B0, B1, B2, etc.)", "B");
+  Optionpk<string> fieldname_opt("bn", "bname", "For single band input data, this extra attribute name will correspond to the raster values. For multi-band input data, multiple attributes with this prefix will be added (e.g. b0, b1, b2, etc.)", "b");
   Optionpk<string> label_opt("cn", "cname", "name of the class label in the output vector file", "label");
   Optionpk<short> geo_opt("g", "geo", "use geo coordinates (set to 0 to use image coordinates)", 1);
   Optionpk<short> down_opt("down", "down", "down sampling factor (for raster sample datasets only). Can be used to create grid points", 1);
diff --git a/src/apps/pkfilter.cc b/src/apps/pkfilter.cc
index 27d38bc..8d0a63f 100644
--- a/src/apps/pkfilter.cc
+++ b/src/apps/pkfilter.cc
@@ -42,7 +42,7 @@ int main(int argc,char **argv) {
   Optionpk<std::string> tmpdir_opt("tmp", "tmp", "Temporary directory","/tmp",2);
   Optionpk<bool> disc_opt("circ", "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, dilate, erode, close, open, homog (central pixel must be identical to all other pixels within window), heterog, sobelx (horizontal edge detection), sobely (vertical edge detection), sobelxy (diagonal edge detection NE-SW),sobelyx (diagonal edge detection NW-SE), smooth, density, majority voting (only for classes), smoothnodata (smooth nodata values only) values, threshold local filtering [...]
+  Optionpk<std::string> method_opt("f", "filter", "filter function (median, var, min, max, sum, mean, dilate, erode, close, open, homog (central pixel must be identical to all other pixels within window), heterog, sobelx (horizontal edge detection), sobely (vertical edge detection), sobelxy (diagonal edge detection NE-SW),sobelyx (diagonal edge detection NW-SE), smooth, density, countid, majority voting (only for classes), smoothnodata (smooth nodata values only) values, threshold local  [...]
   Optionpk<std::string> resample_opt("r", "resampling-method", "Resampling method for shifting operation (near: nearest neighbour, bilinear: bi-linear interpolation).", "near");
   Optionpk<double> dimX_opt("dx", "dx", "filter kernel size in x, better use odd value to avoid image shift", 3);
   Optionpk<double> dimY_opt("dy", "dy", "filter kernel size in y, better use odd value to avoid image shift", 3);
diff --git a/src/apps/pksvm.cc b/src/apps/pksvm.cc
index 4ca05b9..fa0918a 100644
--- a/src/apps/pksvm.cc
+++ b/src/apps/pksvm.cc
@@ -51,7 +51,7 @@ int main(int argc, char *argv[])
   Optionpk<string> input_opt("i", "input", "input image"); 
   Optionpk<string> training_opt("t", "training", "training vector file. A single vector file contains all training features (must be set as: b0, b1, b2,...) for all classes (class numbers identified by label option). Use multiple training files for bootstrap aggregation (alternative to the bag and bsize options, where a random subset is taken from a single training file)");
   Optionpk<string> tlayer_opt("tln", "tln", "training layer name(s)");
-  Optionpk<string> label_opt("label", "label", "identifier for class label in training vector file.","label"); 
+  Optionpk<string> label_opt("label", "label", "attribute name for class label in training vector file.","label"); 
   Optionpk<unsigned int> balance_opt("bal", "balance", "balance the input data to this number of samples for each class", 0);
   Optionpk<bool> random_opt("random", "random", "randomize training data for balancing and bagging", true, 2);
   Optionpk<int> minSize_opt("min", "min", "if number of training pixels is less then min, do not take this class into account (0: consider all classes)", 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