Skip to content
Snippets Groups Projects
Commit 7e4981b3 authored by Jordi Inglada's avatar Jordi Inglada
Browse files

Added example for NCCRegistrationFilter

parents fb7240d4 e0b7511f
No related branches found
No related tags found
No related merge requests found
SET(CTEST_PROJECT_NAME "OTB")
SET(CTEST_NIGHTLY_START_TIME "00:00:00 EST")
IF(NOT DEFINED CTEST_DROP_METHOD)
SET(CTEST_DROP_METHOD "http")
ENDIF(NOT DEFINED CTEST_DROP_METHOD)
IF(CTEST_DROP_METHOD STREQUAL "http")
SET(CTEST_DROP_SITE "www.orfeo-toolbox.org")
SET(CTEST_DROP_LOCATION "/Dashboard/submit.php?project=OTB")
SET(CTEST_TRIGGER_SITE "")
ENDIF(CTEST_DROP_METHOD STREQUAL "http")
......@@ -5,6 +5,11 @@ ADD_EXECUTABLE(SimpleDisparityMapEstimationExample SimpleDisparityMapEstimationE
TARGET_LINK_LIBRARIES(SimpleDisparityMapEstimationExample OTBFeatureExtraction OTBCommon OTBIO ITKCommon
ITKIO)
ADD_EXECUTABLE(NCCRegistrationFilterExample NCCRegistrationFilterExample.cxx )
TARGET_LINK_LIBRARIES(NCCRegistrationFilterExample OTBFeatureExtraction OTBCommon OTBIO ITKCommon
ITKIO)
IF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING )
SET(BASELINE ${OTB_DATA_ROOT}/Baseline/Examples/DisparityMap)
......
/*=========================================================================
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
#ifdef __BORLANDC__
#define ITK_LEAN_AND_MEAN
#endif
// Software Guide : BeginCommandLineArgs
// INPUTS: {fixed.tif}, {moving.tif}
// OUTPUTS: {deformationFieldOutput2.png}
// 5 1.0 2
// Software Guide : EndCommandLineArgs
#include "otbImage.h"
#include "otbImageFileWriter.h"
#include "otbImageFileReader.h"
#include "otbNCCRegistrationFilter.h"
#include "otbCommandLineArgumentParser.h"
#include "itkRecursiveGaussianImageFilter.h"
#include <iostream>
int main(int argc, char** argv )
{
const unsigned int ImageDimension = 2;
typedef double PixelType;
typedef itk::Vector<double,ImageDimension> DeformationPixelType;
typedef double CoordinateRepresentationType;
//Allocate Images
typedef otb::Image<PixelType,ImageDimension> MovingImageType;
typedef otb::Image<PixelType,ImageDimension> FixedImageType;
typedef otb::Image<DeformationPixelType,
ImageDimension> DeformationFieldType;
typedef otb::ImageFileReader< FixedImageType > FixedReaderType;
FixedReaderType::Pointer fReader = FixedReaderType::New();
fReader->SetFileName(argv[1]);
typedef otb::ImageFileReader< MovingImageType > MovingReaderType;
MovingReaderType::Pointer mReader = MovingReaderType::New();
mReader->SetFileName(argv[2]);
//Blur input images
typedef itk::RecursiveGaussianImageFilter< FixedImageType,
FixedImageType > FixedBlurType;
FixedBlurType::Pointer fBlur = FixedBlurType::New();
fBlur->SetInput( fReader->GetOutput() );
fBlur->SetSigma( atof(argv[5]) );
typedef itk::RecursiveGaussianImageFilter< MovingImageType,
MovingImageType > MovingBlurType;
MovingBlurType::Pointer mBlur = MovingBlurType::New();
mBlur->SetInput( mReader->GetOutput() );
mBlur->SetSigma( 1.0 );
//Create the filter
typedef otb::NCCRegistrationFilter< FixedImageType,
MovingImageType,
DeformationFieldType >
RegistrationFilterType;
RegistrationFilterType::Pointer registrator = RegistrationFilterType::New();
registrator->SetMovingImage( mBlur->GetOutput() );
registrator->SetFixedImage( fBlur->GetOutput() );
typedef RegistrationFilterType::RadiusType RadiusType;
RadiusType radius;
radius[0] = atoi(argv[4]);
radius[1] = atoi(argv[4]);
registrator->SetNCCRadius( radius );
std::cout << "NCC radius " << registrator->GetNCCRadius() << std::endl;
registrator->SetNumberOfIterations( argv[6] );
registrator->GetDeformationField();
registrator->Update();
typedef otb::ImageFileWriter< DeformationFieldType > DFWriterType;
DFWriterType::Pointer dfWriter = DFWriterType::New();
dfWriter->SetFileName(argv[3]);
dfWriter->SetInput( registrator->GetOutput() );
dfWriter->Update();
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