[pktools] 73/375: error in classValueMap when class name and value option not provided
Bas Couwenberg
sebastic at xs4all.nl
Wed Dec 3 21:54:00 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 185b48502c8ec91182d8e1d7fa2dbeefae0a88f8
Author: Pieter Kempeneers <kempenep at gmail.com>
Date: Mon Mar 18 10:23:46 2013 +0100
error in classValueMap when class name and value option not provided
---
src/algorithms/Filter.h | 25 +++++++++++++++----------
src/apps/pkclassify_svm.cc | 8 ++++++--
src/apps/pkfilter.cc | 12 ++++++++----
src/base/Makefile.am | 2 +-
src/base/Makefile.in | 2 +-
5 files changed, 31 insertions(+), 18 deletions(-)
diff --git a/src/algorithms/Filter.h b/src/algorithms/Filter.h
index 75bce71..eaf5e33 100644
--- a/src/algorithms/Filter.h
+++ b/src/algorithms/Filter.h
@@ -55,10 +55,10 @@ public:
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 Vector2d<T>& input, const Vector2d<double>& srf, const std::string& interpolationType, vector<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 verbose=false);
// void applySrf(const vector<double> &wavelengthIn, const ImgReaderGdal& input, const vector< Vector2d<double> > &srf, const std::string& interpolationType, ImgWriterGdal& output, bool verbose=false);
template<class T> void applyFwhm(const vector<double> &wavelengthIn, const vector<double>& input, const vector<double> &wavelengthOut, const vector<double> &fwhm, const std::string& interpolationType, vector<double>& 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, 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);
// void applyFwhm(const vector<double> &wavelengthIn, const ImgReaderGdal& input, const vector<double> &wavelengthOut, const vector<double> &fwhm, const std::string& interpolationType, ImgWriterGdal& output, bool verbose=false);
// int fir(double* input, int nbandIn, vector<double>& output, int startBand, const string& wavelength, const string& fwhm, bool verbose);
// int fir(const vector<double>&input, vector<double>& output, int startBand, double fwhm, int ntaps, int down, int offset, bool verbose);
@@ -102,12 +102,12 @@ private:
//input[band][sample], output[sample]
//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, bool verbose)
+ 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 verbose)
{
assert(srf.size()==2);//[0]: wavelength, [1]: response function
int nband=srf[0].size();
unsigned int nsample=input[0].size();
- output.resize(nsample);
+ output.resize((nsample+down-1)/down);
double start=floor(wavelengthIn[0]);
double end=ceil(wavelengthIn.back());
if(verbose)
@@ -151,6 +151,8 @@ private:
assert(splineOut);
for(int isample=0;isample<nsample;++isample){
+ if((isample+1+down/2)%down)
+ continue;
vector<T> inputValues;
input.selectCol(isample,inputValues);
assert(wavelengthIn.size()==inputValues.size());
@@ -164,10 +166,11 @@ private:
assert(input_fine.size()==srf_fine.size());
assert(input_fine.size()==wavelength_fine.size());
stat.initSpline(splineOut,&(wavelength_fine[0]),&(product[0]),wavelength_fine.size());
+ //hiero
if(normalize)
- output[isample]=gsl_spline_eval_integ(splineOut,start,end,accOut)/norm;
+ output[isample/down]=gsl_spline_eval_integ(splineOut,start,end,accOut)/norm;
else
- output[isample]=gsl_spline_eval_integ(splineOut,start,end,accOut);
+ output[isample/down]=gsl_spline_eval_integ(splineOut,start,end,accOut);
}
gsl_spline_free(splineOut);
gsl_interp_accel_free(accOut);
@@ -229,7 +232,7 @@ 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, bool verbose){
+ 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){
double delta=1;//1 nm resolution
vector<double> stddev(fwhm.size());
for(int index=0;index<fwhm.size();++index)
@@ -249,7 +252,7 @@ template<class T> void Filter::applyFwhm(const vector<double> &wavelengthIn, con
}
int nbandIn=wavelength_fine.size();
int nbandOut=wavelengthOut.size();
- output.resize(nbandOut,input[0].size());
+ output.resize(nbandOut,(input[0].size()+down-1)/down);
gsl::matrix tf(nbandIn,nbandOut);
vector<double> norm(nbandOut);
@@ -268,15 +271,17 @@ 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;
input.selectCol(isample,inputValues);
assert(wavelengthIn.size()==inputValues.size());
for(int indexOut=0;indexOut<nbandOut;++indexOut){
vector<double> input_fine;
stat.interpolateUp(wavelengthIn,inputValues,wavelength_fine,interpolationType,input_fine,verbose);
- output[indexOut][isample]=0;
+ output[indexOut][(isample+down-1)/down]=0;
for(int indexIn=0;indexIn<nbandIn;++indexIn){
- output[indexOut][isample]+=input_fine[indexIn]*tf(indexIn,indexOut)/norm[indexOut];
+ output[indexOut][(isample+down-1)/down]+=input_fine[indexIn]*tf(indexIn,indexOut)/norm[indexOut];
}
}
}
diff --git a/src/apps/pkclassify_svm.cc b/src/apps/pkclassify_svm.cc
index 6f3e986..f4b5cf6 100644
--- a/src/apps/pkclassify_svm.cc
+++ b/src/apps/pkclassify_svm.cc
@@ -559,8 +559,12 @@ int main(int argc, char *argv[])
if(input_opt[0].find(".shp")==string::npos){
if(classname_opt.empty()){
std::cerr << "Warning: no class name and value pair provided for all " << nclass << " classes, using string2type<int> instead!" << std::endl;
- for(int iclass=0;iclass<nclass;++iclass)
- classValueMap[type2string<short>(iclass)]=string2type<short>(cm.getClass(iclass));
+ for(int iclass=0;iclass<nclass;++iclass){
+ classValueMap[cm.getClass(iclass)]=string2type<short>(cm.getClass(iclass));
+ if(verbose_opt[0]>0)
+ std::cout << iclass << " " << classValueMap[cm.getClass(iclass)] << " -> " << string2type<short>(cm.getClass(iclass)) << std::endl;
+ // classValueMap[type2string<short>(iclass)]=string2type<short>(cm.getClass(iclass));
+ }
}
ImgReaderGdal testImage;
diff --git a/src/apps/pkfilter.cc b/src/apps/pkfilter.cc
index cbf9ca0..7db2f8b 100644
--- a/src/apps/pkfilter.cc
+++ b/src/apps/pkfilter.cc
@@ -133,7 +133,7 @@ int main(int argc,char **argv) {
if(fwhm_opt.size()||srf_opt.size()){
//todo: support down and offset
int nband=fwhm_opt.size()? fwhm_opt.size():srf_opt.size();
- output.open(output_opt[0],input.nrOfCol(),input.nrOfRow(),nband,theType,imageType,option_opt);
+ 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
output.open(output_opt[0],(input.nrOfCol()+down_opt[0]-1)/down_opt[0],(input.nrOfRow()+down_opt[0]-1)/down_opt[0],input.nrOfBand(),theType,imageType,option_opt);
@@ -228,12 +228,14 @@ int main(int argc,char **argv) {
double progress=0;
pfnProgress(progress,pszMessage,pProgressArg);
for(int y=0;y<input.nrOfRow();++y){
+ if((y+1+down_opt[0]/2)%down_opt[0])
+ continue;
for(int iband=0;iband<input.nrOfBand();++iband)
input.readData(lineInput[iband],GDT_Float64,y,iband);
- filter1d.applyFwhm<double>(wavelengthIn_opt,lineInput,wavelengthOut_opt,fwhm_opt, interpolationType_opt[0], lineOutput, verbose_opt[0]);
+ filter1d.applyFwhm<double>(wavelengthIn_opt,lineInput,wavelengthOut_opt,fwhm_opt, interpolationType_opt[0], lineOutput, down_opt[0], verbose_opt[0]);
for(int iband=0;iband<output.nrOfBand();++iband){
try{
- output.writeData(lineOutput[iband],GDT_Float64,y,iband);
+ output.writeData(lineOutput[iband],GDT_Float64,y/down_opt[0],iband);
}
catch(string errorstring){
cerr << errorstring << "in band " << iband << ", line " << y << endl;
@@ -282,6 +284,8 @@ int main(int argc,char **argv) {
double progress=0;
pfnProgress(progress,pszMessage,pProgressArg);
for(int y=0;y<input.nrOfRow();++y){
+ if((y+1+down_opt[0]/2)%down_opt[0])
+ continue;
for(int iband=0;iband<input.nrOfBand();++iband)
input.readData(lineInput[iband],GDT_Float64,y,iband);
for(int isrf=0;isrf<srf.size();++isrf){
@@ -292,7 +296,7 @@ int main(int argc,char **argv) {
if(verbose_opt[0])
std::cout << "centre wavelength srf " << isrf << ": " << centreWavelength << std::endl;
try{
- output.writeData(lineOutput,GDT_Float64,y,isrf);
+ output.writeData(lineOutput,GDT_Float64,y/down_opt[0],isrf);
}
catch(string errorstring){
cerr << errorstring << "in srf " << srf_opt[isrf] << ", line " << y << endl;
diff --git a/src/base/Makefile.am b/src/base/Makefile.am
index 3c1a63b..17d46b1 100644
--- a/src/base/Makefile.am
+++ b/src/base/Makefile.am
@@ -20,7 +20,7 @@ noinst_LIBRARIES = libbase.a
libbase_adir = $(includedir)/base
# the list of header files that belong to the library (to be installed later)
-libbase_a_HEADERS = PointData.h
+libbase_a_HEADERS = $(top_srcdir)/config.h PointData.h Vector2d.h IndexValue.h Optionpk.h PosValue.h
# the sources to add to the library and to add to the source distribution
libbase_a_SOURCES = $(libbase_a_HEADERS) PointData.cc
diff --git a/src/base/Makefile.in b/src/base/Makefile.in
index a0ddf10..ed38054 100644
--- a/src/base/Makefile.in
+++ b/src/base/Makefile.in
@@ -228,7 +228,7 @@ noinst_LIBRARIES = libbase.a
libbase_adir = $(includedir)/base
# the list of header files that belong to the library (to be installed later)
-libbase_a_HEADERS = PointData.h
+libbase_a_HEADERS = $(top_srcdir)/config.h PointData.h Vector2d.h IndexValue.h Optionpk.h PosValue.h
# the sources to add to the library and to add to the source distribution
libbase_a_SOURCES = $(libbase_a_HEADERS) PointData.cc
--
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