25 #include <sys/types.h>
27 #include "base/Optionpk.h"
28 #include "base/Vector2d.h"
29 #include "algorithms/Filter2d.h"
30 #include "algorithms/Filter.h"
31 #include "fileclasses/FileReaderAscii.h"
32 #include "imageclasses/ImgReaderGdal.h"
33 #include "imageclasses/ImgWriterGdal.h"
35 #include "algorithms/StatFactory.h"
41 int main(
int argc,
char **argv) {
45 Optionpk<bool> disc_opt(
"circ",
"circular",
"circular disc kernel for dilation and erosion",
false);
47 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 local filtering, ismin, ismax, heterogeneous (central pixel must be different than all other pixels within window), order (rank pixels in order), stdev, mrf, dwt, dwti, dwt_cut, dwt_cut_from, scramble, shift, savgolay, percentile)",
"median");
48 Optionpk<std::string> resample_opt(
"r",
"resampling-method",
"Resampling method for shifting operation (near: nearest neighbour, bilinear: bi-linear interpolation).",
"near");
49 Optionpk<double> dimX_opt(
"dx",
"dx",
"filter kernel size in x, better use odd value to avoid image shift", 3);
50 Optionpk<double> dimY_opt(
"dy",
"dy",
"filter kernel size in y, better use odd value to avoid image shift", 3);
51 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");
52 Optionpk<std::string> wavelet_type_opt(
"wt",
"wavelet",
"wavelet type: daubechies,daubechies_centered, haar, haar_centered, bspline, bspline_centered",
"daubechies");
53 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);
54 Optionpk<int> savgolay_nl_opt(
"nl",
"nl",
"Number of leftward (past) data points used in Savitzky-Golay filter)", 2);
55 Optionpk<int> savgolay_nr_opt(
"nr",
"nr",
"Number of rightward (future) data points used in Savitzky-Golay filter)", 2);
56 Optionpk<int> savgolay_ld_opt(
"ld",
"ld",
"order of the derivative desired in Savitzky-Golay filter (e.g., ld=0 for smoothed function)", 0);
57 Optionpk<int> savgolay_m_opt(
"m",
"m",
"order of the smoothing polynomial in Savitzky-Golay filter, also equal to the highest conserved moment; usual values are m = 2 or m = 4)", 2);
58 Optionpk<short> class_opt(
"class",
"class",
"class value(s) to use for density, erosion, dilation, openening and closing, thresholding");
59 Optionpk<double> threshold_opt(
"t",
"threshold",
"threshold value(s) to use for threshold filter (one for each class), or threshold to cut for dwt_cut (use 0 to keep all) or dwt_cut_from, or sigma for shift", 0);
60 Optionpk<double> nodata_opt(
"nodata",
"nodata",
"nodata value(s) (used for smoothnodata filter)");
61 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");
62 Optionpk<double> tapz_opt(
"tapz",
"tapz",
"taps used for spectral filtering");
63 Optionpk<string> padding_opt(
"pad",
"pad",
"Padding method for filtering (how to handle edge effects). Choose between: symmetric, replicate, circular, zero (pad with 0).",
"symmetric");
64 Optionpk<double> fwhm_opt(
"fwhm",
"fwhm",
"list of full width half to apply spectral filtering (-fwhm band1 -fwhm band2 ...)");
65 Optionpk<std::string> srf_opt(
"srf",
"srf",
"list of ASCII files containing spectral response functions (two columns: wavelength response)");
66 Optionpk<double> wavelengthIn_opt(
"win",
"wavelengthIn",
"list of wavelengths in input spectrum (-win band1 -win band2 ...)");
67 Optionpk<double> wavelengthOut_opt(
"wout",
"wavelengthOut",
"list of wavelengths in output spectrum (-wout band1 -wout band2 ...)");
68 Optionpk<std::string> interpolationType_opt(
"interp",
"interp",
"type of interpolation for spectral filtering (see http://www.gnu.org/software/gsl/manual/html_node/Interpolation-Types.html)",
"akima");
69 Optionpk<double> percentile_opt(
"perc",
"perc",
"Percentile value used for percentile",95);
70 Optionpk<std::string> otype_opt(
"ot",
"otype",
"Data type for output image ({Byte/Int16/UInt16/UInt32/Int32/Float32/Float64/CInt16/CInt32/CFloat32/CFloat64}). Empty string: inherit type from input image",
"");
71 Optionpk<string> oformat_opt(
"of",
"oformat",
"Output image format (see also gdal_translate). Empty string: inherit from input image");
72 Optionpk<string> colorTable_opt(
"ct",
"ct",
"color table (file with 5 columns: id R G B ALFA (0: transparent, 255: solid). Use none to ommit color table");
73 Optionpk<string> option_opt(
"co",
"co",
"Creation option for output file. Multiple options can be specified.");
74 Optionpk<short> down_opt(
"d",
"down",
"down sampling factor. Use value 1 for no downsampling). Use value n>1 for downsampling (aggregation)", 1);
75 Optionpk<string> beta_opt(
"beta",
"beta",
"ASCII file with beta for each class transition in Markov Random Field");
81 Optionpk<short> verbose_opt(
"v",
"verbose",
"verbose mode if > 0", 0,2);
83 resample_opt.setHide(1);
84 option_opt.setHide(1);
85 wavelet_type_opt.setHide(1);
86 savgolay_nl_opt.setHide(1);
87 savgolay_nr_opt.setHide(1);
88 savgolay_ld_opt.setHide(1);
89 savgolay_m_opt.setHide(1);
91 threshold_opt.setHide(1);
94 padding_opt.setHide(1);
95 wavelengthIn_opt.setHide(1);
96 wavelengthOut_opt.setHide(1);
104 interpolationType_opt.setHide(1);
105 otype_opt.setHide(1);
106 oformat_opt.setHide(1);
107 colorTable_opt.setHide(1);
112 doProcess=input_opt.retrieveOption(argc,argv);
113 output_opt.retrieveOption(argc,argv);
116 method_opt.retrieveOption(argc,argv);
117 srf_opt.retrieveOption(argc,argv);
118 fwhm_opt.retrieveOption(argc,argv);
119 percentile_opt.retrieveOption(argc,argv);
120 dimX_opt.retrieveOption(argc,argv);
121 dimY_opt.retrieveOption(argc,argv);
122 dimZ_opt.retrieveOption(argc,argv);
123 nodata_opt.retrieveOption(argc,argv);
124 resample_opt.retrieveOption(argc,argv);
125 option_opt.retrieveOption(argc,argv);
126 wavelet_type_opt.retrieveOption(argc,argv);
127 savgolay_nl_opt.retrieveOption(argc,argv);
128 savgolay_nr_opt.retrieveOption(argc,argv);
129 savgolay_ld_opt.retrieveOption(argc,argv);
130 savgolay_m_opt.retrieveOption(argc,argv);
131 class_opt.retrieveOption(argc,argv);
132 threshold_opt.retrieveOption(argc,argv);
133 tap_opt.retrieveOption(argc,argv);
134 tapz_opt.retrieveOption(argc,argv);
135 padding_opt.retrieveOption(argc,argv);
136 wavelengthIn_opt.retrieveOption(argc,argv);
137 wavelengthOut_opt.retrieveOption(argc,argv);
138 down_opt.retrieveOption(argc,argv);
139 beta_opt.retrieveOption(argc,argv);
140 eps_opt.retrieveOption(argc,argv);
141 l1_opt.retrieveOption(argc,argv);
142 l2_opt.retrieveOption(argc,argv);
143 a1_opt.retrieveOption(argc,argv);
144 a2_opt.retrieveOption(argc,argv);
145 interpolationType_opt.retrieveOption(argc,argv);
146 otype_opt.retrieveOption(argc,argv);
147 oformat_opt.retrieveOption(argc,argv);
148 colorTable_opt.retrieveOption(argc,argv);
149 disc_opt.retrieveOption(argc,argv);
150 verbose_opt.retrieveOption(argc,argv);
152 catch(
string predefinedString){
153 std::cout << predefinedString << std::endl;
158 cout <<
"Usage: pkfilter -i input -o ouptut [-f filter | -perc value | -srf file [-srf file]* -win wavelength [-win wavelength]* | -wout wavelength -fwhm value [-wout wavelength -fwhm value]* -win wavelength [-win wavelength]*]" << endl;
160 std::cout <<
"short option -h shows basic options only, use long option --help to show all options" << std::endl;
165 vector<double> angle_opt;
169 if(input_opt.empty()){
170 cerr <<
"Error: no input file selected, use option -i" << endl;
173 if(output_opt.empty()){
174 cerr <<
"Error: no output file selected, use option -o" << endl;
177 if(method_opt.empty()){
178 cerr <<
"Error: no filter selected, use option -f" << endl;
181 input.open(input_opt[0]);
182 GDALDataType theType=GDT_Unknown;
184 cout <<
"possible output data types: ";
185 for(
int iType = 0; iType < GDT_TypeCount; ++iType){
187 cout <<
" " << GDALGetDataTypeName((GDALDataType)iType);
188 if( GDALGetDataTypeName((GDALDataType)iType) != NULL
189 && EQUAL(GDALGetDataTypeName((GDALDataType)iType),
190 otype_opt[0].c_str()))
191 theType=(GDALDataType) iType;
193 if(theType==GDT_Unknown)
194 theType=input.getDataType();
197 std::cout << std::endl <<
"Output pixel type: " << GDALGetDataTypeName(theType) << endl;
199 string imageType=input.getImageType();
200 if(oformat_opt.size())
201 imageType=oformat_opt[0];
203 if(option_opt.findSubstring(
"INTERLEAVE=")==option_opt.end()){
204 string theInterleave=
"INTERLEAVE=";
205 theInterleave+=input.getInterleave();
206 option_opt.push_back(theInterleave);
211 nband=fwhm_opt.size();
212 else if(srf_opt.size())
213 nband=srf_opt.size();
214 else if(dimZ_opt.size()){
216 else if(percentile_opt.size())
217 nband=percentile_opt.size();
219 switch(filter2d::Filter2d::getFilterType(method_opt[0])){
221 assert(class_opt.size()>1);
223 std::cout <<
"opening output image " << output_opt[0] << std::endl;
224 nband=class_opt.size()
230 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);
234 int nband=input.nrOfBand();
236 if(filter2d::Filter2d::getFilterType(method_opt[0])==filter2d::smoothnodata)
241 std::cout <<
"opening single band output image " << output_opt[0] << std::endl;
243 else if(verbose_opt[0])
244 std::cout <<
"opening multi-band output image " << output_opt[0] << std::endl;
247 std::cout <<
"opening output image " << output_opt[0] << std::endl;
248 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);
251 catch(
string errorstring){
252 cout << errorstring << endl;
255 output.setProjection(input.getProjection());
257 input.getGeoTransform(gt);
260 output.setGeoTransform(gt);
262 if(colorTable_opt.size()){
263 if(colorTable_opt[0]!=
"none"){
265 cout <<
"set colortable " << colorTable_opt[0] << endl;
266 assert(output.getDataType()==GDT_Byte);
267 output.setColorTable(colorTable_opt[0]);
270 else if(input.getColorTable()!=NULL)
271 output.setColorTable(input.getColorTable());
273 if(nodata_opt.size()){
274 for(
int iband=0;iband<output.nrOfBand();++iband)
275 output.GDALSetNoDataValue(nodata_opt[0],iband);
281 cout <<
"Set padding to " << padding_opt[0] << endl;
282 filter1d.setPadding(padding_opt[0]);
283 if(class_opt.size()){
285 std::cout<<
"class values: ";
286 for(
int iclass=0;iclass<class_opt.size();++iclass){
288 filter2d.pushClass(class_opt[iclass]);
290 filter1d.pushClass(class_opt[iclass]);
292 std::cout<< class_opt[iclass] <<
" ";
295 std::cout<< std::endl;
298 if(nodata_opt.size()){
300 std::cout<<
"mask values: ";
301 for(
int imask=0;imask<nodata_opt.size();++imask){
303 std::cout<< nodata_opt[imask] <<
" ";
304 filter1d.pushNoDataValue(nodata_opt[imask]);
305 filter2d.pushNoDataValue(nodata_opt[imask]);
308 std::cout<< std::endl;
311 ifstream tapfile(tap_opt[0].c_str());
315 for(
int j=0;j<dimY_opt[0];++j){
316 for(
int i=0;i<dimX_opt[0];++i){
317 tapfile >> taps[j][i];
321 std::cout <<
"taps: ";
322 for(
int j=0;j<dimY_opt[0];++j){
323 for(
int i=0;i<dimX_opt[0];++i){
324 std::cout<< taps[j][i] <<
" ";
326 std::cout<< std::endl;
329 filter2d.setTaps(taps);
330 filter2d.filter(input,output);
333 else if(tapz_opt.size()){
335 std::cout <<
"taps: ";
336 for(
int itap=0;itap<tapz_opt.size();++itap)
337 std::cout<< tapz_opt[itap] <<
" ";
338 std::cout<< std::endl;
340 filter1d.setTaps(tapz_opt);
341 filter1d.filter(input,output);
343 else if(fwhm_opt.size()){
345 std::cout <<
"spectral filtering to " << fwhm_opt.size() <<
" bands with provided fwhm " << std::endl;
346 assert(wavelengthOut_opt.size()==fwhm_opt.size());
347 assert(wavelengthIn_opt.size());
351 const char* pszMessage;
352 void* pProgressArg=NULL;
353 GDALProgressFunc pfnProgress=GDALTermProgress;
355 pfnProgress(progress,pszMessage,pProgressArg);
356 for(
int y=0;y<input.nrOfRow();++y){
357 if((y+1+down_opt[0]/2)%down_opt[0])
359 for(
int iband=0;iband<input.nrOfBand();++iband)
360 input.readData(lineInput[iband],GDT_Float64,y,iband);
361 filter1d.applyFwhm<
double>(wavelengthIn_opt,lineInput,wavelengthOut_opt,fwhm_opt, interpolationType_opt[0], lineOutput, down_opt[0], verbose_opt[0]);
362 for(
int iband=0;iband<output.nrOfBand();++iband){
364 output.writeData(lineOutput[iband],GDT_Float64,y/down_opt[0],iband);
366 catch(
string errorstring){
367 cerr << errorstring <<
"in band " << iband <<
", line " << y << endl;
370 progress=(1.0+y)/output.nrOfRow();
371 pfnProgress(progress,pszMessage,pProgressArg);
374 else if(srf_opt.size()){
376 std::cout <<
"spectral filtering to " << srf_opt.size() <<
" bands with provided SRF " << std::endl;
377 assert(wavelengthIn_opt.size());
378 vector< Vector2d<double> > srf(srf_opt.size());
380 for(
int isrf=0;isrf<srf_opt.size();++isrf){
382 srfFile.open(srf_opt[isrf].c_str());
385 srf[isrf][0].push_back(0);
386 srf[isrf][1].push_back(0);
387 srf[isrf][0].push_back(1);
388 srf[isrf][1].push_back(0);
390 srf[isrf][0].push_back(v);
392 srf[isrf][1].push_back(v);
396 srf[isrf][0].push_back(srf[isrf][0].back()+1);
397 srf[isrf][1].push_back(0);
398 srf[isrf][0].push_back(srf[isrf][0].back()+1);
399 srf[isrf][1].push_back(0);
401 cout <<
"srf file details: " << srf[isrf][0].size() <<
" wavelengths defined" << endl;
403 assert(output.nrOfBand()==srf.size());
404 double centreWavelength=0;
406 const char* pszMessage;
407 void* pProgressArg=NULL;
408 GDALProgressFunc pfnProgress=GDALTermProgress;
410 pfnProgress(progress,pszMessage,pProgressArg);
411 for(
int y=0;y<input.nrOfRow();++y){
412 if((y+1+down_opt[0]/2)%down_opt[0])
414 for(
int iband=0;iband<input.nrOfBand();++iband)
415 input.readData(lineInput[iband],GDT_Float64,y,iband);
416 for(
int isrf=0;isrf<srf.size();++isrf){
417 vector<double> lineOutput(output.nrOfCol());
420 centreWavelength=filter1d.applySrf<
double>(wavelengthIn_opt,lineInput,srf[isrf], interpolationType_opt[0], lineOutput, delta, normalize);
422 std::cout <<
"centre wavelength srf " << isrf <<
": " << centreWavelength << std::endl;
424 output.writeData(lineOutput,GDT_Float64,y/down_opt[0],isrf);
426 catch(
string errorstring){
427 cerr << errorstring <<
"in srf " << srf_opt[isrf] <<
", line " << y << endl;
431 progress=(1.0+y)/output.nrOfRow();
432 pfnProgress(progress,pszMessage,pProgressArg);
437 switch(filter2d::Filter2d::getFilterType(method_opt[0])){
438 case(filter2d::dilate):
440 std::cerr <<
"Error: down option not supported for morphological operator" << std::endl;
445 std::cout<<
"1-D filtering: dilate" << std::endl;
446 filter1d.morphology(input,output,
"dilate",dimZ_opt[0],verbose_opt[0]);
449 filter2d.morphology(input,output,
"dilate",dimX_opt[0],dimY_opt[0],angle_opt,disc_opt[0]);
452 case(filter2d::erode):
454 std::cerr <<
"Error: down option not supported for morphological operator" << std::endl;
457 if(dimZ_opt.size()>0){
459 std::cout<<
"1-D filtering: dilate" << std::endl;
460 filter1d.morphology(input,output,
"erode",dimZ_opt[0]);
463 filter2d.morphology(input,output,
"erode",dimX_opt[0],dimY_opt[0],angle_opt,disc_opt[0]);
466 case(filter2d::close):{
468 std::cerr <<
"Error: down option not supported for morphological operator" << std::endl;
473 tmpout.open(
"/vsimem/dilation",input);
476 filter1d.morphology(input,tmpout,
"dilate",dimZ_opt[0]);
479 filter2d.morphology(input,tmpout,
"dilate",dimX_opt[0],dimY_opt[0],angle_opt,disc_opt[0]);
482 catch(std::string errorString){
483 std::cout<< errorString;
487 tmpin.open(
"/vsimem/dilation");
489 filter1d.morphology(tmpin,output,
"erode",dimZ_opt[0]);
492 filter2d.morphology(tmpin,output,
"erode",dimX_opt[0],dimY_opt[0],angle_opt,disc_opt[0]);
498 case(filter2d::open):{
500 std::cerr <<
"Error: down option not supported for morphological operator" << std::endl;
504 tmpout.open(
"/vsimem/erosion",input);
507 filter1d.morphology(input,tmpout,
"erode",dimZ_opt[0]);
510 filter2d.morphology(input,tmpout,
"erode",dimX_opt[0],dimY_opt[0],angle_opt,disc_opt[0]);
513 catch(std::string errorString){
514 std::cout<< errorString;
518 tmpin.open(
"/vsimem/erosion");
520 filter1d.morphology(tmpin,output,
"dilate",dimZ_opt[0]);
523 filter2d.morphology(tmpin,output,
"dilate",dimX_opt[0],dimY_opt[0],angle_opt,disc_opt[0]);
529 case(filter2d::homog):{
530 filter2d.doit(input,output,
"homog",dimX_opt[0],dimY_opt[0],down_opt[0],disc_opt[0]);
533 case(filter2d::heterog):{
534 filter2d.doit(input,output,
"heterog",dimX_opt[0],dimY_opt[0],down_opt[0],disc_opt[0]);
537 case(filter2d::shift):{
539 std::cerr <<
"Error: down option not supported for shift operator" << std::endl;
542 assert(input.nrOfBand());
543 assert(input.nrOfCol());
544 assert(input.nrOfRow());
546 filter2d.shift(input,output,dimX_opt[0],dimY_opt[0],threshold_opt[0],filter2d::Filter2d::getResampleType(resample_opt[0]));
548 catch(
string errorstring){
549 cerr << errorstring << endl;
575 case(filter2d::mrf):{
577 std::cout <<
"Markov Random Field filtering" << std::endl;
583 vector<int> cols(class_opt.size());
584 for(
int iclass=0;iclass<class_opt.size();++iclass)
586 betaReader.readData(beta,cols);
588 std::cout <<
"using values for beta:" << std::endl;
589 for(
int iclass1=0;iclass1<class_opt.size();++iclass1)
590 std::cout <<
" " << iclass1 <<
" (" << class_opt[iclass1] <<
")";
591 std::cout << std::endl;
592 for(
int iclass1=0;iclass1<class_opt.size();++iclass1){
593 std::cout << iclass1 <<
" (" << class_opt[iclass1] <<
")";
594 for(
int iclass2=0;iclass2<class_opt.size();++iclass2)
595 std::cout <<
" " << beta[iclass2][iclass1] <<
" (" << class_opt[iclass2] <<
")";
596 std::cout << std::endl;
599 filter2d.mrf(input, output, dimX_opt[0], dimY_opt[0], beta,
true, down_opt[0], verbose_opt[0]);
602 filter2d.mrf(input, output, dimX_opt[0], dimY_opt[0], 1,
true, down_opt[0], verbose_opt[0]);
605 case(filter2d::sobelx):{
607 std::cerr <<
"Error: down option not supported for sobel edge detection" << std::endl;
620 filter2d.setTaps(theTaps);
621 filter2d.filter(input,output,
true,
true);
624 case(filter2d::sobely):{
626 std::cerr <<
"Error: down option not supported for sobel edge detection" << std::endl;
639 filter2d.setTaps(theTaps);
640 filter2d.filter(input,output,
true,
true);
643 case(filter2d::sobelxy):{
645 std::cerr <<
"Error: down option not supported for sobel edge detection" << std::endl;
658 filter2d.setTaps(theTaps);
659 filter2d.filter(input,output,
true,
true);
662 case(filter2d::sobelyx):{
664 std::cerr <<
"Error: down option not supported for sobel edge detection" << std::endl;
677 filter2d.setTaps(theTaps);
678 filter2d.filter(input,output,
true,
true);
681 case(filter2d::smooth):{
683 std::cerr <<
"Error: down option not supported for this filter" << std::endl;
688 std::cout<<
"1-D filtering: smooth" << std::endl;
689 filter1d.smooth(input,output,dimZ_opt[0]);
692 filter2d.smooth(input,output,dimX_opt[0],dimY_opt[0]);
696 case(filter2d::smoothnodata):{
698 std::cerr <<
"Error: down option not supported for this filter" << std::endl;
703 std::cout<<
"1-D filtering: smooth" << std::endl;
704 filter1d.smoothNoData(input,interpolationType_opt[0],output);
707 filter2d.smoothNoData(input,output,dimX_opt[0],dimY_opt[0]);
712 std::cerr <<
"Error: down option not supported for this filter" << std::endl;
717 std::cout<<
"DWT in spectral domain" << std::endl;
718 filter1d.dwtForward(input, output, wavelet_type_opt[0], family_opt[0]);
721 filter2d.dwtForward(input, output, wavelet_type_opt[0], family_opt[0]);
723 case(filter2d::dwti):
725 std::cerr <<
"Error: down option not supported for this filter" << std::endl;
730 std::cout<<
"inverse DWT in spectral domain" << std::endl;
731 filter1d.dwtInverse(input, output, wavelet_type_opt[0], family_opt[0]);
734 filter2d.dwtInverse(input, output, wavelet_type_opt[0], family_opt[0]);
736 case(filter2d::dwt_cut):
738 std::cerr <<
"Error: down option not supported for this filter" << std::endl;
743 std::cout<<
"DWT approximation in spectral domain" << std::endl;
744 filter1d.dwtCut(input, output, wavelet_type_opt[0], family_opt[0], threshold_opt[0]);
747 filter2d.dwtCut(input, output, wavelet_type_opt[0], family_opt[0], threshold_opt[0]);
749 case(filter2d::dwt_cut_from):
751 std::cerr <<
"Error: down option not supported for this filter" << std::endl;
756 std::cout<<
"DWT approximation in spectral domain" << std::endl;
757 filter1d.dwtCutFrom(input, output, wavelet_type_opt[0], family_opt[0], static_cast<int>(threshold_opt[0]));
760 std::cerr <<
"Error: this filter is not supported in 2D" << std::endl;
764 case(filter2d::savgolay):{
765 assert(savgolay_nl_opt.size());
766 assert(savgolay_nr_opt.size());
767 assert(savgolay_ld_opt.size());
768 assert(savgolay_m_opt.size());
770 std::cout <<
"Calculating Savitzky-Golay coefficients: " << endl;
771 filter1d.getSavGolayCoefficients(tapz_opt, input.nrOfBand(), savgolay_nl_opt[0], savgolay_nr_opt[0], savgolay_ld_opt[0], savgolay_m_opt[0]);
773 std::cout <<
"taps (size is " << tapz_opt.size() <<
"): ";
774 for(
int itap=0;itap<tapz_opt.size();++itap)
775 std::cout<< tapz_opt[itap] <<
" ";
776 std::cout<< std::endl;
778 filter1d.setTaps(tapz_opt);
779 filter1d.filter(input,output);
782 case(filter2d::threshold):
783 filter2d.setThresholds(threshold_opt);
784 case(filter2d::density):
785 filter2d.setClasses(class_opt);
787 std::cout <<
"classes set" << std::endl;
791 filter1d.stat(input,output,method_opt[0]);
793 assert(down_opt[0]==1);
794 filter1d.filter(input,output,method_opt[0],dimZ_opt[0]);
798 filter2d.doit(input,output,method_opt[0],dimX_opt[0],dimY_opt[0],down_opt[0],disc_opt[0]);