diff --git a/Testing/Code/DisparityMap/CMakeLists.txt b/Testing/Code/DisparityMap/CMakeLists.txt index 6ee8e7e2d330cddf8a126986e23c080bbf7b8bf7..5edb3457ba530cf17620970554e88d2058180c61 100644 --- a/Testing/Code/DisparityMap/CMakeLists.txt +++ b/Testing/Code/DisparityMap/CMakeLists.txt @@ -113,6 +113,19 @@ ADD_TEST(dmTvNNearestTransformsLinearInterpolateDeformationFieldGenerator ${DISP ${TEMP}/dmTvNNearestTransformsLinearInterpolateDeformationField.hdr ) +# ------- otb::BSplinesInterpolateTransformDeformationFieldGenerator ---------- + +ADD_TEST(dmTuBSplinesInterpolateTransformDeformationFieldGeneratorNew ${DISPARITYMAP_TESTS} + otbBSplinesInterpolateTransformDeformationFieldGeneratorNew) + +ADD_TEST(dmTvBSplinesInterpolateTransformDeformationFieldGenerator ${DISPARITYMAP_TESTS} + --compare-image ${EPSILON} + ${BASELINE}/dmTvBSplinesInterpolateTransformDeformationFieldGenerator.hdr + ${TEMP}/dmTvBSplinesInterpolateTransformDeformationFieldGenerator.hdr + otbBSplinesInterpolateTransformDeformationFieldGenerator + ${TEMP}/dmTvBSplinesInterpolateTransformDeformationFieldGenerator.hdr +) + # ------- Additional tests for deformation fields estimation ---------- ADD_TEST(dmTvTranslationDeformationFieldEstimation ${DISPARITYMAP_TESTS} @@ -249,11 +262,13 @@ otbNNearestTransformsLinearInterpolateDeformationFieldGenerator.cxx otbTranslationDeformationFieldEstimation.cxx otbEuler2DDeformationFieldEstimation.cxx otbCenteredRigidDeformationFieldEstimation.cxx +otbBSplinesInterpolateTransformDeformationFieldGeneratorNew.cxx +otbBSplinesInterpolateTransformDeformationFieldGenerator.cxx ) INCLUDE_DIRECTORIES("${OTBTesting_BINARY_DIR}") ADD_EXECUTABLE(otbDisparityMapTests otbDisparityMapTests.cxx ${BasicDisparityMap_SRCS}) -TARGET_LINK_LIBRARIES(otbDisparityMapTests OTBIO OTBDisparityMap gdal ITKIO ITKAlgorithms ITKStatistics ITKCommon) +TARGET_LINK_LIBRARIES(otbDisparityMapTests OTBIO OTBDisparityMap gdal ITKIO ITKAlgorithms ITKStatistics ITKCommon ITKNumerics itkvnl) ENDIF( NOT OTB_DISABLE_CXX_TESTING ) diff --git a/Testing/Code/DisparityMap/otbBSplinesInterpolateTransformDeformationFieldGenerator.cxx b/Testing/Code/DisparityMap/otbBSplinesInterpolateTransformDeformationFieldGenerator.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d62327b32d3c0d612b05208777ea90a46d599322 --- /dev/null +++ b/Testing/Code/DisparityMap/otbBSplinesInterpolateTransformDeformationFieldGenerator.cxx @@ -0,0 +1,135 @@ +/*========================================================================= + + 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 "itkPointSet.h" +#include "otbVectorImage.h" +#include "otbBSplinesInterpolateTransformDeformationFieldGenerator.h" +#include "otbImageFileWriter.h" +#include "itkEuler2DTransform.h" + +int otbBSplinesInterpolateTransformDeformationFieldGenerator(int argc, char * argv[]) +{ + try + { + const unsigned int Dimension = 2; + const char * outfname = argv[1]; + typedef double PixelType; + typedef otb::VectorImage<PixelType,Dimension> ImageType; + typedef itk::Array<double> ParamType; + typedef itk::PointSet<ParamType,Dimension> PointSetType; + typedef PointSetType::PointType PointType; + typedef otb::BSplinesInterpolateTransformDeformationFieldGenerator<PointSetType,ImageType> FilterType; + typedef otb::ImageFileWriter<ImageType> WriterType; + typedef itk::Euler2DTransform<double> TransformType; + + ImageType::SizeType size; + size.Fill(100); + double thresh = 0.9; + + // Preparing point set + PointSetType::Pointer ps = PointSetType::New(); + PointType p1,p2,p3,p4,p5; + ParamType pd1(6),pd2(6),pd3(6),pd4(6),pd5(6); + itk::Point<double,2> center; + + p1[0] = 10; + p1[1] = 10; + p2[0] = 75; + p2[1] = 10; + p3[0] = 50; + p3[1] = 50; + p4[0] = 10; + p4[1] = 60; + p5[0] = 85; + p5[1] = 70; + center.Fill(50); + + pd1[0] = 0.95; + pd1[1] = 0; + pd1[2] = 0; + pd1[3] = 0.03925; + pd1[4] = 5; + pd1[5] = 5; + pd2[0] = 0.98; + pd2[1] = 0; + pd2[2] = 0; + pd2[3] = -0.03925; + pd2[4] = 5; + pd2[5] = -5; + pd3[0] = 0.5; + pd3[1] = 0; + pd3[2] = 0; + pd3[3] = 0; + pd3[4] = 0; + pd3[5] = 0; + pd4[0] = 0.91; + pd4[1] = 0; + pd4[2] = 0; + pd4[3] = 0.03925 ; + pd4[4] = -5; + pd4[5] = 5; + pd5[0] = 0.91; + pd5[1] = 0; + pd5[2] = 0; + pd5[3] = -0.03925 ; + pd5[4] = -5; + pd5[5] = -5; + + + ps->SetPoint(0,p1); + ps->SetPointData(0,pd1); + ps->SetPoint(1,p2); + ps->SetPointData(1,pd2); + ps->SetPoint(2,p3); + ps->SetPointData(2,pd3); + ps->SetPoint(3,p4); + ps->SetPointData(3,pd4); + ps->SetPoint(4,p5); + ps->SetPointData(4,pd5); + + TransformType::Pointer transform = TransformType::New(); + transform->SetCenter(center); + + // Instantiating object + FilterType::Pointer filter = FilterType::New(); + filter->SetOutputSize(size); + filter->SetMetricThreshold(thresh); + filter->SetPointSet(ps); + filter->SetTransform(transform); + filter->AddAngularParameter(0); + + WriterType::Pointer writer = WriterType::New(); + writer->SetInput(filter->GetOutput()); + writer->SetFileName(outfname); + writer->Update(); + } + + 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; + } + return EXIT_SUCCESS; +} diff --git a/Testing/Code/DisparityMap/otbBSplinesInterpolateTransformDeformationFieldGeneratorNew.cxx b/Testing/Code/DisparityMap/otbBSplinesInterpolateTransformDeformationFieldGeneratorNew.cxx new file mode 100644 index 0000000000000000000000000000000000000000..b61060075f95c4c2334259221025d496939ad39f --- /dev/null +++ b/Testing/Code/DisparityMap/otbBSplinesInterpolateTransformDeformationFieldGeneratorNew.cxx @@ -0,0 +1,51 @@ +/*========================================================================= + + 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 "itkPointSet.h" +#include "otbVectorImage.h" +#include "otbBSplinesInterpolateTransformDeformationFieldGenerator.h" + +int otbBSplinesInterpolateTransformDeformationFieldGeneratorNew(int argc, char * argv[]) +{ + try + { + const unsigned int Dimension = 2; + typedef double PixelType; + typedef otb::VectorImage<PixelType,Dimension> ImageType; + typedef itk::Array<double> ParametersType; + typedef itk::PointSet<ParametersType,Dimension> PointSetType; + typedef otb::BSplinesInterpolateTransformDeformationFieldGenerator<PointSetType,ImageType> FilterType; + + // Instantiating object + 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; + } + return EXIT_SUCCESS; +} diff --git a/Testing/Code/DisparityMap/otbDisparityMapTests.cxx b/Testing/Code/DisparityMap/otbDisparityMapTests.cxx index 196aa8f00443edfa10a4f5187db9e385002d3595..a678c27431c6202893f0ec15f0d7f23e7d29d55b 100644 --- a/Testing/Code/DisparityMap/otbDisparityMapTests.cxx +++ b/Testing/Code/DisparityMap/otbDisparityMapTests.cxx @@ -40,6 +40,8 @@ REGISTER_TEST(otbNearestTransformDeformationFieldGeneratorNew); REGISTER_TEST(otbNearestTransformDeformationFieldGenerator); REGISTER_TEST(otbNNearestTransformsLinearInterpolateDeformationFieldGeneratorNew); REGISTER_TEST(otbNNearestTransformsLinearInterpolateDeformationFieldGenerator); +REGISTER_TEST(otbBSplinesInterpolateTransformDeformationFieldGeneratorNew); +REGISTER_TEST(otbBSplinesInterpolateTransformDeformationFieldGenerator); REGISTER_TEST(otbTranslationDeformationFieldEstimation); REGISTER_TEST(otbEuler2DDeformationFieldEstimation); REGISTER_TEST(otbCenteredRigidDeformationFieldEstimation); diff --git a/Utilities/InsightJournal/ijBSplineKernelFunction.h b/Utilities/InsightJournal/ijBSplineKernelFunction.h index 121e0f34f1a2575f1c244bc0d6808157e9c8d557..e2a2e233b5b71fbde6b18dea22a0081870eac2c5 100755 --- a/Utilities/InsightJournal/ijBSplineKernelFunction.h +++ b/Utilities/InsightJournal/ijBSplineKernelFunction.h @@ -83,7 +83,7 @@ public: { which = static_cast< int>( absValue ); } - if ( which < this->m_BSplineShapeFunctions.rows() ) + if ( which < static_cast<int>(this->m_BSplineShapeFunctions.rows()) ) { return PolynomialType( this->m_BSplineShapeFunctions.get_row( which ) ).evaluate( absValue ); diff --git a/Utilities/InsightJournal/ijBSplineScatteredDataPointSetToImageFilter.txx b/Utilities/InsightJournal/ijBSplineScatteredDataPointSetToImageFilter.txx index bc2982ae889ad2dcce24d9c27cce30722843448e..212475fd932e182744bb07399355011803322ee3 100755 --- a/Utilities/InsightJournal/ijBSplineScatteredDataPointSetToImageFilter.txx +++ b/Utilities/InsightJournal/ijBSplineScatteredDataPointSetToImageFilter.txx @@ -360,7 +360,7 @@ BSplineScatteredDataPointSetToImageFilter<TInputPointSet, TOutputImage> for ( unsigned int j = 0; j < ImageDimension; j++ ) { tmp[j] = idx[j] + off[j]; - if ( tmp[j] >= NumberOfNewControlPoints[j] && !this->m_CloseDimension[j] ) + if ( tmp[j] >= static_cast<int>(NumberOfNewControlPoints[j]) && !this->m_CloseDimension[j] ) { OutOfBoundary = true; break; @@ -375,7 +375,7 @@ BSplineScatteredDataPointSetToImageFilter<TInputPointSet, TOutputImage> continue; } - for ( unsigned int j = 0; j < N; j++ ) + for ( int j = 0; j < N; j++ ) { off_Psi = this->IndexToSubscript( j, size_Psi ); @@ -383,7 +383,7 @@ BSplineScatteredDataPointSetToImageFilter<TInputPointSet, TOutputImage> for ( unsigned int k = 0; k < ImageDimension; k++ ) { tmp_Psi[k] = idx_Psi[k] + off_Psi[k]; - if ( tmp_Psi[k] >= this->m_CurrentNumberOfControlPoints[k] + if ( tmp_Psi[k] >= static_cast<int>(this->m_CurrentNumberOfControlPoints[k]) && !this->m_CloseDimension[k] ) { OutOfBoundary = true;