Skip to content
Snippets Groups Projects
Commit 0fd65a59 authored by Rashad Kanavath's avatar Rashad Kanavath
Browse files

ENH: fix check for input values of direction and mode

parent 1120b0d9
No related branches found
No related tags found
No related merge requests found
...@@ -150,11 +150,11 @@ namespace otb ...@@ -150,11 +150,11 @@ namespace otb
AddParameter(ParameterType_Choice, AddParameter(ParameterType_Choice,
"direction", "dir",
"direction: forward/inverse"); "dir: fwd/inv");
AddChoice("direction.forward", "forward"); AddChoice("dir.fwd", "fwd");
AddChoice("direction.inverse", "inverse"); AddChoice("dir.inv", "inv");
AddParameter(ParameterType_OutputImage, "out", "Output Image"); AddParameter(ParameterType_OutputImage, "out", "Output Image");
SetParameterDescription("out", "Output image"); SetParameterDescription("out", "Output image");
...@@ -190,18 +190,22 @@ namespace otb ...@@ -190,18 +190,22 @@ namespace otb
void DoExecute() ITK_OVERRIDE void DoExecute() ITK_OVERRIDE
{ {
int direction = GetParameterInt("direction"); int dir = GetParameterInt("dir");
int mode = GetParameterInt("mode"); int mode = GetParameterInt("mode");
if( direction != 0 || direction != 1) if( dir != 0 && dir != 1)
{ {
itkExceptionMacro( << "direction must be either 'fwd' or 'inv'"); itkExceptionMacro( << "-dir is '"
<< dir << "'."
<< "It must be either 'fwd' or 'inv'");
} }
if( mode != 0 || mode != 1) if( mode != 0 && mode != 1)
{ {
itkExceptionMacro( << "mode must be either 'fft' or 'wavelet'"); itkExceptionMacro( << "mode is '"
<< mode << "'."
<< "It must must be either 'fft' or 'wavelet'");
} }
...@@ -211,34 +215,34 @@ namespace otb ...@@ -211,34 +215,34 @@ namespace otb
switch (wavelet_type) switch (wavelet_type)
{ {
case 0: case 0:
DoWaveletTransform<otb::Wavelet::HAAR> ( direction); DoWaveletTransform<otb::Wavelet::HAAR> ( dir );
break; break;
case 1: case 1:
DoWaveletTransform< otb::Wavelet::DB4 > (direction); DoWaveletTransform< otb::Wavelet::DB4 > ( dir );
break; break;
case 2: case 2:
DoWaveletTransform<otb::Wavelet::DB4> (direction); DoWaveletTransform<otb::Wavelet::DB4> ( dir );
break; break;
case 3: case 3:
DoWaveletTransform<otb::Wavelet::DB6> (direction); DoWaveletTransform<otb::Wavelet::DB6> ( dir );
break; break;
case 4: case 4:
DoWaveletTransform<otb::Wavelet::DB8> (direction); DoWaveletTransform<otb::Wavelet::DB8> ( dir );
break; break;
case 5: case 5:
DoWaveletTransform<otb::Wavelet::DB12> (direction); DoWaveletTransform<otb::Wavelet::DB12> ( dir );
break; break;
case 6: case 6:
DoWaveletTransform<otb::Wavelet::DB20> (direction); DoWaveletTransform<otb::Wavelet::DB20> ( dir );
break; break;
case 7: case 7:
DoWaveletTransform<otb::Wavelet::SPLINE_BIORTHOGONAL_2_4 > (direction); DoWaveletTransform<otb::Wavelet::SPLINE_BIORTHOGONAL_2_4 > ( dir );
break; break;
case 8: case 8:
DoWaveletTransform<otb::Wavelet::SPLINE_BIORTHOGONAL_4_4> (direction); DoWaveletTransform<otb::Wavelet::SPLINE_BIORTHOGONAL_4_4> ( dir );
break; break;
case 9: case 9:
DoWaveletTransform<otb::Wavelet::SYMLET8> (direction); DoWaveletTransform<otb::Wavelet::SYMLET8> ( dir );
break; break;
default: default:
itkExceptionMacro( << "Invalid wavelet type: '" << wavelet_type << "'"); itkExceptionMacro( << "Invalid wavelet type: '" << wavelet_type << "'");
...@@ -250,7 +254,7 @@ namespace otb ...@@ -250,7 +254,7 @@ namespace otb
else else
{ {
//forward fft //forward fft
if (direction == 0 ) if (dir == 0 )
{ {
typedef otb::Image<TInputPixel> TInputImage; typedef otb::Image<TInputPixel> TInputImage;
...@@ -339,7 +343,7 @@ namespace otb ...@@ -339,7 +343,7 @@ namespace otb
template<otb::Wavelet::Wavelet TWaveletOperator> template<otb::Wavelet::Wavelet TWaveletOperator>
void DoWaveletTransform(const int direction, void DoWaveletTransform(const int dir,
const std::string inkey = "in", const std::string inkey = "in",
const std::string outkey = "out") const std::string outkey = "out")
{ {
...@@ -353,7 +357,7 @@ namespace otb ...@@ -353,7 +357,7 @@ namespace otb
inImage->UpdateOutputInformation(); inImage->UpdateOutputInformation();
if( direction == 0) if( dir == 0)
{ {
typedef otb::WaveletImageFilter< typedef otb::WaveletImageFilter<
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment