Skip to content
Snippets Groups Projects
Commit fc13ba7c authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

Ajout test pour le probleme du SetExtractionRegion()

parent 4d123616
No related branches found
No related tags found
No related merge requests found
......@@ -102,6 +102,14 @@ ADD_TEST(coTvExtractROI ${COMMON_TESTS2}
${INPUTDATA}/cthead1.png
${TEMP}/coExtractROI_cthead1_26_97_209_100.png
26 97 209 100 )
ADD_TEST(coTvExtractROI2 ${COMMON_TESTS2}
--compare-image ${TOL} ${BASELINE}/coExtractROI_cthead1_26_97_209_100.png
${TEMP}/coExtractROI2_cthead1_26_97_209_100.png
otbExtractROI2
${INPUTDATA}/cthead1.png
${TEMP}/coExtractROI2_cthead1_26_97_209_100.png
26 97 209 100 )
ADD_TEST(coTvExtractROI_RGB ${COMMON_TESTS2}
--compare-image ${TOL} ${BASELINE}/coExtractROI_RGB_sbuv_700_60_77_489.png
${TEMP}/coExtractROI_RGB_sbuv_700_60_77_489.png
......@@ -505,6 +513,7 @@ SET(BasicCommon_SRCS2
otbLineSpatialObjectList.cxx
otbExtractROINew.cxx
otbExtractROI.cxx
otbExtractROI2.cxx
otbExtractROI_RGB.cxx
otbMultiChannelExtractROI.cxx
otbMultiChannelExtractROINew.cxx
......
......@@ -28,6 +28,7 @@ void RegisterTests()
{
REGISTER_TEST(otbLineSpatialObjectList);
REGISTER_TEST(otbExtractROI);
REGISTER_TEST(otbExtractROI2);
REGISTER_TEST(otbExtractROINew);
REGISTER_TEST(otbExtractROI_RGB);
REGISTER_TEST(otbMultiChannelExtractROI );
......
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
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.
=========================================================================*/
#include "itkExceptionObject.h"
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
#include "otbImage.h"
#include "otbExtractROI.h"
int otbExtractROI2( int argc, char * argv[] )
{
try
{
const char * inputFilename = argv[1];
const char * outputFilename = argv[2];
unsigned int startX((unsigned int)::atoi(argv[3]));
unsigned int startY((unsigned int)::atoi(argv[4]));
unsigned int sizeX((unsigned int)::atoi(argv[5]));
unsigned int sizeY((unsigned int)::atoi(argv[6]));
typedef unsigned char InputPixelType;
typedef unsigned char OutputPixelType;
typedef otb::ExtractROI< InputPixelType,
OutputPixelType > FilterType;
typedef FilterType::InputImageType InputImageType;
typedef FilterType::OutputImageType OutputImageType;
typedef otb::ImageFileReader< InputImageType > ReaderType;
typedef otb::ImageFileWriter< OutputImageType > WriterType;
FilterType::Pointer filter = FilterType::New();
typedef otb::Image<InputPixelType,2> ImageType;
ImageType::IndexType start;
start[0] = startX;
start[1] = startY;
ImageType::SizeType size;
size[0] = sizeX;
size[1] = sizeY;
ImageType::RegionType region;
region.SetSize( size );
filter->SetExtractionRegion(region);
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
reader->SetFileName( inputFilename );
writer->SetFileName( outputFilename );
filter->SetInput( reader->GetOutput() );
writer->SetInput( filter->GetOutput() );
writer->Update();
}
catch( itk::ExceptionObject & err )
{
std::cout << "Exception itk::ExceptionObject levee !" << std::endl;
std::cout << err << std::endl;
return EXIT_FAILURE;
}
catch( ... )
{
std::cout << "Exception levee inconnue !" << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
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