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 e6880149d7a9001a440ed6af22df6b56fe66c614
Author: Pieter Kempeneers <kempe...@gmail.com>
Date:   Fri Oct 24 13:00:35 2014 +0200

    worked on pkkalman
---
 ChangeLog                  |  6 ++++--
 src/algorithms/Filter.h    |  4 ++--
 src/algorithms/Filter2d.cc |  2 +-
 src/algorithms/Filter2d.h  |  6 +++---
 src/apps/pkextract.cc      | 16 ++++++++--------
 src/apps/pkfilter.cc       |  8 ++++++--
 src/apps/pkkalman.cc       | 17 +++++++++++------
 7 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index dc0f1f6..0e626a5 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -301,7 +301,7 @@ version 2.5.2
 version 2.5.3
  - pklas2img
        libLAS 1.8.0 support (ticket #42951)
- - myfann_cpp.h 
+ - myfann_cpp.h
        Fix build failure on ARM due to va_list usage in myfann_cpp.h
 
 
@@ -311,6 +311,7 @@ version 2.5.4
  - pkfilter
        Support filtering and statistics in spectral domain (see ticket #43252)
        Support different padding strategies (currently only supported for 
spectral/temporal filtering)
+       Renamed "majority" to "mode" for majority voting filter
  - pkextract
        bug fix for proportion rule
        support standard deviation rule (stdev) for polygon features (ticket 
#43193)
@@ -330,7 +331,8 @@ version 2.5.4
        replaced options s|start and e|end with bs|bstart and be|bend
  - ImgWriteOgr
        overwrite existing ogr datasets per default
-Next versions: 
+
+Todo:
  - todo for API
        ImgReaderGdal (ImgWriterGdal) open in update mode (check gdal_edit.py: 
http://searchcode.com/codesearch/view/18938404)
        Img[Reader|Writer]Ogr replace OGRDataSource with GDALDataset conform to 
GDAL API 2.x
diff --git a/src/algorithms/Filter.h b/src/algorithms/Filter.h
index 9b12410..705bfc6 100644
--- a/src/algorithms/Filter.h
+++ b/src/algorithms/Filter.h
@@ -33,7 +33,7 @@ extern "C" {
 namespace filter
 {
   
-  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, dwt=26, dwti=27, dwt_cut=28, dwt_cut_from=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, mode=17, mixed=18, 
smoothnodata=19, threshold=20, ismin=21, ismax=22, heterog=23, order=24, 
stdev=25, dwt=26, dwti=27, dwt_cut=28, dwt_cut_from=29};
 
    enum PADDING { symmetric=0, replicate=1, circular=2, constant=3};
 
@@ -116,7 +116,7 @@ private:
     m_filterMap["sobelyx"]=filter::sobelyx;
     m_filterMap["smooth"]=filter::smooth;
     m_filterMap["density"]=filter::density;
-    m_filterMap["majority"]=filter::majority;
+    m_filterMap["mode"]=filter::mode;
     m_filterMap["mixed"]=filter::mixed;
     m_filterMap["smoothnodata"]=filter::smoothnodata;
     m_filterMap["threshold"]=filter::threshold;
diff --git a/src/algorithms/Filter2d.cc b/src/algorithms/Filter2d.cc
index 0fc643a..2d02182 100644
--- a/src/algorithms/Filter2d.cc
+++ b/src/algorithms/Filter2d.cc
@@ -581,7 +581,7 @@ void filter2d::Filter2d::doit(const ImgReaderGdal& input, 
ImgWriterGdal& output,
            outBuffer[x/down]=(m_noDataValues.size())? m_noDataValues[0] : 0;
           break;
        }
-        case(filter2d::majority):{
+        case(filter2d::mode):{
          if(occurrence.size()){
             std::map<long int,int>::const_iterator maxit=occurrence.begin();
             for(std::map<long int,int>::const_iterator 
mit=occurrence.begin();mit!=occurrence.end();++mit){
diff --git a/src/algorithms/Filter2d.h b/src/algorithms/Filter2d.h
index deb27d8..d4e1917 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, countid=134, dwt_cut_from=135};
+  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, 
mode=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, dwt_cut_from=135};
 
   enum RESAMPLE { NEAR = 0, BILINEAR = 1, BICUBIC = 2 };//bicubic not 
supported yet...
   
@@ -149,7 +149,7 @@ private:
     m_filterMap["sobelyx"]=filter2d::sobelyx;
     m_filterMap["smooth"]=filter2d::smooth;
     m_filterMap["density"]=filter2d::density;
-    m_filterMap["majority"]=filter2d::majority;
+    m_filterMap["mode"]=filter2d::mode;
     m_filterMap["mixed"]=filter2d::mixed;
     m_filterMap["smoothnodata"]=filter2d::smoothnodata;
     m_filterMap["threshold"]=filter2d::threshold;
@@ -453,7 +453,7 @@ template<class T1, class T2> void Filter2d::doit(const 
Vector2d<T1>& inputVector
           outBuffer[x/down]=noDataValue;
         break;
       }
-      case(filter2d::majority):{
+      case(filter2d::mode):{
         if(occurrence.size()){
           std::map<int,int>::const_iterator maxit=occurrence.begin();
           for(std::map<int,int>::const_iterator 
mit=occurrence.begin();mit!=occurrence.end();++mit){
diff --git a/src/apps/pkextract.cc b/src/apps/pkextract.cc
index 759782b..8ec5bd6 100644
--- a/src/apps/pkextract.cc
+++ b/src/apps/pkextract.cc
@@ -35,7 +35,7 @@ along with pktools.  If not, see 
<http://www.gnu.org/licenses/>.
 #endif
 
 namespace rule{
-  enum RULE_TYPE {point=0, mean=1, proportion=2, custom=3, min=4, max=5, 
maxvote=6, centroid=7, sum=8, median=9, stdev=10};
+  enum RULE_TYPE {point=0, mean=1, proportion=2, custom=3, min=4, max=5, 
mode=6, centroid=7, sum=8, median=9, stdev=10};
 }
 
 using namespace std;
@@ -48,14 +48,14 @@ int main(int argc, char *argv[])
   Optionpk<unsigned int> random_opt("rand", "random", "Create simple random 
sample of points. Provide number of points to generate");
   Optionpk<double> grid_opt("grid", "grid", "Create systematic grid of points. 
Provide cell grid size (in projected units, e.g,. m)");
   Optionpk<string> output_opt("o", "output", "Output sample dataset");
-  Optionpk<int> class_opt("c", "class", "Class(es) to extract from input 
sample image. Leave empty to extract all valid data pixels from sample dataset. 
Make sure to set classes if rule is set to maxvote or proportion");
+  Optionpk<int> class_opt("c", "class", "Class(es) to extract from input 
sample image. Leave empty to extract all valid data pixels from sample dataset. 
Make sure to set classes if rule is set to mode or proportion");
   Optionpk<float> threshold_opt("t", "threshold", "Probability threshold for 
selecting samples (randomly). Provide probability in percentage (>0) or 
absolute (<0). Use a single threshold for vector sample datasets. If using 
raster land cover maps as a sample dataset, you can provide a threshold value 
for each class (e.g. -t 80 -t 60). Use value 100 to select all pixels for 
selected class(es)", 100);
   Optionpk<string> ogrformat_opt("f", "f", "Output sample dataset 
format","SQLite");
   Optionpk<string> ftype_opt("ft", "ftype", "Field type (only Real or 
Integer)", "Real");
   Optionpk<string> ltype_opt("lt", "ltype", "Label type: In16 or String", 
"Integer");
   Optionpk<bool> polygon_opt("polygon", "polygon", "Create OGRPolygon as 
geometry instead of OGRPoint.", false);
   Optionpk<int> band_opt("b", "band", "Band index(es) to extract. Leave empty 
to use all bands");
-  Optionpk<string> rule_opt("r", "rule", "Rule how to report image information 
per feature (only for vector sample). point (value at each point or at centroid 
if polygon), centroid, mean, stdev, median, proportion, min, max, maxvote, 
sum.", "centroid");
+  Optionpk<string> rule_opt("r", "rule", "Rule how to report image information 
per feature (only for vector sample). point (value at each point or at centroid 
if polygon), centroid, mean, stdev, median, proportion, min, max, mode, sum.", 
"centroid");
   Optionpk<double> srcnodata_opt("srcnodata", "srcnodata", "Invalid value(s) 
for input image");
   Optionpk<int> bndnodata_opt("bndnodata", "bndnodata", "Band(s) in input 
image to check if pixel is valid (used for srcnodata)", 0);
   Optionpk<float> polythreshold_opt("tp", "thresholdPolygon", "(absolute) 
threshold for selecting samples in each polygon");
@@ -118,7 +118,7 @@ int main(int argc, char *argv[])
   ruleMap["min"]=rule::min;
   ruleMap["max"]=rule::max;
   ruleMap["custom"]=rule::custom;
-  ruleMap["maxvote"]=rule::maxvote;
+  ruleMap["mode"]=rule::mode;
   ruleMap["sum"]=rule::sum;
 
   if(srcnodata_opt.size()){
@@ -771,7 +771,7 @@ int main(int argc, char *argv[])
          break;
        }
        case(rule::custom):
-       case(rule::maxvote):
+       case(rule::mode):
          ogrWriter.createField(label_opt[0],fieldType,ilayerWrite);
        if(test_opt.size())
          ogrTestWriter.createField(label_opt[0],fieldType,ilayerWrite);
@@ -1259,7 +1259,7 @@ int main(int argc, char *argv[])
                    
writePolygonFeature->SetField(label_opt[0].c_str(),static_cast<int>(20));
                  }
                }
-               else if(ruleMap[rule_opt[0]]==rule::maxvote){
+               else if(ruleMap[rule_opt[0]]==rule::mode){
                  //maximum votes in polygon
                  if(verbose_opt[0])
                    std::cout << "number of points in window: " << nPointWindow 
<< std::endl;
@@ -1720,7 +1720,7 @@ int main(int argc, char *argv[])
                    
writePolygonFeature->SetField(label_opt[0].c_str(),static_cast<int>(20));
                  }
                }
-               else if(ruleMap[rule_opt[0]]==rule::maxvote){
+               else if(ruleMap[rule_opt[0]]==rule::mode){
                  //maximum votes in polygon
                  if(verbose_opt[0])
                    std::cout << "number of points in polygon: " << 
nPointPolygon << std::endl;
@@ -2238,7 +2238,7 @@ int main(int argc, char *argv[])
                    
writePolygonFeature->SetField(label_opt[0].c_str(),static_cast<int>(20));
                  }
                }
-               else if(ruleMap[rule_opt[0]]==rule::maxvote){
+               else if(ruleMap[rule_opt[0]]==rule::mode){
                  //maximum votes in polygon
                  if(verbose_opt[0])
                    std::cout << "number of points in polygon: " << 
nPointPolygon << std::endl;
diff --git a/src/apps/pkfilter.cc b/src/apps/pkfilter.cc
index 21d43cc..2645f1b 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, 
countid, majority voting (only for classes), smoothnodata (smooth nodata values 
only) values, threshold local  [...]
+  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, mode (majority voting, only for classes), smoothnodata (smooth nodata 
values only) values, threshold  [...]
   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);
@@ -191,7 +191,10 @@ int main(int argc,char **argv) {
       
output.open(output_opt[0],(input.nrOfCol()+down_opt[0]-1)/down_opt[0],(input.nrOfRow()+down_opt[0]-1)/down_opt[0],nband,theType,imageType,option_opt);
     }
     else{
-      int nband=(dimZ_opt[0]==1)? 1 : input.nrOfBand();
+      int nband=input.nrOfBand();
+      if(dimZ_opt.size())
+       if(dimZ_opt[0]==1)
+         nband=1;
       
output.open(output_opt[0],(input.nrOfCol()+down_opt[0]-1)/down_opt[0],(input.nrOfRow()+down_opt[0]-1)/down_opt[0],nband,theType,imageType,option_opt);
     }
   }
@@ -241,6 +244,7 @@ int main(int argc,char **argv) {
     if(verbose_opt[0])
       std::cout<< std::endl;
   }
+
   if(nodata_opt.size()){
     if(verbose_opt[0])
       std::cout<< "mask values: ";
diff --git a/src/apps/pkkalman.cc b/src/apps/pkkalman.cc
index bbc7475..24dd44b 100644
--- a/src/apps/pkkalman.cc
+++ b/src/apps/pkkalman.cc
@@ -50,6 +50,7 @@ int main(int argc,char **argv) {
   Optionpk<double> eps_opt("eps", "eps", "epsilon for non zero division", 
0.00001);
   Optionpk<double> uncertModel_opt("um", "uncertmodel", "Multiply this value 
with std dev of first model image to obtain uncertainty of model",2);
   Optionpk<double> uncertObs_opt("uo", "uncertobs", "Uncertainty of valid 
observations",0);
+  Optionpk<double> deltaObs_opt("dobs", "deltaobs", "Threshold for relative 
difference (in percentage) in observation and model pixel");
   Optionpk<double> uncertNodata_opt("unodata", "uncertnodata", "Uncertainty in 
case of no-data values in observation", 10000);
   // Optionpk<double> regTime_opt("rt", "regtime", "Relative Weight for 
regression in time series", 1.0);
   // Optionpk<double> regSensor_opt("rs", "regsensor", "Relative Weight for 
regression in sensor series", 1.0);
@@ -57,7 +58,7 @@ int main(int argc,char **argv) {
   Optionpk<float> threshold_opt("th", "threshold", "threshold for selecting 
samples (randomly). Provide probability in percentage (>0) or absolute (<0).", 
0);
   Optionpk<int> minreg_opt("minreg", "minreg", "Minimum number of pixels to 
take into account for regression", 5, 2);
   // Optionpk<bool> regObs_opt("regobs", "regobs", "Perform regression between 
modeled and observed value",false);
-  Optionpk<bool> checkDiff_opt("diff", "diff", "Flag observation as invalid if 
difference with model is above uncertainty",false);
+  // Optionpk<double> checkDiff_opt("diff", "diff", "Flag observation as 
invalid if difference with model is above uncertainty",false);
   Optionpk<unsigned short> window_opt("win", "window", "window size for 
calculating regression (use 0 for global)", 0);
   Optionpk<string>  oformat_opt("of", "oformat", "Output image format (see 
also gdal_translate). Empty string: inherit from input image","GTiff",2);
   Optionpk<string> option_opt("co", "co", "Creation option for output file. 
Multiple options can be specified.");
@@ -83,6 +84,7 @@ int main(int argc,char **argv) {
     eps_opt.retrieveOption(argc,argv);
     uncertModel_opt.retrieveOption(argc,argv);
     uncertObs_opt.retrieveOption(argc,argv);
+    deltaObs_opt.retrieveOption(argc,argv);
     uncertNodata_opt.retrieveOption(argc,argv);
     // regTime_opt.retrieveOption(argc,argv);
     // regSensor_opt.retrieveOption(argc,argv);
@@ -90,7 +92,7 @@ int main(int argc,char **argv) {
     threshold_opt.retrieveOption(argc,argv);
     minreg_opt.retrieveOption(argc,argv);
     // regObs_opt.retrieveOption(argc,argv);
-    checkDiff_opt.retrieveOption(argc,argv);
+    // checkDiff_opt.retrieveOption(argc,argv);
     window_opt.retrieveOption(argc,argv);
     oformat_opt.retrieveOption(argc,argv);
     option_opt.retrieveOption(argc,argv);
@@ -613,13 +615,14 @@ int main(int argc,char **argv) {
          //observation update
          if(update&&!imgReaderObs.isNoData(obsLineBuffer[icol])){
            bool doUpdate=true;
-           if(checkDiff_opt[0]){
+           if(deltaObs_opt.size()){
              statfactory::StatFactory statobs;
              statobs.setNoDataValues(obsnodata_opt);
              double obsMeanValue=statobs.mean(obsWindowBuffer);
              double difference=(obsMeanValue-c0obs)/c1obs-modValue;
+             difference/=modValue;//make relative difference
              difference*=difference;
-             doUpdate=(sqrt(difference)<uncertModel_opt[0]*stdDev);
+             doUpdate=(100*sqrt(difference)<deltaObs_opt[0]);
            }
            if(doUpdate){
              double kalmanGain=1;
@@ -1035,13 +1038,15 @@ int main(int argc,char **argv) {
          //observation update
          if(update&&!imgReaderObs.isNoData(obsLineBuffer[icol])){
            bool doUpdate=true;
-           if(checkDiff_opt[0]){
+           if(deltaObs_opt.size()){
              statfactory::StatFactory statobs;
              statobs.setNoDataValues(obsnodata_opt);
              double obsMeanValue=statobs.mean(obsWindowBuffer);
              double difference=(obsMeanValue-c0obs)/c1obs-modValue;
              difference*=difference;
-             doUpdate=(sqrt(difference)<uncertModel_opt[0]*stdDev);
+             difference/=modValue;//make relative difference
+             difference*=difference;
+             doUpdate=(100*sqrt(difference)<deltaObs_opt[0]);
            }
            if(doUpdate){
              double kalmanGain=1;

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

_______________________________________________
Pkg-grass-devel mailing list
Pkg-grass-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel

Reply via email to