diff --git a/Testing/Fa/00134-feature_extraction.cxx b/Testing/Fa/00134-feature_extraction.cxx new file mode 100644 index 0000000000000000000000000000000000000000..afebb29f0128f3a81b4281228c1c37fbbcf014f7 --- /dev/null +++ b/Testing/Fa/00134-feature_extraction.cxx @@ -0,0 +1,101 @@ +/*========================================================================= + + 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. + +=========================================================================*/ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#include "otbImage.h" +#include "otbImageFileReader.h" +#include "otbImageFileWriter.h" +#include "otbVectorImage.h" +#include "otbImageList.h" +#include "otbImageListToVectorImageFilter.h" +#include "itkMeanImageFilter.h" +#include "otbMultiToMonoChannelExtractROI.h" +#include "otbMultiChannelRAndNIRIndexImageFilter.h" +#include "otbVegetationIndicesFunctor.h" + + +int main(int argc, char* argv[]) +{ + const char * inputName = argv[1]; + const char * outputName = argv[2]; + const unsigned int radius = atoi(argv[3]); + + typedef double PixelType; + typedef otb::Image<PixelType, 2> ImageType; + typedef otb::VectorImage<PixelType, 2> VectorImageType; + typedef otb::ImageFileReader<VectorImageType> ReaderType; + typedef otb::ImageFileWriter<VectorImageType> WriterType; + + typedef otb::ImageList< ImageType > ImageListType; + typedef otb::ImageListToVectorImageFilter<ImageListType, VectorImageType> ListToImageFilterType; + typedef otb::MultiToMonoChannelExtractROI<PixelType, PixelType> ExtractorFilterType; + typedef itk::MeanImageFilter<ImageType, ImageType> MeanFilterType; + typedef otb::Functor::NDVI< PixelType, PixelType, PixelType > NDVIFunctorType; + typedef otb::MultiChannelRAndNIRIndexImageFilter<VectorImageType,ImageType,NDVIFunctorType> NDVIFilterType; + + ReaderType::Pointer reader = ReaderType::New(); + WriterType::Pointer writer = WriterType::New(); + ImageListType::Pointer imListOut = ImageListType::New(); + ExtractorFilterType::Pointer extract = ExtractorFilterType::New(); + MeanFilterType::Pointer meanner = MeanFilterType::New(); + NDVIFilterType::Pointer ndvi = NDVIFilterType::New(); + ListToImageFilterType::Pointer caster = ListToImageFilterType::New(); + + reader->SetFileName(inputName); + reader->GenerateOutputInformation(); + + extract->SetInput( reader->GetOutput() ); + extract->SetChannel(1); + extract->UpdateOutputInformation(); + + ImageType::SizeType rad; + rad[0] = radius; + rad[1] = radius; + meanner->SetInput( extract->GetOutput() ); + meanner->SetRadius( rad ); + + ndvi->SetInput( reader->GetOutput() ); + + imListOut->PushBack( meanner->GetOutput() ); + imListOut->PushBack( ndvi->GetOutput() ); + + + caster->SetInput(imListOut); + writer->SetInput(caster->GetOutput() ); + writer->SetFileName(outputName); + writer->Update(); + + + + /*** With 2 writers : OK */ + /* + typedef otb::ImageFileWriter<ImageType> WriterMonoType; + WriterMonoType::Pointer w1 = WriterMonoType::New(); + WriterMonoType::Pointer w2 = WriterMonoType::New(); + w1->SetInput( imListOut->GetNthElement(0) ); + w2->SetInput( imListOut->GetNthElement(1) ); + w1->SetFileName("meaner.tif"); + w2->SetFileName("ndvi.tif"); + w1->Update(); + w2->Update(); + */ + + return EXIT_SUCCESS; +} diff --git a/Testing/Fa/CMakeLists.txt b/Testing/Fa/CMakeLists.txt index 74cce0766a2209715fd3d7f7e255a8a03b069614..4ab6edaf6379d2d8951412655bcb14d4103181b6 100755 --- a/Testing/Fa/CMakeLists.txt +++ b/Testing/Fa/CMakeLists.txt @@ -214,6 +214,12 @@ ADD_TEST(FA-0000041-mean_shift2 ${CXX_TEST_PATH}/0000041-mean_shift ${TEMP}/labelled_image2.tif ${TEMP}/boundary_of_labelled_image2.tif ) +IF(OTB_DATA_USE_LARGEINPUT) +ADD_TEST(FA-00134-feature_extraction ${CXX_TEST_PATH}/00134-feature_extraction + ${LARGEINPUTDATA}/QUICKBIRD/TOULOUSE/000000128955_01_P001_MUL/02APR01105228-M1BS-000000128955_01_P001.TIF + ${TEMP}/extracted_filter_134.tif + ) +ENDIF(OTB_DATA_USE_LARGEINPUT) IF(OTB_USE_VISU_GUI) ADD_TEST(FA-0000132-jpg ${CXX_TEST_PATH}/0000132-jpg @@ -242,6 +248,9 @@ TARGET_LINK_LIBRARIES(StreamingStat OTBFeatureExtraction OTBIO OTBCommon) ADD_EXECUTABLE(0000041-mean_shift 0000041-mean_shift.cxx) TARGET_LINK_LIBRARIES(0000041-mean_shift OTBIO OTBCommon OTBBasicFilters) +ADD_EXECUTABLE(00134-feature_extraction 00134-feature_extraction.cxx) +TARGET_LINK_LIBRARIES(00134-feature_extraction OTBIO OTBCommon OTBBasicFilters OTBFeatureExtraction) + IF(OTB_USE_VISU_GUI) ADD_EXECUTABLE(0000132-jpg 0000132-jpg.cxx ) TARGET_LINK_LIBRARIES(0000132-jpg OTBIO OTBVisualization)