Skip to content
Snippets Groups Projects
Commit 74025c5d authored by Cyrille Valladeau's avatar Cyrille Valladeau
Browse files

STYLE : try/catch blocs supression in ChangeDetection testing.

parent 85077c17
Branches
Tags
No related merge requests found
Showing
with 145 additions and 268 deletions
......@@ -10,9 +10,9 @@
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
......@@ -89,22 +89,9 @@ int otbCBAMIChangeDetectionTest(int argc, char* argv[] )
filter->AddObserver(itk::ProgressEvent(), observer);
writer->Update();
try
{
writer->Update();
}
catch( itk::ExceptionObject & err )
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return -1;
}
return 0;
return EXIT_SUCCESS;
}
......
......@@ -10,9 +10,9 @@
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
......
......@@ -9,10 +9,10 @@
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
......
......@@ -10,9 +10,9 @@
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
......@@ -90,21 +90,10 @@ int otbCorrelChangeDetectionTest(int argc, char* argv[] )
filter->AddObserver(itk::ProgressEvent(), observer);
writer->Update();
try
{
writer->Update();
}
catch( itk::ExceptionObject & err )
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return -1;
}
return 0;
return EXIT_SUCCESS;
}
......
......@@ -10,9 +10,9 @@
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
......@@ -89,20 +89,10 @@ int otbJHMIChangeDetectionTest(int argc, char* argv[] )
filter->AddObserver(itk::ProgressEvent(), observer);
writer->Update();
try
{
writer->Update();
}
catch( itk::ExceptionObject & err )
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return -1;
}
return 0;
return EXIT_SUCCESS;
}
......
......@@ -10,9 +10,9 @@
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "itkExceptionObject.h"
......@@ -24,58 +24,44 @@
int otbKullbackLeiblerDistanceImageFilter(int argc, char * argv[])
{
try
if(argc != 5)
{
if(argc != 5)
{
std::cerr<<"Detection de changements par mesure de Kullback-Leibler, optimisee par un developpement de Edgeworth\n";
std::cerr << argv[0] << " imgAv imgAp imgResu winSize\n";
return 1;
}
char * fileName1 = argv[1];
char * fileName2 = argv[2];
char * fileNameOut = argv[3];
int winSize = atoi(argv[4]);
const unsigned int Dimension = 2;
typedef double PixelType;
typedef otb::Image<PixelType,Dimension> ImageType;
typedef otb::KullbackLeiblerDistanceImageFilter<ImageType,ImageType,ImageType> FilterType;
typedef otb::ImageFileReader<ImageType> ReaderType;
typedef otb::ImageFileWriter<ImageType> WriterType;
ReaderType::Pointer reader1 = ReaderType::New();
reader1->SetFileName( fileName1 );
ReaderType::Pointer reader2 = ReaderType::New();
reader2->SetFileName( fileName2 );
FilterType::Pointer filter = FilterType::New();
filter->SetRadius( (winSize-1)/2 );
filter->SetInput1( reader1->GetOutput() );
filter->SetInput2( reader2->GetOutput() );
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(fileNameOut);
writer->SetInput(filter->GetOutput());
writer->Update();
std::cerr<<"Detection de changements par mesure de Kullback-Leibler, optimisee par un developpement de Edgeworth\n";
std::cerr << argv[0] << " imgAv imgAp imgResu winSize\n";
return 1;
}
catch( itk::ExceptionObject & err )
{
std::cout << "Exception itk::ExceptionObject thrown !" << std::endl;
std::cout << err << std::endl;
return EXIT_FAILURE;
}
catch( ... )
{
std::cout << "Unknown exception thrown !" << std::endl;
return EXIT_FAILURE;
}
char * fileName1 = argv[1];
char * fileName2 = argv[2];
char * fileNameOut = argv[3];
int winSize = atoi(argv[4]);
const unsigned int Dimension = 2;
typedef double PixelType;
typedef otb::Image<PixelType,Dimension> ImageType;
typedef otb::KullbackLeiblerDistanceImageFilter<ImageType,ImageType,ImageType> FilterType;
typedef otb::ImageFileReader<ImageType> ReaderType;
typedef otb::ImageFileWriter<ImageType> WriterType;
ReaderType::Pointer reader1 = ReaderType::New();
reader1->SetFileName( fileName1 );
ReaderType::Pointer reader2 = ReaderType::New();
reader2->SetFileName( fileName2 );
FilterType::Pointer filter = FilterType::New();
filter->SetRadius( (winSize-1)/2 );
filter->SetInput1( reader1->GetOutput() );
filter->SetInput2( reader2->GetOutput() );
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(fileNameOut);
writer->SetInput(filter->GetOutput());
writer->Update();
return EXIT_SUCCESS;
}
......@@ -10,9 +10,9 @@
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "itkExceptionObject.h"
......@@ -22,29 +22,14 @@
int otbKullbackLeiblerDistanceImageFilterNew(int argc, char * argv[])
{
try
{
const unsigned int Dimension = 2;
typedef double PixelType;
typedef otb::Image<PixelType,Dimension> ImageType;
typedef otb::KullbackLeiblerDistanceImageFilter<ImageType,ImageType,ImageType> FilterType;
FilterType::Pointer filter = FilterType::New();
}
catch( itk::ExceptionObject & err )
{
std::cout << "Exception itk::ExceptionObject thrown !" << std::endl;
std::cout << err << std::endl;
return EXIT_FAILURE;
}
catch( ... )
{
std::cout << "Unknown exception thrown !" << std::endl;
return EXIT_FAILURE;
}
const unsigned int Dimension = 2;
typedef double PixelType;
typedef otb::Image<PixelType,Dimension> ImageType;
typedef otb::KullbackLeiblerDistanceImageFilter<ImageType,ImageType,ImageType> FilterType;
FilterType::Pointer filter = FilterType::New();
return EXIT_SUCCESS;
}
......@@ -10,9 +10,9 @@
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "itkExceptionObject.h"
......@@ -25,59 +25,45 @@
int otbKullbackLeiblerProfileImageFilter(int argc, char * argv[])
{
try
if(argc != 6)
{
if(argc != 6)
{
std::cerr<<"Detection de changements par mesure de Kullback-Leibler, optimisee par un developpement de Edgeworth\n";
std::cerr << argv[0] << " imgAv imgAp imgResu winSizeMin winSizeMax\n";
return 1;
}
char * fileName1 = argv[1];
char * fileName2 = argv[2];
char * fileNameOut = argv[3];
int winSizeMin = atoi(argv[4]);
int winSizeMax = atoi(argv[5]);
const unsigned int Dimension = 2;
typedef double PixelType;
typedef otb::Image<PixelType,Dimension> ImageType;
typedef otb::VectorImage<PixelType,Dimension> VectorImageType;
typedef otb::KullbackLeiblerProfileImageFilter<ImageType,ImageType,VectorImageType> FilterType;
typedef otb::ImageFileReader<ImageType> ReaderType;
typedef otb::ImageFileWriter<VectorImageType> WriterType;
ReaderType::Pointer reader1 = ReaderType::New();
reader1->SetFileName( fileName1 );
ReaderType::Pointer reader2 = ReaderType::New();
reader2->SetFileName( fileName2 );
FilterType::Pointer filter = FilterType::New();
filter->SetRadius( (winSizeMin-1)/2,(winSizeMax-1)/2 );
filter->SetInput1( reader1->GetOutput() );
filter->SetInput2( reader2->GetOutput() );
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(fileNameOut);
writer->SetInput(filter->GetOutput());
writer->Update();
std::cerr<<"Detection de changements par mesure de Kullback-Leibler, optimisee par un developpement de Edgeworth\n";
std::cerr << argv[0] << " imgAv imgAp imgResu winSizeMin winSizeMax\n";
return 1;
}
catch( itk::ExceptionObject & err )
{
std::cout << "Exception itk::ExceptionObject thrown !" << std::endl;
std::cout << err << std::endl;
return EXIT_FAILURE;
}
catch( ... )
{
std::cout << "Unknown exception thrown !" << std::endl;
return EXIT_FAILURE;
}
char * fileName1 = argv[1];
char * fileName2 = argv[2];
char * fileNameOut = argv[3];
int winSizeMin = atoi(argv[4]);
int winSizeMax = atoi(argv[5]);
const unsigned int Dimension = 2;
typedef double PixelType;
typedef otb::Image<PixelType,Dimension> ImageType;
typedef otb::VectorImage<PixelType,Dimension> VectorImageType;
typedef otb::KullbackLeiblerProfileImageFilter<ImageType,ImageType,VectorImageType> FilterType;
typedef otb::ImageFileReader<ImageType> ReaderType;
typedef otb::ImageFileWriter<VectorImageType> WriterType;
ReaderType::Pointer reader1 = ReaderType::New();
reader1->SetFileName( fileName1 );
ReaderType::Pointer reader2 = ReaderType::New();
reader2->SetFileName( fileName2 );
FilterType::Pointer filter = FilterType::New();
filter->SetRadius( (winSizeMin-1)/2,(winSizeMax-1)/2 );
filter->SetInput1( reader1->GetOutput() );
filter->SetInput2( reader2->GetOutput() );
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(fileNameOut);
writer->SetInput(filter->GetOutput());
writer->Update();
return EXIT_SUCCESS;
}
......@@ -10,9 +10,9 @@
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "itkExceptionObject.h"
......@@ -22,29 +22,15 @@
int otbKullbackLeiblerProfileImageFilterNew(int argc, char * argv[])
{
try
{
const unsigned int Dimension = 2;
typedef double PixelType;
typedef otb::Image<PixelType,Dimension> ImageType;
typedef otb::VectorImage<PixelType,Dimension> VectorImageType;
typedef otb::KullbackLeiblerProfileImageFilter<ImageType,ImageType,VectorImageType> FilterType;
FilterType::Pointer filter = FilterType::New();
}
catch( itk::ExceptionObject & err )
{
std::cout << "Exception itk::ExceptionObject thrown !" << std::endl;
std::cout << err << std::endl;
return EXIT_FAILURE;
}
catch( ... )
{
std::cout << "Unknown exception thrown !" << std::endl;
return EXIT_FAILURE;
}
const unsigned int Dimension = 2;
typedef double PixelType;
typedef otb::Image<PixelType,Dimension> ImageType;
typedef otb::VectorImage<PixelType,Dimension> VectorImageType;
typedef otb::KullbackLeiblerProfileImageFilter<ImageType,ImageType,VectorImageType> FilterType;
FilterType::Pointer filter = FilterType::New();
return EXIT_SUCCESS;
}
......@@ -10,9 +10,9 @@
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
......@@ -89,22 +89,10 @@ int otbLHMIChangeDetectionTest(int argc, char* argv[] )
filter->AddObserver(itk::ProgressEvent(), observer);
try
{
writer->Update();
}
catch( itk::ExceptionObject & err )
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return -1;
}
writer->Update();
return 0;
return EXIT_SUCCESS;
}
......
......@@ -10,9 +10,9 @@
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
......@@ -88,21 +88,11 @@ int otbMeanDiffChangeDetectionTest(int argc, char* argv[] )
CommandType::Pointer observer = CommandType::New();
filter->AddObserver(itk::ProgressEvent(), observer);
try
{
writer->Update();
}
catch( itk::ExceptionObject & err )
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return -1;
}
writer->Update();
return 0;
return EXIT_SUCCESS;
}
......
......@@ -10,9 +10,9 @@
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
......@@ -88,21 +88,11 @@ int otbMeanRatioChangeDetectionTest (int argc, char* argv[] )
CommandType::Pointer observer = CommandType::New();
filter->AddObserver(itk::ProgressEvent(), observer);
writer->Update();
try
{
writer->Update();
}
catch( itk::ExceptionObject & err )
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return -1;
}
return 0;
return EXIT_SUCCESS;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment