Skip to content
Snippets Groups Projects
Commit bbd11fcd authored by Manuel Grizonnet's avatar Manuel Grizonnet
Browse files

Automated merge with http://hg.orfeo-toolbox.org/OTB

parents b40394f9 8cbe9493
No related branches found
No related tags found
No related merge requests found
/*=========================================================================
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;
}
......@@ -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)
......
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