diff --git a/CMakeLists.txt b/CMakeLists.txt index 446765a35fdae193ac299ef1cad09b6774fc4804..321fcfe4c922ea4bb640031ac7aa02b943a6f257 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,15 +67,24 @@ SET(OTB_VERSION_STRING "${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}.${OTB_VERSION_ # => Comment for OTB 2.6.0 -#OPTION(BUILD_TESTING "Build testing." OFF) +OPTION(BUILD_TESTING "Build testing." OFF) +#----------------------------------------------------------------------------- +# OTB build configuration options. +IF(WIN32) +# do not build shared lib under windows +SET(BUILD_SHARED_LIBS OFF) +MESSAGE("Disabling build shared lib option on windows like OS.") +ELSE(WIN32) +OPTION(BUILD_SHARED_LIBS "Build OTB with shared libraries." ON) +ENDIF(WIN32) +SET(OTB_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) #----------------------------------------------------------------------------- # Case for release 2.2.1 # Use the openjpeg library. OPTION(OTB_USE_JPEG2000 "Use to support jpeg2000 image file format." ON) -#MARK_AS_ADVANCED(OTB_USE_JPEG2000) #----------------------------------------------------------------------------- @@ -88,19 +97,13 @@ OPTION(OTB_USE_JPEG2000 "Use to support jpeg2000 image file format." ON) OPTION(OTB_USE_EXTERNAL_EXPAT "Use an outside build of EXPAT." OFF) MARK_AS_ADVANCED(OTB_USE_EXTERNAL_EXPAT) -#SET(OTB_COMPILE_EXPAT ${OTB_USE_EXTERNAL_EXPAT}) + IF(OTB_USE_EXTERNAL_EXPAT) FIND_PACKAGE(EXPAT) IF(EXPAT_FOUND) # Control expat compatibility INCLUDE_DIRECTORIES(BEFORE ${EXPAT_INCLUDE_DIR}) LINK_DIRECTORIES( ${EXPAT_LIBRARY} ) -# TRY_COMPILE(OTB_TYPE_COMPILE_EXPAT -# ${OTB_BINARY_DIR}/CMakeTmp -# ${OTB_SOURCE_DIR}/CMake/otbTestCompileExpat.cxx ) -# IF( NOT OTB_TYPE_COMPILE_EXPAT) -# SET(OTB_USE_EXTERNAL_EXPAT OFF) -# ENDIF( NOT OTB_TYPE_COMPILE_EXPAT) ELSE(EXPAT_FOUND) MESSAGE(FATAL_ERROR "Cannot build OTB project without lib EXPAT. Please set EXPAT_DIR or set OTB_USE_EXTERNAL_EXPAT OFF to use INTERNAL EXPAT set on OTB/Utilities repository.") @@ -210,7 +213,7 @@ IF(OTB_USE_VISU_GUI) IF( NOT OPENGL_FOUND ) MESSAGE(FATAL_ERROR "Impossible to find OpenGL on your system.\nCannot build OTB Visu module without OpenGL library.\nInstall OpenGL on your system OR set OTB_USE_VISU to OFF to disable OTB Visu module generation !") - ENDIF( NOT OPENGL_FOUND ) + ENDIF( NOT OPENGL_FOUND ) IF( NOT OPENGL_GLU_FOUND ) MESSAGE(FATAL_ERROR "Impossible to find GLU library on your system.\nCannot build OTB Visu module without GLU library.\nInstall GLU library on your system OR set OTB_USE_VISU to OFF to disable OTB Visu module generation !") ENDIF( NOT OPENGL_GLU_FOUND ) @@ -218,17 +221,6 @@ IF(OTB_USE_VISU_GUI) IF(OPENGL_INCLUDE_DIR) INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR}) ENDIF(OPENGL_INCLUDE_DIR) - -# INCLUDE(CheckIncludeFiles) -# CHECK_INCLUDE_FILES("GL/glu.h" HAVE_GL_GLU_H) -# IF ( NOT HAVE_GL_GLU_H ) -# FIND_PATH(OTB_GLU_INCLUDE_PATH "GL/glu.h" ${OPENGL_INCLUDE_PATH}) -# IF(NOT OTB_GLU_INCLUDE_PATH) -# SET(OTB_GLU_INCLUDE_PATH "") -# MESSAGE("Impossible to find GLU files (include lib), detected by the FIND_PACKAGE(OpenGL) command.\nCannot build OTB Visu module without GLU library.\n=> You must install GLU (Mesa package, etc.) on your system OR set OTB_USE_VISU to OFF to disable OTB Visu module generation !") -# ENDIF(NOT OTB_GLU_INCLUDE_PATH) -# ENDIF ( NOT HAVE_GL_GLU_H ) - #------------------------------- # FLTK Library @@ -281,17 +273,6 @@ OPTION(OTB_USE_CURL "Use curl library." OFF) MARK_AS_ADVANCED(OTB_USE_CURL) IF(OTB_USE_CURL) -# INCLUDE(CheckIncludeFiles) -# INCLUDE(CheckLibraryExists) -# CHECK_INCLUDE_FILES("curl/curl.h" OTB_HAVE_CURL_HEADER) -# CHECK_LIBRARY_EXISTS("curl" "curl_easy_init" "" OTB_HAVE_CURL_LIBRARY) -# IF( NOT OTB_HAVE_CURL_HEADER ) -# MESSAGE("Cannot find CURL include directory. Please set CURL_INCLUDE_DIRS or SET OTB_USE_CURL OFF.") -# ENDIF( NOT OTB_HAVE_CURL_HEADER) -# IF( NOT OTB_HAVE_CURL_LIBRARY ) -# MESSAGE("Cannot find CURL include directory. Please set CURL_LIBRARY_DIRS or SET OTB_USE_CURL OFF.") -# ENDIF( NOT OTB_HAVE_CURL_LIBRARY) - FIND_PATH(CURL_INCLUDE_DIR curl/curl.h PATHS) MARK_AS_ADVANCED(CURL_INCLUDE_DIR) IF (NOT CURL_INCLUDE_DIR) @@ -442,20 +423,6 @@ INCLUDE_DIRECTORIES( ${OTB_LIBRARY_PATH} ) # Put "." in the rpath of all OTB shared libraries. LINK_DIRECTORIES(.) -#----------------------------------------------------------------------------- -# OTB build configuration options. -OPTION(BUILD_SHARED_LIBS "Build OTB with shared libraries." ON) -SET(OTB_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) - -# => Comment for OTB 2.6.0 -# Options for building some of the most common core templates explicitly only -# once. This has only been tested on gcc compilers. -# OPTION(OTB_EXPLICIT_INSTANTIATION "BETA-Try to explicitly build some of the core templates explictitly rather than over and over again." OFF) -# MARK_AS_ADVANCED(OTB_EXPLICIT_INSTANTIATION) -# IF( OTB_EXPLICIT_INSTANTIATION ) -# ADD_DEFINITIONS(-DOTB_EXPLICIT_INSTANTIATION) -# ENDIF( OTB_EXPLICIT_INSTANTIATION ) - #----------------------------------------------------------------------------- # Option for display all developpment message !!! OPTION(OTB_SHOW_ALL_MSG_DEBUG "OTB developers : Show all messages (debug, dev, etc...) use only for otb developers." OFF) @@ -500,21 +467,10 @@ INCLUDE(${OTB_SOURCE_DIR}/Wrapping/otbWrapSetup.cmake) OPTION(OTB_USE_PATENTED "Build patented examples. ITK must be genereted whith patented option (ITK_USE_PATENTED = ON)." OFF) MARK_AS_ADVANCED(OTB_USE_PATENTED) - -IF(WIN32) - IF(BUILD_SHARED_LIBS) - SET(OTB_COMMON_BUILD_TYPE "SHARED") - ELSE(BUILD_SHARED_LIBS) - SET(OTB_COMMON_BUILD_TYPE "STATIC") - ENDIF(BUILD_SHARED_LIBS) - SET(BUILD_SHARED_LIBS OFF) -ENDIF(WIN32) - - IF(OTB_USE_VISU_GUI) SET(OTB_VISU_GUI_LIBRARIES "${FLTK_LIBRARIES};${OPENGL_LIBRARIES};${FLTK_PLATFORM_DEPENDENT_LIBS}") IF(APPLE) - SET(OTB_VISU_GUI_LIBRARIES "${OTB_VISU_GUI_LIBRARIES} -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib ") + SET(OTB_VISU_GUI_LIBRARIES "${OTB_VISU_GUI_LIBRARIES};-Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib") ENDIF(APPLE) ELSE(OTB_USE_VISU_GUI) SET(OTB_VISU_GUI_LIBRARIES "") @@ -528,9 +484,7 @@ ENDIF(OTB_USE_VISU_GUI) # Use OTB_ALLS_UTILITIES_DEPENDENT_LIBRARIES to LINK Utilities Algo libraries into your executable # => Create OTB_IO_UTILITIES_DEPENDENT_LIBRARIES -#SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES "gdal dxf otbkml tinyXML otbgeotiff otbxtiff otbossim otbossimBase otbossimElevation otbossimFont otbossimKBool otbossimMatrix otbossimPlugin otbossimProjectionImaging otbossimSupportData otbossimVec otbossimVpfUtil") SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES "gdal;dxf;tinyXML;otbgeotiff;otbxtiff;otbossim" ) -#otbossimBase otbossimElevation otbossimFont otbossimKBool otbossimMatrix otbossimPlugin otbossimProjectionImaging otbossimSupportData otbossimVec otbossimVpfUtil") IF(NOT OTB_USE_EXTERNAL_OPENTHREADS) SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES "${OTB_IO_UTILITIES_DEPENDENT_LIBRARIES};${OPENTHREADS_LIBRARY}") @@ -548,12 +502,6 @@ IF( OTB_COMPILE_JPEG2000 ) SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES "${OTB_IO_UTILITIES_DEPENDENT_LIBRARIES};otbopenjpeg") ENDIF( OTB_COMPILE_JPEG2000 ) - -# Add VISU libraries -#IF(OTB_USE_VISU_GUI) -# SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES "${OTB_IO_UTILITIES_DEPENDENT_LIBRARIES} ${OTB_VISU_GUI_LIBRARIES}") -#ENDIF(OTB_USE_VISU_GUI) - # => Create OTB_ALGO_UTILITIES_DEPENDENT_LIBRARIES SET(OTB_ALGO_UTILITIES_DEPENDENT_LIBRARIES "otb6S;otbgalib;InsightJournal;otbsvm") @@ -588,63 +536,10 @@ SET(OTB_REQUIRED_C_FLAGS "${ITK_REQUIRED_C_FLAGS}") SET(OTB_REQUIRED_CXX_FLAGS "${ITK_REQUIRED_CXX_FLAGS}") SET(OTB_REQUIRED_LINK_FLAGS "${ITK_REQUIRED_LINK_FLAGS}") -# IF(CMAKE_COMPILER_IS_GNUCXX) -# SET(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} -ftemplate-depth-50") -# IF(APPLE) -# SET(OTB_REQUIRED_C_FLAGS "${OTB_REQUIRED_C_FLAGS} -no-cpp-precomp") -# SET(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} -no-cpp-precomp") -# SET(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} -Wno-long-double") -# ENDIF(APPLE) -# ENDIF(CMAKE_COMPILER_IS_GNUCXX) - -# IF(UNIX) -# IF(NOT CMAKE_COMPILER_IS_GNUCXX) -# INCLUDE(${OTB_SOURCE_DIR}/CMake/TestNO_ICC_IDYNAMIC_NEEDED.cmake) -# TESTNO_ICC_IDYNAMIC_NEEDED(NO_ICC_IDYNAMIC_NEEDED ${OTB_SOURCE_DIR}/CMake ) -# IF(NO_ICC_IDYNAMIC_NEEDED) -# SET(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS}") -# ELSE(NO_ICC_IDYNAMIC_NEEDED) -# SET(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} -i_dynamic") -# ENDIF(NO_ICC_IDYNAMIC_NEEDED) -# ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX) -# ENDIF(UNIX) - -# Force the use of ansi cxx flags (i.e. -LANG:std on sgi ) -# IF("x${CMAKE_ANSI_CXXFLAGS}" MATCHES "^x.*[^ ]") -# SET(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} ${CMAKE_ANSI_CXXFLAGS}") -# ENDIF("x${CMAKE_ANSI_CXXFLAGS}" MATCHES "^x.*[^ ]") -# IF("x${CMAKE_ANSI_CFLAGS}" MATCHES "^x.*[^ ]") -# SET(OTB_REQUIRED_C_FLAGS "${OTB_REQUIRED_C_FLAGS} ${CMAKE_ANSI_CFLAGS}") -# ENDIF("x${CMAKE_ANSI_CFLAGS}" MATCHES "^x.*[^ ]") - -# IF(CMAKE_SYSTEM MATCHES "IRIX.*") -# IF(NOT CMAKE_COMPILER_IS_GNUCXX) -# SET(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} -woff 15,84,1110,1209,1424,1468,3102,3210,3439 -no_auto_include -ptused -no_prelink") -# SET(OTB_REQUIRED_LINK_FLAGS "${OTB_REQUIRED_LINK_FLAGS} -Wl,-woff15") -# ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX) -# ENDIF(CMAKE_SYSTEM MATCHES "IRIX.*") - IF(MINGW) LINK_LIBRARIES(gdi32) ENDIF(MINGW) -# for the gnu compiler a -D_PTHREADS is needed on sun -# for the native compiler a -mt flag is needed on the sun -# IF(CMAKE_USE_PTHREADS) -# IF(CMAKE_SYSTEM MATCHES "SunOS.*") -# IF(CMAKE_COMPILER_IS_GNUCXX) -# SET(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} -D_PTHREADS") -# ELSE(CMAKE_COMPILER_IS_GNUCXX) -# SET(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} -mt") -# SET(OTB_REQUIRED_C_FLAGS "${OTB_REQUIRED_C_FLAGS} -mt") -# ENDIF(CMAKE_COMPILER_IS_GNUCXX) -# ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*") -# ENDIF(CMAKE_USE_PTHREADS) - -# IF(WIN32) -# SET(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} -DNOMINMAX") -# ENDIF(WIN32) - #----------------------------------------------------------------------------- # Test for an Objective-C++ compiler. SET(OTB_OBJCXX_COMPILER_WORKS 0) @@ -663,45 +558,8 @@ IF(APPLE) "the following output:\n${OTB_OBJCXX_TRY_COMPILE_OUTPUT}\n\n") ENDIF( OTB_OBJCXX_COMPILER_WORKS ) ENDIF(APPLE) -#----------------------------------------------------------------------------- -# mingw thread support -# IF(MINGW) -# SET(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} -mthreads") -# SET(OTB_REQUIRED_C_FLAGS "${OTB_REQUIRED_C_FLAGS} -mthreads") -# SET(OTB_REQUIRED_LINK_FLAGS "${OTB_REQUIRED_LINK_FLAGS} -mthreads") -# ENDIF(MINGW) - - -#----------------------------------------------------------------------------- -# => Comment for OTB 2.6.0 -# -# See if compiler preprocessor has the __FUNCTION__ directive used by itkExceptionMacro -# -# INCLUDE(${OTB_SOURCE_DIR}/CMake/CheckCPPDirective.cmake) -# CHECK_CPP_DIRECTIVE_EXISTS(__FUNCTION__ ITK_CPP_FUNCTION) -#----------------------------------------------------------------------------- -# => Comment for OTB 2.6.0 -# Find platform-specific differences in the handling of IEEE floating point -# special values. -# INCLUDE(${OTB_SOURCE_DIR}/CMake/CheckBigBitfield.cmake) -# CHECK_BIG_BITFIELD(BIGBITFIELD_VALUE ${OTB_SOURCE_DIR}/CMake) -# IF(BIGBITFIELD_VALUE) -# SET(BIGBITFIELD 1 CACHE INTERNAL "System handles bit-fields larger than 32 bits.") -# ELSE(BIGBITFIELD_VALUE) -# SET(BIGBITFIELD 0 CACHE INTERNAL "System handles bit-fields larger than 32 bits.") -# ENDIF(BIGBITFIELD_VALUE) - -# => Comment for OTB 2.6.0 -# INCLUDE(${OTB_SOURCE_DIR}/CMake/TestQnanhibit.cmake) -# TEST_QNANHIBIT(QNANHIBIT_VALUE ${OTB_SOURCE_DIR}/CMake) -# IF(QNANHIBIT_VALUE) -# SET(QNANHIBIT 1 CACHE INTERNAL "The 22nd bit of 32-bit floating-point quiet NaN.") -# ELSE(QNANHIBIT_VALUE) -# SET(QNANHIBIT 0 CACHE INTERNAL "The 22nd bit of 32-bit floating-point quiet NaN.") -# ENDIF(QNANHIBIT_VALUE) - INCLUDE(CheckTypeSize) CHECK_TYPE_SIZE("long long" OTB_SIZEOF_LONG_LONG) @@ -709,74 +567,6 @@ CHECK_TYPE_SIZE("__int64" OTB_SIZEOF___INT64) CHECK_TYPE_SIZE("long int" OTB_SIZEOF_LONG_INT) CHECK_TYPE_SIZE("short int" OTB_SIZEOF_SHORT_INT) -# => Comment for OTB 2.6.0 -# IF(OTB_SIZEOF___INT64) -# IF("OTB_TYPE_SAME_LONG_AND___INT64" MATCHES "^OTB_TYPE_SAME_LONG_AND___INT64$") -# MESSAGE(STATUS "Checking whether long and __int64 are the same type") -# TRY_COMPILE(OTB_TYPE_SAME_LONG_AND___INT64 -# ${OTB_BINARY_DIR}/CMakeTmp -# ${OTB_SOURCE_DIR}/CMake/otbTestCompareTypes.cxx -# COMPILE_DEFINITIONS -# -DOTB_TEST_COMPARE_TYPE_1=long -# -DOTB_TEST_COMPARE_TYPE_2=__int64 -# OUTPUT_VARIABLE OUTPUT) -# IF(OTB_TYPE_SAME_LONG_AND___INT64) -# MESSAGE(STATUS "Checking whether long and __int64 are the same type -- yes") -# SET(OTB_TYPE_SAME_LONG_AND___INT64 1 CACHE INTERNAL "Whether long and __int64 are the same type") -# ELSE(OTB_TYPE_SAME_LONG_AND___INT64) -# MESSAGE(STATUS "Checking whether long and __int64 are the same type -- no") -# SET(OTB_TYPE_SAME_LONG_AND___INT64 0 CACHE INTERNAL "Whether long and __int64 are the same type") -# WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeError.log -# "Determining whether long and __int64 are the same type " -# "failed with the following output:\n" -# "${OUTPUT}\n" APPEND) -# ENDIF(OTB_TYPE_SAME_LONG_AND___INT64) -# ENDIF("OTB_TYPE_SAME_LONG_AND___INT64" MATCHES "^OTB_TYPE_SAME_LONG_AND___INT64$") -# ENDIF(OTB_SIZEOF___INT64) -# IF(OTB_SIZEOF_LONG_LONG) -# CONFIGURE_FILE(${OTB_SOURCE_DIR}/CMake/otbTestStreamLongLong.cxx.in -# ${OTB_BINARY_DIR}/otbTestStreamLongLong.cxx @ONLY IMMEDIATE) -# IF("OTB_OSTREAM_SUPPORTS_LONG_LONG" MATCHES "^OTB_OSTREAM_SUPPORTS_LONG_LONG$") -# MESSAGE(STATUS "Checking if ostream supports long long") -# TRY_COMPILE(OTB_OSTREAM_SUPPORTS_LONG_LONG -# ${OTB_BINARY_DIR} -# ${OTB_BINARY_DIR}/otbTestStreamLongLong.cxx -# COMPILE_DEFINITIONS -DOTB_TEST_OSTREAM_LONG_LONG -# OUTPUT_VARIABLE OUTPUT) -# IF(OTB_OSTREAM_SUPPORTS_LONG_LONG) -# MESSAGE(STATUS "Checking if ostream supports long long -- yes") -# SET(OTB_OSTREAM_SUPPORTS_LONG_LONG 1 CACHE INTERNAL "Whether ostream supports long long") -# ELSE(OTB_OSTREAM_SUPPORTS_LONG_LONG) -# MESSAGE(STATUS "Checking if ostream supports long long -- no") -# SET(OTB_OSTREAM_SUPPORTS_LONG_LONG 0 CACHE INTERNAL "Whether ostream supports long long") -# WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeError.log -# "Determining if ostream supports long long " -# "failed with the following output:\n" -# "${OUTPUT}\n" APPEND) -# ENDIF(OTB_OSTREAM_SUPPORTS_LONG_LONG) -# ENDIF("OTB_OSTREAM_SUPPORTS_LONG_LONG" MATCHES "^OTB_OSTREAM_SUPPORTS_LONG_LONG$") -# IF("OTB_ISTREAM_SUPPORTS_LONG_LONG" MATCHES "^OTB_ISTREAM_SUPPORTS_LONG_LONG$") -# MESSAGE(STATUS "Checking if istream supports long long") -# TRY_COMPILE(OTB_ISTREAM_SUPPORTS_LONG_LONG -# ${OTB_BINARY_DIR} -# ${OTB_BINARY_DIR}/otbTestStreamLongLong.cxx -# COMPILE_DEFINITIONS -DOTB_TEST_ISTREAM_LONG_LONG -# OUTPUT_VARIABLE OUTPUT) -# IF(OTB_ISTREAM_SUPPORTS_LONG_LONG) -# MESSAGE(STATUS "Checking if istream supports long long -- yes") -# SET(OTB_ISTREAM_SUPPORTS_LONG_LONG 1 CACHE INTERNAL "Whether istream supports long long") -# ELSE(OTB_ISTREAM_SUPPORTS_LONG_LONG) -# MESSAGE(STATUS "Checking if istream supports long long -- no") -# SET(OTB_ISTREAM_SUPPORTS_LONG_LONG 0 CACHE INTERNAL "Whether istream supports long long") -# WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeError.log -# "Determining if istream supports long long " -# "failed with the following output:\n" -# "${OUTPUT}\n" APPEND) -# ENDIF(OTB_ISTREAM_SUPPORTS_LONG_LONG) -# ENDIF("OTB_ISTREAM_SUPPORTS_LONG_LONG" MATCHES "^OTB_ISTREAM_SUPPORTS_LONG_LONG$") -# ENDIF(OTB_SIZEOF_LONG_LONG) - - #----------------------------------------------------------------------------- # Configure the default OTB_DATA_ROOT for the location of OTB Data. FIND_PATH(OTB_DATA_ROOT OTBData.readme $ENV{OTB_DATA_ROOT}) @@ -845,22 +635,3 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OTB_REQUIRED_CXX_FLAGS}") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OTB_REQUIRED_LINK_FLAGS}") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OTB_REQUIRED_LINK_FLAGS}") SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${OTB_REQUIRED_LINK_FLAGS}") - -#----------------------------------------------------------------------------- -# => Comment for OTB 2.6.0 -# The frename-registers option does not work due to a bug in the gnu compiler. -# It must be removed or data errors will be produced and incorrect results -# will be produced. This is first documented in the gcc4 man page. -# IF(CMAKE_COMPILER_IS_GNUCXX) -# SET(ALL_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS} ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}" ) -# SEPARATE_ARGUMENTS(ALL_FLAGS) -# FOREACH(COMP_OPTION ${ALL_FLAGS}) -# # MESSAGE("${COMP_OPTION} being checked.") -# IF("${COMP_OPTION}" STREQUAL "-frename-registers") -# MESSAGE(FATAL_ERROR "-frename-registers causes runtime bugs. It must be removed from your compilation options.") -# ENDIF("${COMP_OPTION}" STREQUAL "-frename-registers") -# IF("${COMP_OPTION}" STREQUAL "-ffloat-store") -# MESSAGE(FATAL_ERROR "-ffloat-store causes runtime bugs on gcc 3.2.3 (appearently not on gcc 3.4.3, but the exact criteria is not known). It must be removed from your compilation options.") -# ENDIF("${COMP_OPTION}" STREQUAL "-ffloat-store") -# ENDFOREACH(COMP_OPTION) -# ENDIF(CMAKE_COMPILER_IS_GNUCXX) diff --git a/CTestConfig.cmake b/CTestConfig.cmake new file mode 100644 index 0000000000000000000000000000000000000000..e804438c206776b8c42a8314f664bd093157992c --- /dev/null +++ b/CTestConfig.cmake @@ -0,0 +1,12 @@ +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") diff --git a/Code/BasicFilters/otbBSplineInterpolateImageFunction.txx b/Code/BasicFilters/otbBSplineInterpolateImageFunction.txx index a377371794c11bacab6c196686498df0cb1f06f8..438bf2127b47e167c17e53759d6689f7c7f93aee 100755 --- a/Code/BasicFilters/otbBSplineInterpolateImageFunction.txx +++ b/Code/BasicFilters/otbBSplineInterpolateImageFunction.txx @@ -64,17 +64,12 @@ void BSplineInterpolateImageFunction<TImageType,TCoordRep,TCoefficientType> ::UpdateCoefficientsFilter(void) { - if(!m_CoefficientFilter->GetInput()->GetBufferedRegion().IsInside(m_CurrentBufferedRegion)) - { - //std::cout<<"Updating coefs filter"<<std::endl; m_CoefficientFilter->GetOutput()->UpdateOutputInformation(); m_CoefficientFilter->GetOutput()->SetRequestedRegion(m_CoefficientFilter->GetInput()->GetBufferedRegion()); m_CoefficientFilter->GetOutput()->PropagateRequestedRegion(); m_CoefficientFilter->GetOutput()->UpdateOutputData(); m_Coefficients = m_CoefficientFilter->GetOutput(); - //std::cout<<"Updated region: "<<m_CoefficientFilter->GetInput()->GetBufferedRegion()<<std::endl; - } - m_CurrentBufferedRegion =m_CoefficientFilter->GetInput()->GetBufferedRegion(); + m_CurrentBufferedRegion =m_CoefficientFilter->GetInput()->GetBufferedRegion(); } template <class TImageType, class TCoordRep, class TCoefficientType> void @@ -83,15 +78,13 @@ BSplineInterpolateImageFunction<TImageType,TCoordRep,TCoefficientType> { if ( inputData ) { - m_CoefficientFilter->SetInput(inputData); + m_CoefficientFilter->SetInput(inputData); // the Coefficient Filter requires that the spline order and the input data be set. // TODO: We need to ensure that this is only run once and only after both input and // spline order have been set. Should we force an update after the // splineOrder has been set also? - - UpdateCoefficientsFilter(); // Call the Superclass implementation after, in case the filter diff --git a/Code/BasicFilters/otbGaborFilterGenerator.h b/Code/BasicFilters/otbGaborFilterGenerator.h index 194ffa4c6eba37ad2b665c292f9c806d7059c384..ce1fc9b757034e90b9b4b4ba0e14c5f18b7afa92 100644 --- a/Code/BasicFilters/otbGaborFilterGenerator.h +++ b/Code/BasicFilters/otbGaborFilterGenerator.h @@ -18,8 +18,8 @@ PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef _otbGaborFilterGenerator_h -#define _otbGaborFilterGenerator_h +#ifndef __otbGaborFilterGenerator_h +#define __otbGaborFilterGenerator_h #include "itkObject.h" #include "itkObjectFactory.h" diff --git a/Code/BasicFilters/otbGaborFilterGenerator.txx b/Code/BasicFilters/otbGaborFilterGenerator.txx index c271286d8c6fc356ef6f34881064d74a6ce4ce55..c4dc923850f3a12824a175fe97bbc90bc137b95f 100644 --- a/Code/BasicFilters/otbGaborFilterGenerator.txx +++ b/Code/BasicFilters/otbGaborFilterGenerator.txx @@ -18,8 +18,8 @@ PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef _otbGaborFilterGenerator_txx -#define _otbGaborFilterGenerator_txx +#ifndef __otbGaborFilterGenerator_txx +#define __otbGaborFilterGenerator_txx #include "otbMath.h" diff --git a/Code/BasicFilters/otbMeanShiftImageFilter.h b/Code/BasicFilters/otbMeanShiftImageFilter.h index 564566f412e6120c19965d41382a3c9e6a0bf38d..96720e484d36e3a4f5c5ccfef7d0bb8ce5d01723 100644 --- a/Code/BasicFilters/otbMeanShiftImageFilter.h +++ b/Code/BasicFilters/otbMeanShiftImageFilter.h @@ -15,8 +15,8 @@ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef _otbMeanShiftImageFilter_h -#define _otbMeanShiftImageFilter_h +#ifndef __otbMeanShiftImageFilter_h +#define __otbMeanShiftImageFilter_h #include "otbMeanShiftImageFilterBase.h" diff --git a/Code/BasicFilters/otbMeanShiftImageFilter.txx b/Code/BasicFilters/otbMeanShiftImageFilter.txx index f91b892ca59d15729d2019c95c80530c8b8c2e5e..d40a9ae9350c4d14559758fffda67a8c12a50fa6 100644 --- a/Code/BasicFilters/otbMeanShiftImageFilter.txx +++ b/Code/BasicFilters/otbMeanShiftImageFilter.txx @@ -15,8 +15,8 @@ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef _otbMeanShiftImageFilter_txx -#define _otbMeanShiftImageFilter_txx +#ifndef __otbMeanShiftImageFilter_txx +#define __otbMeanShiftImageFilter_txx #include "otbMeanShiftImageFilter.h" diff --git a/Code/BasicFilters/otbMeanShiftImageFilterBase.h b/Code/BasicFilters/otbMeanShiftImageFilterBase.h index 7e263c1bef124c2812ba87785a6092fe1ee56212..6ecbb7fda0c7ab82fccee7e263c9c841588e0d02 100644 --- a/Code/BasicFilters/otbMeanShiftImageFilterBase.h +++ b/Code/BasicFilters/otbMeanShiftImageFilterBase.h @@ -15,8 +15,8 @@ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef _otbMeanShiftImageFilterBase_h -#define _otbMeanShiftImageFilterBase_h +#ifndef __otbMeanShiftImageFilterBase_h +#define __otbMeanShiftImageFilterBase_h #include "itkImageToImageFilter.h" #include "itkVariableLengthVector.h" diff --git a/Code/BasicFilters/otbMeanShiftImageFilterBase.txx b/Code/BasicFilters/otbMeanShiftImageFilterBase.txx index 8e502e06f432c003b5d0da69796f62d14ce2d6bd..cc11a150dea3baf7f2a76e750d2a8435fca195b7 100644 --- a/Code/BasicFilters/otbMeanShiftImageFilterBase.txx +++ b/Code/BasicFilters/otbMeanShiftImageFilterBase.txx @@ -15,8 +15,8 @@ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef _otbMeanShiftImageFilterBase_txx -#define _otbMeanShiftImageFilterBase_txx +#ifndef __otbMeanShiftImageFilterBase_txx +#define __otbMeanShiftImageFilterBase_txx #include "otbMeanShiftImageFilterBase.h" diff --git a/Code/BasicFilters/otbMeanShiftVectorImageFilter.h b/Code/BasicFilters/otbMeanShiftVectorImageFilter.h index 6280dd65c1ec4fc39f5ce9287c0bad514f0a2eee..dfef1b48c02654b0025a84743a2d8b770523f58a 100644 --- a/Code/BasicFilters/otbMeanShiftVectorImageFilter.h +++ b/Code/BasicFilters/otbMeanShiftVectorImageFilter.h @@ -15,8 +15,8 @@ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef _otbMeanShiftVectorImageFilter_h -#define _otbMeanShiftVectorImageFilter_h +#ifndef __otbMeanShiftVectorImageFilter_h +#define __otbMeanShiftVectorImageFilter_h #include "otbMeanShiftImageFilterBase.h" diff --git a/Code/BasicFilters/otbMeanShiftVectorImageFilter.txx b/Code/BasicFilters/otbMeanShiftVectorImageFilter.txx index 4786260d9d19cc9b2e09c6c5dea14d856abb175b..4753ed724b9350dd7caa6cdf84a248225b731f00 100644 --- a/Code/BasicFilters/otbMeanShiftVectorImageFilter.txx +++ b/Code/BasicFilters/otbMeanShiftVectorImageFilter.txx @@ -15,8 +15,8 @@ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef _otbMeanShiftVectorImageFilter_txx -#define _otbMeanShiftVectorImageFilter_txx +#ifndef __otbMeanShiftVectorImageFilter_txx +#define __otbMeanShiftVectorImageFilter_txx #include "otbMeanShiftVectorImageFilter.h" diff --git a/Code/BasicFilters/otbOverlapSaveConvolutionImageFilter.txx b/Code/BasicFilters/otbOverlapSaveConvolutionImageFilter.txx index 1341491c7e38f34ecf43fb9533be7e678acc223f..246179c6ffa90e419016a540d00c2459726ca991 100755 --- a/Code/BasicFilters/otbOverlapSaveConvolutionImageFilter.txx +++ b/Code/BasicFilters/otbOverlapSaveConvolutionImageFilter.txx @@ -15,8 +15,8 @@ PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef _otbOverlapSaveConvolutionImageFilter_txx -#define _otbOverlapSaveConvolutionImageFilter_txx +#ifndef __otbOverlapSaveConvolutionImageFilter_txx +#define __otbOverlapSaveConvolutionImageFilter_txx #include "otbOverlapSaveConvolutionImageFilter.h" diff --git a/Code/BasicFilters/otbStreamingShrinkImageFilter.txx b/Code/BasicFilters/otbStreamingShrinkImageFilter.txx index 833b50a734a88f7317490efb24d4ffefe7d700c6..c8231b7c1e5c526232657e278dfb37cf8f3b6d6f 100644 --- a/Code/BasicFilters/otbStreamingShrinkImageFilter.txx +++ b/Code/BasicFilters/otbStreamingShrinkImageFilter.txx @@ -72,7 +72,7 @@ StreamingShrinkImageFilter<TInputImage, TOutputImage> for (unsigned int i = 0; i < OutputImageType::ImageDimension; i++) { outputSpacing[i] = inputSpacing[i] * static_cast<double>( m_ShrinkFactor); - outputSize[i] = inputSize[i]/m_ShrinkFactor; + outputSize[i] = static_cast<int>( static_cast<double>(inputSize[i])/static_cast<double>( m_ShrinkFactor )) ; //outputStartIndex[i] = inputStartIndex[i]; outputStartIndex[i]=0; } diff --git a/Code/Common/otbPolyLineParametricPathWithValue.h b/Code/Common/otbPolyLineParametricPathWithValue.h index fe6376c5de076f7504dd797ab135d2727b2929ed..01eb8923020773bc250f6b44af474fd294efe8b2 100644 --- a/Code/Common/otbPolyLineParametricPathWithValue.h +++ b/Code/Common/otbPolyLineParametricPathWithValue.h @@ -55,7 +55,7 @@ class ITK_EXPORT PolyLineParametricPathWithValue typedef typename Superclass::VertexType VertexType; typedef typename Superclass::VertexListType VertexListType; typedef typename Superclass::ContinuousIndexType ContinuousIndexType; - typedef typename VertexListType::ConstIterator VertexListIteratorType; + typedef typename VertexListType::ConstIterator VertexListConstIteratorType; itkGetMacro(Key,std::string); diff --git a/Code/Common/otbPolygon.h b/Code/Common/otbPolygon.h index 0b7b5a0fb32a9311e84bb7312a8497208af69593..dc817e068653b1c4000e535a86e1a31bd4c178d1 100644 --- a/Code/Common/otbPolygon.h +++ b/Code/Common/otbPolygon.h @@ -57,7 +57,7 @@ class ITK_EXPORT Polygon typedef typename Superclass::VertexType VertexType; typedef typename Superclass::VertexListType VertexListType; typedef typename Superclass::ContinuousIndexType ContinuousIndexType; - typedef typename Superclass::VertexListIteratorType VertexListIteratorType; + typedef typename Superclass::VertexListConstIteratorType VertexListConstIteratorType; typedef itk::ImageRegion<2> RegionType; typedef typename RegionType::SizeType SizeType; diff --git a/Code/Common/otbPolygon.txx b/Code/Common/otbPolygon.txx index 4ba530997bd1a0cef9e206dc34a2a4097ed2c7fb..039e48ce2b35d56ebfbae3806dc1498bef75b2e2 100644 --- a/Code/Common/otbPolygon.txx +++ b/Code/Common/otbPolygon.txx @@ -36,7 +36,7 @@ Polygon<TValue> double x = point[0]; double y = point[1]; unsigned int crossingCount = 0; - VertexListIteratorType it = this->GetVertexList()->Begin(); + VertexListConstIteratorType it = this->GetVertexList()->Begin(); double xa = it.Value()[0]; double ya = it.Value()[1]; ++it; @@ -117,7 +117,7 @@ Polygon<TValue> double x = point[0]; double y = point[1]; double xb,yb; - VertexListIteratorType it = this->GetVertexList()->Begin(); + VertexListConstIteratorType it = this->GetVertexList()->Begin(); double xa = it.Value()[0]; double ya = it.Value()[1]; double xbegin = xa; @@ -201,8 +201,8 @@ Polygon<TValue> ::NbCrossing(VertexType a, VertexType b) { unsigned int resp = 0; - VertexListIteratorType it = this->GetVertexList()->Begin(); - VertexListIteratorType it_end = this->GetVertexList()->End(); + VertexListConstIteratorType it = this->GetVertexList()->Begin(); + VertexListConstIteratorType it_end = this->GetVertexList()->End(); VertexType current = it.Value(); VertexType first = current; ++it; @@ -235,8 +235,8 @@ Polygon<TValue> ::NbTouching(VertexType a, VertexType b) { unsigned int resp = 0; - VertexListIteratorType it = this->GetVertexList()->Begin(); - VertexListIteratorType it_end = this->GetVertexList()->End(); + VertexListConstIteratorType it = this->GetVertexList()->Begin(); + VertexListConstIteratorType it_end = this->GetVertexList()->End(); VertexType current = it.Value(); VertexType first = current; ++it; @@ -426,7 +426,7 @@ Polygon<TValue> IndexType maxId; maxId.Fill(0); - VertexListIteratorType it = this->GetVertexList()->Begin(); + VertexListConstIteratorType it = this->GetVertexList()->Begin(); long int x,y; @@ -483,7 +483,7 @@ template<class TValue> ::GetSurface() { m_Surface = 0.0; - VertexListIteratorType it = this->GetVertexList()->Begin(); + VertexListConstIteratorType it = this->GetVertexList()->Begin(); if(this->GetVertexList()->Size()>2) { diff --git a/Code/DisparityMap/otbMIRegistrationFilter.h b/Code/DisparityMap/otbMIRegistrationFilter.h new file mode 100644 index 0000000000000000000000000000000000000000..b3937073dc12d89153b6ea829585d046b5d6c0a6 --- /dev/null +++ b/Code/DisparityMap/otbMIRegistrationFilter.h @@ -0,0 +1,126 @@ +#ifndef _otbMIRegistrationFilter_h_ +#define _otbMIRegistrationFilter_h_ + +#include "itkPDEDeformableRegistrationFilter.h" +#include "itkMIRegistrationFunction.h" + +namespace otb { + +/** \class MIRegistrationFilter + * \brief Deformably register two images using the PDEs and Mutual Information. + * + * MIRegistrationFilter implements the ####### + * register two images by computing the deformation field which will map a + * moving image onto a fixed image. + * + * A deformation field is represented as a image whose pixel type is some + * vector type with at least N elements, where N is the dimension of + * the fixed image. The vector type must support element access via operator + * []. It is assumed that the vector elements behave like floating point + * scalars. + * + * This class is templated over the fixed image type, moving image type + * and the deformation field type. + * + * The input fixed and moving images are set via methods SetFixedImage + * and SetMovingImage respectively. An initial deformation field maybe set via + * SetInitialDeformationField or SetInput. If no initial field is set, + * a zero field is used as the initial condition. + * + * The algorithm has one parameter: the number of iteration to be performed. + * + * The output deformation field can be obtained via methods GetOutput + * or GetDeformationField. + * + * This class make use of the finite difference solver hierarchy. Update + * for each iteration is computed in MIRegistrationFunction. + * + * \warning This filter assumes that the fixed image type, moving image type + * and deformation field type all have the same number of dimensions. + * + * \sa MIRegistrationFunction + * \ingroup DeformableImageRegistration MultiThreaded + */ +template<class TFixedImage, class TMovingImage, class TDeformationField> +class ITK_EXPORT MIRegistrationFilter : + public itk::PDEDeformableRegistrationFilter< TFixedImage, TMovingImage, + TDeformationField> +{ +public: + /** Standard class typedefs. */ + typedef MIRegistrationFilter Self; + typedef itk::PDEDeformableRegistrationFilter< + TFixedImage, TMovingImage,TDeformationField> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro( MIRegistrationFilter, + itk::PDEDeformableRegistrationFilter ); + + /** Inherit types from superclass. */ + typedef typename Superclass::TimeStepType TimeStepType; + + /** FixedImage image type. */ + typedef typename Superclass::FixedImageType FixedImageType; + typedef typename Superclass::FixedImagePointer FixedImagePointer; + + /** MovingImage image type. */ + typedef typename Superclass::MovingImageType MovingImageType; + typedef typename Superclass::MovingImagePointer MovingImagePointer; + + /** Deformation field type. */ + typedef typename Superclass::DeformationFieldType + DeformationFieldType; + typedef typename Superclass::DeformationFieldPointer + DeformationFieldPointer; + + /** FiniteDifferenceFunction type. */ + typedef typename Superclass::FiniteDifferenceFunctionType + FiniteDifferenceFunctionType; + + /** MIRegistrationFilterFunction type. */ + typedef itk::MIRegistrationFunction<FixedImageType,MovingImageType, + DeformationFieldType> MIRegistrationFunctionType; + + typedef typename MIRegistrationFunctionType::RadiusType RadiusType; + + /** Get the metric value. The metric value is computed over the the + * overlapping region between the two images. This is value is only + * available for the previous iteration and NOT the current + * iteration. */ + virtual double GetMetric() const; + + + virtual void SetMIRadius(RadiusType radius); + virtual RadiusType GetMIRadius() const; + +protected: + MIRegistrationFilter(); + ~MIRegistrationFilter() {} + void PrintSelf(std::ostream& os, itk::Indent indent) const; + + /** Initialize the state of filter and equation before each iteration. */ + virtual void InitializeIteration(); + + /** Apply update. */ + virtual void ApplyUpdate(TimeStepType dt); + +private: + MIRegistrationFilter(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + + +}; + + +} // end namespace otb + +#ifndef ITK_MANUAL_INSTANTIATION +#include "otbMIRegistrationFilter.txx" +#endif + +#endif diff --git a/Code/DisparityMap/otbMIRegistrationFilter.txx b/Code/DisparityMap/otbMIRegistrationFilter.txx new file mode 100644 index 0000000000000000000000000000000000000000..17928f0489af553a99da337301780301381db490 --- /dev/null +++ b/Code/DisparityMap/otbMIRegistrationFilter.txx @@ -0,0 +1,176 @@ +#ifndef _otbMIRegistrationFilter_txx +#define _otbMIRegistrationFilter_txx +#include "otbMIRegistrationFilter.h" + +namespace otb { + +/* + * Default constructor + */ +template <class TFixedImage, class TMovingImage, class TDeformationField> +MIRegistrationFilter<TFixedImage,TMovingImage,TDeformationField> +::MIRegistrationFilter() +{ + + typename MIRegistrationFunctionType::Pointer drfp; + drfp = MIRegistrationFunctionType::New(); + + drfp->SetDeformationField( this->GetDeformationField() ); + + this->SetDifferenceFunction( static_cast<FiniteDifferenceFunctionType *>( + drfp.GetPointer() ) ); + +} + + +template <class TFixedImage, class TMovingImage, class TDeformationField> +void +MIRegistrationFilter<TFixedImage,TMovingImage,TDeformationField> +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf( os, indent ); + os << indent << "MI Radius: " << + this->GetMIRadius() << std::endl; +} + + +/* + * Set the function state values before each iteration + */ +template <class TFixedImage, class TMovingImage, class TDeformationField> +void +MIRegistrationFilter<TFixedImage,TMovingImage,TDeformationField> +::InitializeIteration() +{ + + // call the superclass implementation + Superclass::InitializeIteration(); + + // set the gradient selection flag + MIRegistrationFunctionType *drfp = + dynamic_cast<MIRegistrationFunctionType *> + (this->GetDifferenceFunction().GetPointer()); + + if( !drfp ) + { + itkExceptionMacro( << + "Could not cast difference function to MIRegistrationFunction" ); + } + + /* + * Smooth the deformation field + */ + if ( this->GetSmoothDeformationField() ) + { + this->SmoothDeformationField(); + } + +} + + +/* + * Get the metric value from the difference function + */ +template <class TFixedImage, class TMovingImage, class TDeformationField> +double +MIRegistrationFilter<TFixedImage,TMovingImage,TDeformationField> +::GetMetric() const +{ + + MIRegistrationFunctionType *drfp = + dynamic_cast<MIRegistrationFunctionType *> + (this->GetDifferenceFunction().GetPointer()); + + if( !drfp ) + { + itkExceptionMacro( << + "Could not cast difference function to MIRegistrationFunction" ); + } + + return drfp->GetEnergy(); + +} + + +/* + * + */ +template <class TFixedImage, class TMovingImage, class TDeformationField> +typename MIRegistrationFilter<TFixedImage,TMovingImage,TDeformationField>::RadiusType +MIRegistrationFilter<TFixedImage,TMovingImage,TDeformationField> +::GetMIRadius() const +{ + + MIRegistrationFunctionType *drfp = + dynamic_cast<MIRegistrationFunctionType *> + (this->GetDifferenceFunction().GetPointer()); + + if( !drfp ) + { + itkExceptionMacro( << + "Could not cast difference function to MIRegistrationFunction" ); + } + + return drfp->GetRadius(); + +} + +/* + * + */ +template <class TFixedImage, class TMovingImage, class TDeformationField> +void +MIRegistrationFilter<TFixedImage,TMovingImage,TDeformationField> +::SetMIRadius(RadiusType radius) +{ + + MIRegistrationFunctionType *drfp = + dynamic_cast<MIRegistrationFunctionType *> + (this->GetDifferenceFunction().GetPointer()); + + if( !drfp ) + { + itkExceptionMacro( << + "Could not cast difference function to MIRegistrationFunction" ); + } + + drfp->SetRadius(radius); + +} + +/* + * Get the metric value from the difference function + */ +template <class TFixedImage, class TMovingImage, class TDeformationField> +void +MIRegistrationFilter<TFixedImage,TMovingImage,TDeformationField> +::ApplyUpdate(TimeStepType dt) +{ + // If we smooth the update buffer before applying it, then the are + // approximating a viscuous problem as opposed to an elastic problem + if ( this->GetSmoothUpdateField() ) + { + this->SmoothUpdateField(); + } + + this->Superclass::ApplyUpdate(dt); + + MIRegistrationFunctionType *drfp = + dynamic_cast<MIRegistrationFunctionType *> + (this->GetDifferenceFunction().GetPointer()); + + if( !drfp ) + { + itkExceptionMacro( << + "Could not cast difference function to MIRegistrationFunction" ); + } + +// this->SetRMSChange( drfp->GetRMSChange() ); + +} + + + +} // end namespace otb + +#endif diff --git a/Code/DisparityMap/otbNCCRegistrationFilter.h b/Code/DisparityMap/otbNCCRegistrationFilter.h new file mode 100644 index 0000000000000000000000000000000000000000..a0070832220d7866ded251ffd6bb1b6208f5c79b --- /dev/null +++ b/Code/DisparityMap/otbNCCRegistrationFilter.h @@ -0,0 +1,126 @@ +#ifndef _otbNCCRegistrationFilter_h_ +#define _otbNCCRegistrationFilter_h_ + +#include "itkPDEDeformableRegistrationFilter.h" +#include "itkNCCRegistrationFunction.h" + +namespace otb { + +/** \class NCCRegistrationFilter + * \brief Deformably register two images using the PDEs and NCC. + * + * NCCRegistrationFilter implements the ####### + * register two images by computing the deformation field which will map a + * moving image onto a fixed image. + * + * A deformation field is represented as a image whose pixel type is some + * vector type with at least N elements, where N is the dimension of + * the fixed image. The vector type must support element access via operator + * []. It is assumed that the vector elements behave like floating point + * scalars. + * + * This class is templated over the fixed image type, moving image type + * and the deformation field type. + * + * The input fixed and moving images are set via methods SetFixedImage + * and SetMovingImage respectively. An initial deformation field maybe set via + * SetInitialDeformationField or SetInput. If no initial field is set, + * a zero field is used as the initial condition. + * + * The algorithm has one parameter: the number of iteration to be performed. + * + * The output deformation field can be obtained via methods GetOutput + * or GetDeformationField. + * + * This class make use of the finite difference solver hierarchy. Update + * for each iteration is computed in NCCRegistrationFunction. + * + * \warning This filter assumes that the fixed image type, moving image type + * and deformation field type all have the same number of dimensions. + * + * \sa NCCRegistrationFunction + * \ingroup DeformableImageRegistration MultiThreaded + */ +template<class TFixedImage, class TMovingImage, class TDeformationField> +class ITK_EXPORT NCCRegistrationFilter : + public itk::PDEDeformableRegistrationFilter< TFixedImage, TMovingImage, + TDeformationField> +{ +public: + /** Standard class typedefs. */ + typedef NCCRegistrationFilter Self; + typedef itk::PDEDeformableRegistrationFilter< + TFixedImage, TMovingImage,TDeformationField> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro( NCCRegistrationFilter, + itk::PDEDeformableRegistrationFilter ); + + /** Inherit types from superclass. */ + typedef typename Superclass::TimeStepType TimeStepType; + + /** FixedImage image type. */ + typedef typename Superclass::FixedImageType FixedImageType; + typedef typename Superclass::FixedImagePointer FixedImagePointer; + + /** MovingImage image type. */ + typedef typename Superclass::MovingImageType MovingImageType; + typedef typename Superclass::MovingImagePointer MovingImagePointer; + + /** Deformation field type. */ + typedef typename Superclass::DeformationFieldType + DeformationFieldType; + typedef typename Superclass::DeformationFieldPointer + DeformationFieldPointer; + + /** FiniteDifferenceFunction type. */ + typedef typename Superclass::FiniteDifferenceFunctionType + FiniteDifferenceFunctionType; + + /** NCCRegistrationFilterFunction type. */ + typedef itk::NCCRegistrationFunction<FixedImageType,MovingImageType, + DeformationFieldType> NCCRegistrationFunctionType; + + typedef typename NCCRegistrationFunctionType::RadiusType RadiusType; + + /** Get the metric value. The metric value is computed over the the + * overlapping region between the two images. This is value is only + * available for the previous iteration and NOT the current + * iteration. */ + virtual double GetMetric() const; + + + virtual void SetNCCRadius(RadiusType radius); + virtual RadiusType GetNCCRadius() const; + +protected: + NCCRegistrationFilter(); + ~NCCRegistrationFilter() {} + void PrintSelf(std::ostream& os, itk::Indent indent) const; + + /** Initialize the state of filter and equation before each iteration. */ + virtual void InitializeIteration(); + + /** Apply update. */ + virtual void ApplyUpdate(TimeStepType dt); + +private: + NCCRegistrationFilter(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + + +}; + + +} // end namespace otb + +#ifndef ITK_MANUAL_INSTANTIATION +#include "otbNCCRegistrationFilter.txx" +#endif + +#endif diff --git a/Code/DisparityMap/otbNCCRegistrationFilter.txx b/Code/DisparityMap/otbNCCRegistrationFilter.txx new file mode 100644 index 0000000000000000000000000000000000000000..cd7633b6defc331d54d42a5b09a3a8bed86f8845 --- /dev/null +++ b/Code/DisparityMap/otbNCCRegistrationFilter.txx @@ -0,0 +1,176 @@ +#ifndef _otbNCCRegistrationFilter_txx +#define _otbNCCRegistrationFilter_txx +#include "otbNCCRegistrationFilter.h" + +namespace otb { + +/* + * Default constructor + */ +template <class TFixedImage, class TMovingImage, class TDeformationField> +NCCRegistrationFilter<TFixedImage,TMovingImage,TDeformationField> +::NCCRegistrationFilter() +{ + + typename NCCRegistrationFunctionType::Pointer drfp; + drfp = NCCRegistrationFunctionType::New(); + + drfp->SetDeformationField( this->GetDeformationField() ); + + this->SetDifferenceFunction( static_cast<FiniteDifferenceFunctionType *>( + drfp.GetPointer() ) ); + +} + + +template <class TFixedImage, class TMovingImage, class TDeformationField> +void +NCCRegistrationFilter<TFixedImage,TMovingImage,TDeformationField> +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf( os, indent ); + os << indent << "NCC Radius: " << + this->GetNCCRadius() << std::endl; +} + + +/* + * Set the function state values before each iteration + */ +template <class TFixedImage, class TMovingImage, class TDeformationField> +void +NCCRegistrationFilter<TFixedImage,TMovingImage,TDeformationField> +::InitializeIteration() +{ + + // call the superclass implementation + Superclass::InitializeIteration(); + + // set the gradient selection flag + NCCRegistrationFunctionType *drfp = + dynamic_cast<NCCRegistrationFunctionType *> + (this->GetDifferenceFunction().GetPointer()); + + if( !drfp ) + { + itkExceptionMacro( << + "Could not cast difference function to NCCRegistrationFunction" ); + } + + /* + * Smooth the deformation field + */ + if ( this->GetSmoothDeformationField() ) + { + this->SmoothDeformationField(); + } + +} + + +/* + * Get the metric value from the difference function + */ +template <class TFixedImage, class TMovingImage, class TDeformationField> +double +NCCRegistrationFilter<TFixedImage,TMovingImage,TDeformationField> +::GetMetric() const +{ + + NCCRegistrationFunctionType *drfp = + dynamic_cast<NCCRegistrationFunctionType *> + (this->GetDifferenceFunction().GetPointer()); + + if( !drfp ) + { + itkExceptionMacro( << + "Could not cast difference function to NCCRegistrationFunction" ); + } + + return drfp->GetEnergy(); + +} + + +/* + * + */ +template <class TFixedImage, class TMovingImage, class TDeformationField> +typename NCCRegistrationFilter<TFixedImage,TMovingImage,TDeformationField>::RadiusType +NCCRegistrationFilter<TFixedImage,TMovingImage,TDeformationField> +::GetNCCRadius() const +{ + + NCCRegistrationFunctionType *drfp = + dynamic_cast<NCCRegistrationFunctionType *> + (this->GetDifferenceFunction().GetPointer()); + + if( !drfp ) + { + itkExceptionMacro( << + "Could not cast difference function to NCCRegistrationFunction" ); + } + + return drfp->GetRadius(); + +} + +/* + * + */ +template <class TFixedImage, class TMovingImage, class TDeformationField> +void +NCCRegistrationFilter<TFixedImage,TMovingImage,TDeformationField> +::SetNCCRadius(RadiusType radius) +{ + + NCCRegistrationFunctionType *drfp = + dynamic_cast<NCCRegistrationFunctionType *> + (this->GetDifferenceFunction().GetPointer()); + + if( !drfp ) + { + itkExceptionMacro( << + "Could not cast difference function to NCCRegistrationFunction" ); + } + + drfp->SetRadius(radius); + +} + +/* + * Get the metric value from the difference function + */ +template <class TFixedImage, class TMovingImage, class TDeformationField> +void +NCCRegistrationFilter<TFixedImage,TMovingImage,TDeformationField> +::ApplyUpdate(TimeStepType dt) +{ + // If we smooth the update buffer before applying it, then the are + // approximating a viscuous problem as opposed to an elastic problem + if ( this->GetSmoothUpdateField() ) + { + this->SmoothUpdateField(); + } + + this->Superclass::ApplyUpdate(dt); + + NCCRegistrationFunctionType *drfp = + dynamic_cast<NCCRegistrationFunctionType *> + (this->GetDifferenceFunction().GetPointer()); + + if( !drfp ) + { + itkExceptionMacro( << + "Could not cast difference function to NCCRegistrationFunction" ); + } + +// this->SetRMSChange( drfp->GetRMSChange() ); + +} + + + +} // end namespace otb + +#endif diff --git a/Code/Gui/CMakeLists.txt b/Code/Gui/CMakeLists.txt index 6f608142cade965deaaaf64342d1f3ce1623de6f..05efe68a95d6cfe3f13d02e66f40d1e8455b9cea 100644 --- a/Code/Gui/CMakeLists.txt +++ b/Code/Gui/CMakeLists.txt @@ -6,7 +6,7 @@ FILE(GLOB OTBGui_SRCS "*.cxx" ) # To suppress "ld: cycle in dylib re-exports with /usr/X11R6/lib/libGL.dylib" error on APPLE and SHARED configuration IF(APPLE AND BUILD_SHARED_LIBS) FOREACH(c "" "_DEBUG" "_RELEASE" "_MINSIZEREL" "_RELWITHDEBINFO") - SET(CMAKE_SHARED_LINKER_FLAGS${c} "${CMAKE_SHARED_LINKER_FLAGS${c}} -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib") + SET(CMAKE_SHARED_LINKER_FLAGS${c} "${CMAKE_SHARED_LINKER_FLAGS${c}};-Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib") ENDFOREACH(c) ENDIF(APPLE AND BUILD_SHARED_LIBS) diff --git a/Code/IO/otbMWImageIO.h b/Code/IO/otbMWImageIO.h index 90187499eaeea298b30596c8f2f70f02597239d5..d7f71500ee402c6da7d447a3e24a1aecfaf976e7 100755 --- a/Code/IO/otbMWImageIO.h +++ b/Code/IO/otbMWImageIO.h @@ -150,7 +150,7 @@ private: std::string m_TypeMW; //used for write itk::ImageIOBase::ByteOrder m_FileByteOrder; std::fstream m_File; - uint m_Ncom; + unsigned int m_Ncom; }; diff --git a/Code/IO/otbRADImageIO.cxx b/Code/IO/otbRADImageIO.cxx index 8aa969fedfbbd29deae49b0649ba39cf0788d29c..6f86c8aa457b6c511088b220c9a4469d5b2e4fd8 100644 --- a/Code/IO/otbRADImageIO.cxx +++ b/Code/IO/otbRADImageIO.cxx @@ -66,7 +66,6 @@ RADImageIO::RADImageIO() m_Origin[1] = 0.0; m_ChannelsFile = NULL; m_FlagWriteImageInformation = true; - } RADImageIO::~RADImageIO() diff --git a/Code/SARPolarimetry/otbPolarimetricData.h b/Code/SARPolarimetry/otbPolarimetricData.h index 9394a62ce2081fb7bf48c9453499c2d0e237e4ed..9fe28e0d939deceb1fe0da5905fc1e99a15476a3 100644 --- a/Code/SARPolarimetry/otbPolarimetricData.h +++ b/Code/SARPolarimetry/otbPolarimetricData.h @@ -15,8 +15,8 @@ PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef _otb_PolarimetricData_h -#define _otb_PolarimetricData_h +#ifndef __otb_PolarimetricData_h +#define __otb_PolarimetricData_h #include "itkDataObject.h" #include "itkObjectFactory.h" diff --git a/Code/SpatialReasoning/otbPolygonToPolygonRCC8Calculator.h b/Code/SpatialReasoning/otbPolygonToPolygonRCC8Calculator.h index d1e0fd8d70d4d76919646e45fb305ce4a7365b7c..26963401ada00ebaabe46e36088a4c7c50ca81ac 100644 --- a/Code/SpatialReasoning/otbPolygonToPolygonRCC8Calculator.h +++ b/Code/SpatialReasoning/otbPolygonToPolygonRCC8Calculator.h @@ -63,7 +63,7 @@ public: typedef typename PolygonType::ConstPointer PolygonConstPointerType; typedef typename PolygonType::VertexListType VertexListType; typedef typename PolygonType::ContinuousIndexType ContinuousIndexType; - typedef typename VertexListType::ConstIterator VertexListIteratorType; + typedef typename VertexListType::ConstIterator VertexListConstIteratorType; typedef std::vector<bool> BoolVectorType; /** RCC8 values type */ diff --git a/Code/SpatialReasoning/otbPolygonToPolygonRCC8Calculator.txx b/Code/SpatialReasoning/otbPolygonToPolygonRCC8Calculator.txx index c181c72d8a4aa325735b93a0b6334d0e63f96e6e..cabb79f1fd96262a1e4dbe07b42fa9db7df269a1 100644 --- a/Code/SpatialReasoning/otbPolygonToPolygonRCC8Calculator.txx +++ b/Code/SpatialReasoning/otbPolygonToPolygonRCC8Calculator.txx @@ -156,8 +156,8 @@ PolygonToPolygonRCC8Calculator<TInputPolygon> ::ComputeInterExter(PolygonPointerType polygon1, PolygonPointerType polygon2) { bool resp = false; - VertexListIteratorType it = polygon1->GetVertexList()->Begin(); - VertexListIteratorType it_end = polygon1->GetVertexList()->End(); + VertexListConstIteratorType it = polygon1->GetVertexList()->Begin(); + VertexListConstIteratorType it_end = polygon1->GetVertexList()->End(); ContinuousIndexType current = it.Value(); ContinuousIndexType first = current; @@ -213,8 +213,8 @@ PolygonToPolygonRCC8Calculator<TInputPolygon> ::ComputeInterInter(PolygonPointerType polygon1, PolygonPointerType polygon2) { bool resp = false; - VertexListIteratorType it = polygon1->GetVertexList()->Begin(); - VertexListIteratorType it_end = polygon1->GetVertexList()->End(); + VertexListConstIteratorType it = polygon1->GetVertexList()->Begin(); + VertexListConstIteratorType it_end = polygon1->GetVertexList()->End(); ContinuousIndexType current = it.Value(); ContinuousIndexType first = current; bool currentIsInside = polygon2->IsInside(current); @@ -259,8 +259,8 @@ PolygonToPolygonRCC8Calculator<TInputPolygon> ::ComputeEdgeEdge(PolygonPointerType polygon1, PolygonPointerType polygon2) { bool resp = false; - VertexListIteratorType it = polygon1->GetVertexList()->Begin(); - VertexListIteratorType it_end = polygon1->GetVertexList()->End(); + VertexListConstIteratorType it = polygon1->GetVertexList()->Begin(); + VertexListConstIteratorType it_end = polygon1->GetVertexList()->End(); ContinuousIndexType current = it.Value(); resp = polygon2->IsOnEdge(current); diff --git a/Code/Visu/otbImageAlternateViewer.h b/Code/Visu/otbImageAlternateViewer.h index 22f927d2ca784a624c3ff8d0c26332c9f60ee07d..f168e7f872ed6c022fac0047dfef6a279a6eb943 100644 --- a/Code/Visu/otbImageAlternateViewer.h +++ b/Code/Visu/otbImageAlternateViewer.h @@ -23,17 +23,13 @@ PURPOSE. See the above copyright notices for more information. #include "otbImageList.h" #include "itkInterpolateImageFunction.h" #include "itkLinearInterpolateImageFunction.h" -#include "otbBSplineInterpolateImageFunction.h" #include "itkVectorImageToImageAdaptor.h" #include "otbVectorImageToImageListFilter.h" #include "otbImage.h" -#include "itkWindowedSincInterpolateImageFunction.h" -#include "otbWindowedSincInterpolateImageGaussianFunction.h" -#include "otbWindowedSincInterpolateImageHammingFunction.h" -#include "itkZeroFluxNeumannBoundaryCondition.h" + #include <FL/gl.h> #include "itkImageRegionSplitter.h" -#include "otbProlateInterpolateImageFunction.h" + namespace otb { @@ -78,14 +74,6 @@ class ITK_EXPORT ImageAlternateViewer typedef itk::InterpolateImageFunction<SingleImageType,double> InterpolatorType; typedef typename InterpolatorType::Pointer InterpolatorPointerType; typedef itk::LinearInterpolateImageFunction<SingleImageType,double> DefaultInterpolatorType; - typedef BSplineInterpolateImageFunction<SingleImageType,double,double> BSplineInterpolatorType; - - typedef itk::Function::HammingWindowFunction<4> WindowFunctionType; - typedef otb::Function::GaussianWindowFunction<> GaussianWindowType; - typedef itk::ZeroFluxNeumannBoundaryCondition<SingleImageType> ConditionType; - typedef itk::WindowedSincInterpolateImageFunction<SingleImageType,3,WindowFunctionType,ConditionType ,double> WindowedSincInterpolatorType; - typedef WindowedSincInterpolateImageGaussianFunction<SingleImageType,ConditionType> OtbWindowedSincInterpolatorType; - typedef ProlateInterpolateImageFunction<SingleImageType,ConditionType> ProlateInterpolatorType; typedef itk::ImageRegionSplitter<2> SplitterType; typedef typename SplitterType::Pointer SplitterPointerType; @@ -124,6 +112,11 @@ class ITK_EXPORT ImageAlternateViewer itkSetMacro(DisplayExtent,RegionType); itkGetMacro(DisplayExtent,RegionType); + itkGetObjectMacro(ZoomInInterpolator,InterpolatorType); + itkSetObjectMacro(ZoomInInterpolator,InterpolatorType); + itkGetObjectMacro(ZoomOutInterpolator,InterpolatorType); + itkSetObjectMacro(ZoomOutInterpolator,InterpolatorType); + /** * Set view mode to RGB. */ diff --git a/Code/Visu/otbImageAlternateViewer.txx b/Code/Visu/otbImageAlternateViewer.txx index 4a3e672e6e8f65cddd349b1187f1d7f85427cb26..775e962dee7328c46286b6c554ded3bed52c1e95 100644 --- a/Code/Visu/otbImageAlternateViewer.txx +++ b/Code/Visu/otbImageAlternateViewer.txx @@ -51,19 +51,8 @@ namespace otb m_DecompositionFilter = VectorImageDecompositionFilterType::New(); - typename BSplineInterpolatorType::Pointer bsplineInterpolator = BSplineInterpolatorType::New(); - bsplineInterpolator->SetSplineOrder(3); - - typename ProlateInterpolatorType::Pointer prolateInterpolator = ProlateInterpolatorType::New(); - prolateInterpolator->SetRadius(8); - typename OtbWindowedSincInterpolatorType::Pointer otbwinsinc = OtbWindowedSincInterpolatorType::New(); - otbwinsinc->SetRadius(8); - typename DefaultInterpolatorType::Pointer defaultInterpolator = DefaultInterpolatorType::New(); - // m_ZoomInInterpolator = WindowedSincInterpolatorType::New(); m_ZoomInInterpolator=defaultInterpolator; - // m_ZoomInInterpolator=bsplineInterpolator; - m_ZoomOutInterpolator = defaultInterpolator; m_SpacingZoomFactor=1; @@ -202,8 +191,6 @@ namespace otb m_DisplayExtent.SetIndex(index); m_DisplayExtent.SetSize(size); - - //std::cout<<"New display extent: "<<m_DisplayExtent<<std::endl; this->Fl_Gl_Window::resize(x,y,w,h); this->redraw(); } @@ -282,7 +269,6 @@ namespace otb IncrementalOpenGlBufferUpdate(); ResetOpenGlContext(); this->Draw(m_OpenGlBuffer,m_BufferedRegion); - //std::cout<<"Buffered region: "<<m_BufferedRegion<<std::endl; if(!m_Drag) { @@ -306,7 +292,6 @@ namespace otb for(unsigned int i = 0;i<8;++i) { RegionType additionalBufferRegion = GetAdditionalBufferRegion(i); - //std::cout<<"Additional region required: "<<additionalBufferRegion<<std::endl; unsigned char * additionalBuffer = CreateAdditionalBuffer(additionalBufferRegion,m_Image,m_ViewModelIsRGB); this->Draw(additionalBuffer,additionalBufferRegion); bufferList.push_back(additionalBuffer); @@ -334,11 +319,6 @@ namespace otb { this->DrawRegionBoundary(m_SubWindowRegion); } - itk::OStringStream oss; - oss<<"Zoom: "<<m_OpenGlIsotropicZoom<<", scale: "<<m_SpacingZoomFactor; - gl_color(FL_RED); - gl_font(FL_SCREEN_BOLD,10); - gl_draw(oss.str().c_str(),static_cast<int>(m_DisplayExtent.GetIndex()[0])+10,static_cast<int>(m_DisplayExtent.GetIndex()[1])+10); swap_buffers(); glFlush(); } @@ -351,8 +331,6 @@ namespace otb long resp; double x = (point[0]-oldUpperLeft[0])/spacing[0]; double y = (point[1]-oldUpperLeft[1])/spacing[1]; - - //std::cout<<"x: "<<x<<", y: "<<y<<std::endl; if ((vcl_floor(x)!=x)||(vcl_floor(y)!=y)) { @@ -364,7 +342,7 @@ namespace otb } else { - resp = 4*(static_cast<long>(y)*size[0]+static_cast<long>(x)); + resp = 3*(static_cast<long>(y)*size[0]+static_cast<long>(x)); } return resp; @@ -379,8 +357,6 @@ namespace otb IndexType focusOffset; focusOffset[0]=static_cast<long>(static_cast<double>(m_ViewedRegionCenter[0]-m_OldViewedRegionCenter[0])/m_SpacingZoomFactor); focusOffset[1]=static_cast<long>(static_cast<double>(m_ViewedRegionCenter[1]-m_OldViewedRegionCenter[1])/m_SpacingZoomFactor); - - //std::cout<<"Focus offset: "<<focusOffset<<std::endl; IndexType newBufferedRegionIndex; @@ -399,22 +375,14 @@ namespace otb -static_cast<long>(m_BufferedRegion.GetSize()[1]))/2; newBufferedRegionIndex[0]-=focusOffset[0]; newBufferedRegionIndex[1]-=focusOffset[1]; - //std::cout<<"NewBufferedRegionIndex: "<<newBufferedRegionIndex<<std::endl; m_BufferedRegion.SetIndex(newBufferedRegionIndex); - //m_OldViewedRegionCenter = m_ViewedRegionCenter; - - //std::cout<<"New buffered region: "<<m_BufferedRegion<<std::endl; PointType center; m_Image->TransformIndexToPhysicalPoint(m_ViewedRegionCenter,center); - //std::cout<<"Center index: "<<m_ViewedRegionCenter<<std::endl; - //std::cout<<"Center: "<<center<<std::endl; if(m_SpacingZoomFactor != m_OldSpacingZoomFactor) { m_BufferedRegion.Crop(m_DisplayExtent); - //std::cout<<"New buffered region2 "<<m_BufferedRegion<<std::endl; - SpacingType spacing = m_Image->GetSpacing()*m_SpacingZoomFactor; SpacingType oldSpacing = m_Image->GetSpacing()*m_OldSpacingZoomFactor; @@ -435,17 +403,8 @@ namespace otb bufferedUpperLeft[0]=origin[0]+static_cast<double>(m_BufferedRegion.GetIndex()[0])*spacing[0]; bufferedUpperLeft[1]=origin[1]+static_cast<double>(m_BufferedRegion.GetIndex()[1])*spacing[1]; - //std::cout<<"OldBufferedRegion: "<<m_OldBufferedRegion<<std::endl; - //std::cout<<"DisplayExtent: "<<m_DisplayExtent<<std::endl; - //std::cout<<"Center: "<<center<<std::endl; - //std::cout<<"Spacing: "<<spacing<<std::endl; - //std::cout<<"OldSpacing: "<<oldSpacing<<std::endl; - //std::cout<<"BufferedUpperLeft: "<<bufferedUpperLeft<<std::endl; - //std::cout<<"oldBufferedUpperLeft: "<<oldBufferedUpperLeft<<std::endl; - - unsigned char * newBuffer = NULL; - unsigned int bufferLenght = 4*m_BufferedRegion.GetSize()[0]*m_BufferedRegion.GetSize()[1]; + unsigned int bufferLenght = 3*m_BufferedRegion.GetSize()[0]*m_BufferedRegion.GetSize()[1]; newBuffer = new unsigned char[bufferLenght]; typename ImageListType::Pointer bandList; @@ -456,16 +415,18 @@ namespace otb unsigned int numberOfSplits=1; unsigned int optiCount = 0; - - if(m_SpacingZoomFactor>0) + InterpolatorPointerType interpolator; + if(m_SpacingZoomFactor>1) { numberOfSplits=max((static_cast<unsigned int>(m_SpacingZoomFactor))*(static_cast<unsigned int>(m_SpacingZoomFactor)),1U); + interpolator = m_ZoomOutInterpolator; + } + else + { + interpolator = m_ZoomInInterpolator; } unsigned int splitterNumberOfSplits = m_Splitter->GetNumberOfSplits(m_BufferedRegion,numberOfSplits); - - //std::cout<<"numberOfSplits: "<<numberOfSplits<<std::endl; - //std::cout<<"splitterNumberOfSplits: "<<splitterNumberOfSplits<<std::endl; for(unsigned int splitIndex = 0;splitIndex<splitterNumberOfSplits;++splitIndex) { @@ -480,7 +441,6 @@ namespace otb m_RequestedRegion.SetSize(nullSize); m_RequestedRegion.SetIndex(nullIndex); } - //std::cout<<"Requested region: "<<m_RequestedRegion<<std::endl; m_DecompositionFilter = VectorImageDecompositionFilterType::New(); m_DecompositionFilter->SetInput(m_Image); bandList = m_DecompositionFilter->GetOutput(); @@ -513,14 +473,13 @@ namespace otb newBuffer[index] = m_OpenGlBuffer[indexInOldBuffer]; newBuffer[index+1] = m_OpenGlBuffer[indexInOldBuffer+1]; newBuffer[index+2] = m_OpenGlBuffer[indexInOldBuffer+2]; - newBuffer[index+3] = m_OpenGlBuffer[indexInOldBuffer+3]; - index+=4; + index+=3; optiCount++; } else { - m_ZoomInInterpolator->SetInputImage(bandList->GetNthElement(m_RedChannelIndex)); - if( m_ZoomInInterpolator->IsInsideBuffer(interpolatedPos)) + interpolator->SetInputImage(bandList->GetNthElement(m_RedChannelIndex)); + if(interpolator->IsInsideBuffer(interpolatedPos)) { interpolatedValue = static_cast<PixelType>(m_ZoomInInterpolator->Evaluate(interpolatedPos)); } @@ -534,32 +493,30 @@ namespace otb m_ZoomInInterpolator->SetInputImage(bandList->GetNthElement(m_GreenChannelIndex)); if( m_ZoomInInterpolator->IsInsideBuffer(interpolatedPos)) { - interpolatedValue = static_cast<PixelType>( m_ZoomInInterpolator->Evaluate(interpolatedPos)); + interpolatedValue = static_cast<PixelType>(interpolator->Evaluate(interpolatedPos)); } else { interpolatedValue = 0; } newBuffer[index+1] = Normalize(interpolatedValue,m_GreenChannelIndex); - m_ZoomInInterpolator->SetInputImage(bandList->GetNthElement(m_BlueChannelIndex)); - if( m_ZoomInInterpolator->IsInsideBuffer(interpolatedPos)) + interpolator->SetInputImage(bandList->GetNthElement(m_BlueChannelIndex)); + if( interpolator->IsInsideBuffer(interpolatedPos)) { - interpolatedValue = static_cast<PixelType>(m_ZoomInInterpolator->Evaluate(interpolatedPos)); + interpolatedValue = static_cast<PixelType>(interpolator->Evaluate(interpolatedPos)); } else { interpolatedValue = 0; } newBuffer[index+2] = Normalize(interpolatedValue,m_BlueChannelIndex); - newBuffer[index+3] = 255; - index+=4; + index+=3; } else { newBuffer[index+1] = Normalize(interpolatedValue,m_RedChannelIndex); newBuffer[index+2] = Normalize(interpolatedValue,m_RedChannelIndex); - newBuffer[index+3] = 255; - index+=4; + index+=3; } } interpolatedPos[0] +=spacing[0]; @@ -575,10 +532,6 @@ namespace otb m_OldSpacingZoomFactor = m_SpacingZoomFactor; } - //std::cout<<"Optimisation called "<<optiCount<<" times over "<<m_BufferedRegion.GetNumberOfPixels()<<std::endl; - - //std::cout<<"BufferedRegion: "<<m_BufferedRegion<<std::endl; - //std::cout<<"OldBufferedRegion: "<<m_OldBufferedRegion<<std::endl; } template <class TPixel> @@ -664,7 +617,6 @@ namespace otb } region.SetSize(size); region.SetIndex(index); - //std::cout<<"Region "<<part<<": "<<region<<std::endl; return region; } @@ -705,11 +657,6 @@ namespace otb bufferedLowerRight[0]=bufferedUpperLeft[0]+static_cast<double>(m_BufferedRegion.GetSize()[0]-1)*spacing[0]; bufferedLowerRight[1]=bufferedUpperLeft[1]+static_cast<double>(m_BufferedRegion.GetSize()[1]-1)*spacing[1]; - //std::cout<<"UpperLeft: "<<upperLeft<<std::endl; - //std::cout<<"LowerRight: "<<lowerRight<<std::endl; - //std::cout<<"BufferedUpperLeft: "<<bufferedUpperLeft<<std::endl; - //std::cout<<"BufferedLowerRight: "<<bufferedLowerRight<<std::endl; - IndexType lowerRightIndex; IndexType requestedIndex; SizeType requestedSize; @@ -736,7 +683,7 @@ namespace otb total.Start(); unsigned char * result = NULL; - unsigned int bufferLenght = 4*region.GetSize()[0]*region.GetSize()[1]; + unsigned int bufferLenght = 3*region.GetSize()[0]*region.GetSize()[1]; if(bufferLenght == 0) { @@ -749,30 +696,29 @@ namespace otb typename ImageListType::Pointer bandList = m_DecompositionFilter->GetOutput() ; bandList->UpdateOutputInformation(); - //std::cout<<bandList->Size()<<std::endl; - unsigned int index = 0; PixelType interpolatedValue = 0; PointType interpolatedPos; interpolatedPos.Fill(0); unsigned int numberOfSplits=1; - if(m_SpacingZoomFactor>0) + InterpolatorPointerType interpolator; + if(m_SpacingZoomFactor>1) { numberOfSplits=max((static_cast<unsigned int>(m_SpacingZoomFactor))*(static_cast<unsigned int>(m_SpacingZoomFactor)),1U); + interpolator = m_ZoomOutInterpolator; + } + else + { + interpolator = m_ZoomInInterpolator; } unsigned int splitterNumberOfSplits = m_Splitter->GetNumberOfSplits(region,numberOfSplits); - //std::cout<<"ZoomState: "<<m_ZoomState<<std::endl; - //std::cout<<"Number of splits: "<<numberOfSplits<<std::endl; - //std::cout<<"Zoom out number of splits: "<<splitterNumberOfSplits<<std::endl; - SpacingType spacing = image->GetSpacing()*m_SpacingZoomFactor; PointType center; image->TransformIndexToPhysicalPoint(m_ViewedRegionCenter,center); - //std::cout<<"Center(ad): "<<center<<std::endl; PointType origin; origin[0]=center[0]-(static_cast<double>(this->m_DisplayExtent.GetSize()[0])/2-1)*spacing[0]; origin[1]=center[1]-(static_cast<double>(this->m_DisplayExtent.GetSize()[1])/2-1)*spacing[1]; @@ -784,10 +730,7 @@ namespace otb PointType upperLeft; upperLeft[0]=origin[0]+(static_cast<double>(splitRegion.GetIndex()[0]))*spacing[0]; upperLeft[1]=origin[1]+(static_cast<double>(splitRegion.GetIndex()[1]))*spacing[1]; - //std::cout<<"Loop upper left: "<<upperLeft<<std::endl; m_RequestedRegion = ComputeRequestedRegion(splitRegion); - //std::cout<<"Additional requested region: "<<m_RequestedRegion<<std::endl; - //std::cout<<"Largest possible region: "<<image->GetLargestPossibleRegion()<<std::endl; if(!m_RequestedRegion.Crop(image->GetLargestPossibleRegion())) { SizeType nullSize; @@ -797,10 +740,6 @@ namespace otb m_RequestedRegion.SetSize(nullSize); m_RequestedRegion.SetIndex(nullIndex); } - //std::cout<<"Additional cropped requested region: "<<m_RequestedRegion<<std::endl; - - // if(!m_RequestedRegion.IsInside(bandList->GetNthElement(m_RedChannelIndex)->GetBufferedRegion())) - // { m_DecompositionFilter = VectorImageDecompositionFilterType::New(); m_DecompositionFilter->SetInput(image); bandList = m_DecompositionFilter->GetOutput(); @@ -816,7 +755,6 @@ namespace otb bandList->UpdateOutputData(); filter.Stop(); - // } interpolation.Start(); interpolatedPos[1]=upperLeft[1]; @@ -825,11 +763,10 @@ namespace otb interpolatedPos[0]=upperLeft[0]; for(unsigned int i = 0;i<splitRegion.GetSize()[0];++i) { - // //std::cout<<interpolatedPos<<std::endl; - m_ZoomInInterpolator->SetInputImage(bandList->GetNthElement(m_RedChannelIndex)); - if( m_ZoomInInterpolator->IsInsideBuffer(interpolatedPos)) + interpolator->SetInputImage(bandList->GetNthElement(m_RedChannelIndex)); + if( interpolator->IsInsideBuffer(interpolatedPos)) { - interpolatedValue = static_cast<PixelType>(m_ZoomInInterpolator->Evaluate(interpolatedPos)); + interpolatedValue = static_cast<PixelType>(interpolator->Evaluate(interpolatedPos)); } else { @@ -838,35 +775,33 @@ namespace otb result[index] = Normalize(interpolatedValue,m_RedChannelIndex); if(rgb) { - m_ZoomInInterpolator->SetInputImage(bandList->GetNthElement(m_GreenChannelIndex)); - if( m_ZoomInInterpolator->IsInsideBuffer(interpolatedPos)) + interpolator->SetInputImage(bandList->GetNthElement(m_GreenChannelIndex)); + if( interpolator->IsInsideBuffer(interpolatedPos)) { - interpolatedValue = static_cast<PixelType>( m_ZoomInInterpolator->Evaluate(interpolatedPos)); + interpolatedValue = static_cast<PixelType>( interpolator->Evaluate(interpolatedPos)); } else { interpolatedValue = 0; } result[index+1] = Normalize(interpolatedValue,m_GreenChannelIndex); - m_ZoomInInterpolator->SetInputImage(bandList->GetNthElement(m_BlueChannelIndex)); - if( m_ZoomInInterpolator->IsInsideBuffer(interpolatedPos)) + interpolator->SetInputImage(bandList->GetNthElement(m_BlueChannelIndex)); + if( interpolator->IsInsideBuffer(interpolatedPos)) { - interpolatedValue = static_cast<PixelType>(m_ZoomInInterpolator->Evaluate(interpolatedPos)); + interpolatedValue = static_cast<PixelType>(interpolator->Evaluate(interpolatedPos)); } else { interpolatedValue = 0; } result[index+2] = Normalize(interpolatedValue,m_BlueChannelIndex); - result[index+3] = 255; - index+=4; + index+=3; } else { result[index+1] = Normalize(interpolatedValue,m_RedChannelIndex); result[index+2] = Normalize(interpolatedValue,m_RedChannelIndex); - result[index+3] = 255; - index+=4; + index+=3; } interpolatedPos[0] +=spacing[0]; } @@ -877,14 +812,8 @@ namespace otb - // std::cout<<"Last interpolated position: "<<interpolatedPos<<std::endl; - // std::cout<<"Additional buffer built"<<std::endl; interpolation.Stop(); total.Stop(); - // std::cout<<"Profiling:\t"<<std::endl; - // std::cout<<"- Total:\t"<<total.GetMeanTime()<<std::endl; - // std::cout<<"- Filtering:\t\t"<<filter.GetMeanTime()<<"\t"<<filter.GetMeanTime()/total.GetMeanTime()*100<<" %"<<std::endl; - // std::cout<<"- Interpolation:\t"<<interpolation.GetMeanTime()<<"\t\t"<<interpolation.GetMeanTime()/total.GetMeanTime()*100<<" %"<<std::endl; return result; } @@ -905,7 +834,6 @@ namespace otb +(static_cast<double>(Fl::event_x())-static_cast<double>(m_DisplayExtent.GetSize()[0]/2))/m_OpenGlIsotropicZoom); m_OldMousePos[1]= static_cast<long int>(static_cast<double>(m_DisplayExtent.GetSize()[1]/2) +(static_cast<double>(Fl::event_y())-static_cast<double>(m_DisplayExtent.GetSize()[1]/2))/m_OpenGlIsotropicZoom); - // m_OldMousePos[1]= Fl::event_y(); m_Drag=true; m_DragEventCounter=0; @@ -923,7 +851,6 @@ namespace otb case FL_DRAG: { - //std::cout<<"FL_DRAG"<<std::endl; m_Drag=true; int x =static_cast<int>(static_cast<double>(m_DisplayExtent.GetSize()[0]/2) @@ -943,7 +870,6 @@ namespace otb newSize[1]=vcl_abs(y-m_OldMousePos[1]); m_SubWindowRegion.SetIndex(newIndex); m_SubWindowRegion.SetSize(newSize); - //std::cout<<"new subWindowRegion: "<<m_SubWindowRegion<<std::endl; this->redraw(); m_DragEventCounter++; } @@ -968,7 +894,6 @@ namespace otb PointType newCenter; newCenter[0]=origin[0]+static_cast<double>(m_OldMousePos[0]-x+static_cast<long>(this->m_DisplayExtent.GetSize()[0])/2)*spacing[0]; newCenter[1]=origin[1]+static_cast<double>(m_OldMousePos[1]-y+static_cast<long>(this->m_DisplayExtent.GetSize()[1])/2)*spacing[1]; - //std::cout<<"Drag focus offset: "<<m_OldMousePos[0]-x<<", "<<m_OldMousePos[1]-y<<std::endl; m_Image->TransformPhysicalPointToIndex(newCenter,m_ViewedRegionCenter); this->redraw(); m_DragEventCounter++; @@ -986,25 +911,6 @@ namespace otb m_SubWindowMove = false; return 1; } - - case FL_MOUSEWHEEL: - { - int dy = Fl::event_dy(); - m_OldSpacingZoomFactor = m_SpacingZoomFactor; - m_OpenGlIsotropicZoom -=static_cast<double>(dy)/10; - if(m_OpenGlIsotropicZoom>2) - { - m_SpacingZoomFactor/=2; - m_OpenGlIsotropicZoom = 1; - } - else if(m_OpenGlIsotropicZoom<1) - { - m_SpacingZoomFactor*=2; - m_OpenGlIsotropicZoom = 1.9; - } - this->redraw(); - return 1; - } case FL_FOCUS: { return 1; @@ -1015,7 +921,7 @@ namespace otb } case FL_KEYDOWN: { - if(Fl::event_key()==116) // T kye + if(Fl::event_key()==116) // T key { m_SubWindowMode = !m_SubWindowMode; this->redraw(); @@ -1031,7 +937,6 @@ namespace otb ImageAlternateViewer<TPixel> ::MergeBuffersAndFreeMemory(std::vector<unsigned char *> bufferList, std::vector<RegionType> bufferRegionList) { - //std::cout<<"Entering merge method"<<std::endl; if(bufferList.size()!=8 || bufferRegionList.size()!=8) { itkExceptionMacro("Invalid number of additionnal buffers"); @@ -1051,7 +956,7 @@ namespace otb // malloc new buffer - unsigned char * newBuffer = new unsigned char[4*m_DisplayExtent.GetNumberOfPixels()]; + unsigned char * newBuffer = new unsigned char[3*m_DisplayExtent.GetNumberOfPixels()]; // fill the new buffer unsigned int indexInNewBuffer = 0; @@ -1085,7 +990,7 @@ namespace otb { if(bufferList[0]!=NULL) { - for(unsigned int i = 0; i<4*bufferRegionList[0].GetSize()[0];++i) + for(unsigned int i = 0; i<3*bufferRegionList[0].GetSize()[0];++i) { newBuffer[indexInNewBuffer]=bufferList[0][indexInBuffer1]; ++indexInNewBuffer; @@ -1095,7 +1000,7 @@ namespace otb // Fill region 2 if(bufferList[1]!=NULL) { - for(unsigned int i = 0; i<4*bufferRegionList[1].GetSize()[0];++i) + for(unsigned int i = 0; i<3*bufferRegionList[1].GetSize()[0];++i) { newBuffer[indexInNewBuffer]=bufferList[1][indexInBuffer2]; ++indexInNewBuffer; @@ -1105,7 +1010,7 @@ namespace otb // Fill region 3 if(bufferList[2]!=NULL) { - for(unsigned int i = 0; i<4*bufferRegionList[2].GetSize()[0];++i) + for(unsigned int i = 0; i<3*bufferRegionList[2].GetSize()[0];++i) { newBuffer[indexInNewBuffer]=bufferList[2][indexInBuffer3]; ++indexInNewBuffer; @@ -1117,22 +1022,18 @@ namespace otb unsigned int lineOffset = static_cast<unsigned int>(-min(0L,m_BufferedRegion.GetIndex()[0])); unsigned int lineOffsetEnd = static_cast<unsigned int>(-min(0L,static_cast<long>(m_DisplayExtent.GetSize()[0])-m_BufferedRegion.GetIndex()[0]-static_cast<long>(m_BufferedRegion.GetSize()[0]))); unsigned int columnOffset = static_cast<unsigned int>(-min(0L,m_BufferedRegion.GetIndex()[1])); - unsigned int offsety= columnOffset*(static_cast<int>(m_BufferedRegion.GetSize()[0]))*4; - unsigned int offsetx = lineOffset*4; + unsigned int offsety= columnOffset*(static_cast<int>(m_BufferedRegion.GetSize()[0]))*3; + unsigned int offsetx = lineOffset*3; indexInCentralBuffer+=offsety; - //comment std::cout<<"Line offset: "<<lineOffset<<std::endl; - //comment std::cout<<"Line offset end: "<<lineOffsetEnd<<std::endl; - //comment std::cout<<"Column offset: "<<columnOffset<<std::endl; - // For each line for(unsigned int j = 0;j<bufferRegionList[3].GetSize()[1];++j) { //Fill line from region 4 if(bufferList[3]!=NULL) { - for(unsigned int i = 0;i<4*bufferRegionList[3].GetSize()[0];++i) + for(unsigned int i = 0;i<3*bufferRegionList[3].GetSize()[0];++i) { newBuffer[indexInNewBuffer]=bufferList[3][indexInBuffer4]; ++indexInNewBuffer; @@ -1144,18 +1045,18 @@ namespace otb { indexInCentralBuffer+=offsetx; - for(unsigned int i = 0;i<4*bufferRegionList[1].GetSize()[0];++i) + for(unsigned int i = 0;i<3*bufferRegionList[1].GetSize()[0];++i) { newBuffer[indexInNewBuffer]=m_OpenGlBuffer[indexInCentralBuffer]; ++indexInNewBuffer; ++indexInCentralBuffer; } - indexInCentralBuffer+=lineOffsetEnd*4; + indexInCentralBuffer+=lineOffsetEnd*3; } // Fill line from region 5 if(bufferList[4]!=NULL) { - for(unsigned int i = 0;i<4*bufferRegionList[4].GetSize()[0];++i) + for(unsigned int i = 0;i<3*bufferRegionList[4].GetSize()[0];++i) { newBuffer[indexInNewBuffer]=bufferList[4][indexInBuffer5]; ++indexInNewBuffer; @@ -1184,7 +1085,7 @@ namespace otb { if(bufferList[5]!=NULL) { - for(unsigned int i = 0; i<4*bufferRegionList[5].GetSize()[0];++i) + for(unsigned int i = 0; i<3*bufferRegionList[5].GetSize()[0];++i) { newBuffer[indexInNewBuffer]=bufferList[5][indexInBuffer6]; ++indexInNewBuffer; @@ -1194,7 +1095,7 @@ namespace otb // Fill region 2 if(bufferList[6]!=NULL) { - for(unsigned int i = 0; i<4*bufferRegionList[6].GetSize()[0];++i) + for(unsigned int i = 0; i<3*bufferRegionList[6].GetSize()[0];++i) { newBuffer[indexInNewBuffer]=bufferList[6][indexInBuffer7]; ++indexInNewBuffer; @@ -1204,7 +1105,7 @@ namespace otb // Fill region 3 if(bufferList[7]!=NULL) { - for(unsigned int i = 0; i<4*bufferRegionList[7].GetSize()[0];++i) + for(unsigned int i = 0; i<3*bufferRegionList[7].GetSize()[0];++i) { newBuffer[indexInNewBuffer]=bufferList[7][indexInBuffer8]; ++indexInNewBuffer; @@ -1212,8 +1113,6 @@ namespace otb } } } - //std::cout<<"New Buffer size: "<<4*m_DisplayExtent.GetNumberOfPixels()<<", last processed index: "<<indexInNewBuffer-1<<std::endl; - // Free all intermediate buffers typename std::vector<unsigned char *>::iterator it; @@ -1257,8 +1156,6 @@ namespace otb zoomOffsetX = (1-m_OpenGlIsotropicZoom)*(static_cast<double>(m_DisplayExtent.GetSize()[0]/2)-static_cast<double>(region.GetIndex()[0])); zoomOffsetY = (1-m_OpenGlIsotropicZoom)*( static_cast<double>(m_DisplayExtent.GetSize()[1]/2)-static_cast<double>(region.GetIndex()[1])); - // std::cout<<zoomOffsetX<<" "<<zoomOffsetY<<std::endl; - double movex = static_cast<double>(region.GetIndex()[0])+zoomOffsetX; double movey = static_cast<double>(m_DisplayExtent.GetSize()[1])-static_cast<double>(region.GetIndex()[1])-zoomOffsetY; glBitmap(0,0,0,0,movex,movey,NULL); @@ -1268,7 +1165,7 @@ namespace otb // display the image glDrawPixels(region.GetSize()[0], region.GetSize()[1], - GL_RGBA, + GL_RGB, GL_UNSIGNED_BYTE, buffer); glEnd(); @@ -1298,7 +1195,7 @@ namespace otb glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4f(1,0,0,1); + glColor3f(1,0,0); glBegin(GL_LINE_LOOP); glVertex2f(minx,miny); glVertex2f(minx,maxy); @@ -1308,50 +1205,6 @@ namespace otb glDisable(GL_BLEND); } - - - - - - - - // template <class TPixel> - // void - // ImageAlternateViewer<TPixel> - // ::Draw(unsigned char * buffer, RegionType& region) - // { - // if(buffer!=NULL) - // { - // glMatrixMode(GL_TEXTURE); - // glLoadIdentity(); - - // // glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP); - // // glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP); - // // // glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_R,GL_CLAMP); - // // glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE); - - // glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,region.GetSize()[0],region.GetSize()[1],0,GL_RGBA,GL_UNSIGNED_BYTE,buffer); - // //gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA,region.GetSize()[0],region.GetSize()[1],GL_RGBA,GL_UNSIGNED_BYTE,buffer); - // //glEnable(GL_TEXTURE_2D); - // glBegin(GL_QUADS); - // glTexCoord2f(0.,0.); - // glVertex2f(region.GetIndex()[0],region.GetIndex()[1]); - // glTexCoord2f(1.,0.); - // glVertex2f(region.GetIndex()[0]+region.GetSize()[0],region.GetIndex()[1]); - // glTexCoord2f(1.,1.); - // glVertex2f(region.GetIndex()[0]+region.GetSize()[0],region.GetIndex()[1]+region.GetSize()[1]); - // glTexCoord2f(0.,1.); - // glVertex2f(region.GetIndex()[0],region.GetIndex()[1]+region.GetSize()[1]); - // glEnd(); - - // // glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - // // glDisable(GL_TEXTURE_2D); - // // swap_buffers(); - // // ; - // // glFlush(); - // } - // } - template <class TPixel> void ImageAlternateViewer<TPixel> @@ -1374,14 +1227,7 @@ namespace otb glLoadIdentity(); glDisable(GL_BLEND); - // glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); - // glClearColor(0.0f,0.0f,0.0f,0.5f); - // glClearDepth(1.0f); - // glEnable(GL_DEPTH_TEST); - // glDepthFunc(GL_LEQUAL); - // glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST); - } diff --git a/Code/Visu/otbImageViewerBase.h b/Code/Visu/otbImageViewerBase.h index 462d1201405aa26d022eca609449f3604ecce6c6..9af0081bb5583d29ea4ea0ad9f4dbdbf1e851e4e 100644 --- a/Code/Visu/otbImageViewerBase.h +++ b/Code/Visu/otbImageViewerBase.h @@ -155,7 +155,7 @@ namespace otb /// type for the list of the polygon ROI typedef otb::Polygon<LabelType> PolygonType; - typedef typename PolygonType::VertexListIteratorType PolygonIteratorType; + typedef typename PolygonType::VertexListConstIteratorType PolygonIteratorType; typedef otb::ObjectList<PolygonType> PolygonListType; typedef typename PolygonListType::Pointer PolygonListPointerType; typedef typename PolygonListType::Iterator PolygonListIteratorType; @@ -167,7 +167,7 @@ namespace otb typedef std::map<LabelType,ColorType> ROIColorMapType; typedef otb::PolyLineParametricPathWithValue<double,2> PathType; - typedef typename PathType::VertexListIteratorType PathIteratorType; + typedef typename PathType::VertexListConstIteratorType PathIteratorType; typedef otb::ObjectList<PathType> PathListType; typedef typename PathListType::Pointer PathListPointerType; typedef typename PathListType::Iterator PathListIteratorType; diff --git a/Code/Visu/otbImageWidgetPolygonForm.h b/Code/Visu/otbImageWidgetPolygonForm.h index c08a7fc0030779693f9018514454fed9892a3c8c..93fbe1c7f163ba1dc02e57ca9b926df869f4e27e 100644 --- a/Code/Visu/otbImageWidgetPolygonForm.h +++ b/Code/Visu/otbImageWidgetPolygonForm.h @@ -59,7 +59,7 @@ class ITK_EXPORT ImageWidgetPolygonForm typedef typename PolygonType::Pointer PolygonPointerType; typedef typename PolygonType::VertexType VertexType; typedef typename PolygonType::VertexListType VertexListType; - typedef typename VertexListType::ConstIterator VertexListIteratorType; + typedef typename VertexListType::ConstIterator VertexListConstIteratorType; typedef typename PolygonType::ContinuousIndexType ContinuousIndexType; /** Accessors */ diff --git a/Code/Visu/otbImageWidgetPolygonForm.txx b/Code/Visu/otbImageWidgetPolygonForm.txx index bec5d80f7ab374fefb6f6cfb77cee79a54cd3ee8..59b57443c19d73855fad9981ade52e90ac9d4109 100644 --- a/Code/Visu/otbImageWidgetPolygonForm.txx +++ b/Code/Visu/otbImageWidgetPolygonForm.txx @@ -58,7 +58,7 @@ ImageWidgetPolygonForm<TValue> polygonDrawer->Color4d(m_Color[0],m_Color[1],m_Color[2],m_Color[3]); } polygonDrawer->SetBoundaryOnly(!m_Solid); - VertexListIteratorType it = this->GetPolygon()->GetVertexList()->Begin(); + VertexListConstIteratorType it = this->GetPolygon()->GetVertexList()->Begin(); while(it != this->GetPolygon()->GetVertexList()->End()) { diff --git a/Code/Visu/otbImageWidgetPolylineForm.h b/Code/Visu/otbImageWidgetPolylineForm.h index aaf94d7917a7db56d05442e3f52a929ae5ee83f6..8948881c7a981b6492b08fe056e2f8e75add9daf 100644 --- a/Code/Visu/otbImageWidgetPolylineForm.h +++ b/Code/Visu/otbImageWidgetPolylineForm.h @@ -54,7 +54,7 @@ class ITK_EXPORT ImageWidgetPolylineForm typedef typename PolylineType::Pointer PolylinePointerType; typedef typename PolylineType::VertexType VertexType; typedef typename PolylineType::VertexListType VertexListType; - typedef typename VertexListType::ConstIterator VertexListIteratorType; + typedef typename VertexListType::ConstIterator VertexListConstIteratorType; typedef typename PolylineType::ContinuousIndexType ContinuousIndexType; /** Accessors */ diff --git a/Code/Visu/otbImageWidgetPolylineForm.txx b/Code/Visu/otbImageWidgetPolylineForm.txx index 86400dc3fb3b17efd0df4334bda51a7cea9b27fb..4576d18ca66838731190f03fa04d8a30296aa808 100644 --- a/Code/Visu/otbImageWidgetPolylineForm.txx +++ b/Code/Visu/otbImageWidgetPolylineForm.txx @@ -55,7 +55,7 @@ ImageWidgetPolylineForm<TValue> } glBegin(GL_LINE_STRIP); - VertexListIteratorType it = this->GetPolyline()->GetVertexList()->Begin(); + VertexListConstIteratorType it = this->GetPolyline()->GetVertexList()->Begin(); while(it != this->GetPolyline()->GetVertexList()->End()) { diff --git a/Examples/DisparityMap/CMakeLists.txt b/Examples/DisparityMap/CMakeLists.txt index 895199fb1c88b284c23563310e64de9095d75bb2..0a05ed3fe87e916e9c0153d0f3564fab90455a8f 100644 --- a/Examples/DisparityMap/CMakeLists.txt +++ b/Examples/DisparityMap/CMakeLists.txt @@ -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) diff --git a/Examples/DisparityMap/NCCRegistrationFilterExample.cxx b/Examples/DisparityMap/NCCRegistrationFilterExample.cxx new file mode 100644 index 0000000000000000000000000000000000000000..cba58581507bdfa430121b75dcdc7d8ea34b3bd0 --- /dev/null +++ b/Examples/DisparityMap/NCCRegistrationFilterExample.cxx @@ -0,0 +1,131 @@ +/*========================================================================= + + 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( atoi(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; + +} + diff --git a/Examples/IO/VectorDataIOExample.cxx b/Examples/IO/VectorDataIOExample.cxx index 23d12fc1a1cdb10873873809704faefaabd9ca53..1f00ba2cd0554e025d5fb4170214457f63a1df32 100644 --- a/Examples/IO/VectorDataIOExample.cxx +++ b/Examples/IO/VectorDataIOExample.cxx @@ -124,7 +124,7 @@ int main(int argc, char * argv[]) // Software Guide : BeginCodeSnippet typedef otb::Polygon<PixelType> PolygonType; - typedef PolygonType::VertexListIteratorType PolygonIteratorType; + typedef PolygonType::VertexListConstIteratorType PolygonIteratorType; typedef otb::ObjectList<PolygonType> PolygonListType; typedef PolygonListType::Iterator PolygonListIteratorType; diff --git a/Testing/Code/DisparityMap/CMakeLists.txt b/Testing/Code/DisparityMap/CMakeLists.txt index 5543ca5ef77776992dc410f2ed97a3305720c677..6b745eaa73a83c3bf685e2e247757e69e3218f25 100644 --- a/Testing/Code/DisparityMap/CMakeLists.txt +++ b/Testing/Code/DisparityMap/CMakeLists.txt @@ -56,6 +56,17 @@ ADD_TEST(dmTvNearestPointDeformationFieldGenerator ${DISPARITYMAP_TESTS1} ${TEMP}/dmTvNearestPointDeformationField.hdr ) +# ------- otb::NCCRegistrationFilter ---------- + +ADD_TEST(dmTuNCCRegistrationFilterNew ${DISPARITYMAP_TESTS1} + otbNCCRegistrationFilterNew) + +# ------- otb::MIRegistrationFilter ---------- + +ADD_TEST(dmTuMIRegistrationFilterNew ${DISPARITYMAP_TESTS1} + otbMIRegistrationFilterNew) + + # ------- otb::NNearestPointsLinearInterpolateDeformationFieldGenerator ---------- ADD_TEST(dmTuNNearestPointsLinearInterpolateDeformationFieldGeneratorNew ${DISPARITYMAP_TESTS1} @@ -304,6 +315,8 @@ ADD_TEST(dmTvSinusoidDeformationFieldEstimation2 ${DISPARITYMAP_TESTS2} SET(BasicDisparityMap_SRCS1 otbDisparityMapEstimationMethodNew.cxx otbDisparityMapEstimationMethod.cxx +otbNCCRegistrationFilterNew.cxx +otbMIRegistrationFilterNew.cxx otbPointSetToDeformationFieldGeneratorNew.cxx otbNearestPointDeformationFieldGeneratorNew.cxx otbNearestPointDeformationFieldGenerator.cxx diff --git a/Testing/Code/DisparityMap/otbDisparityMapTests1.cxx b/Testing/Code/DisparityMap/otbDisparityMapTests1.cxx index 5e1d66cd3ee630f68ad131b8a10a9464983b5253..82515423c023942365a1ae168b431eb7aafd8c9e 100644 --- a/Testing/Code/DisparityMap/otbDisparityMapTests1.cxx +++ b/Testing/Code/DisparityMap/otbDisparityMapTests1.cxx @@ -36,4 +36,6 @@ REGISTER_TEST(otbNNearestPointsLinearInterpolateDeformationFieldGenerator); REGISTER_TEST(otbBSplinesInterpolateDeformationFieldGeneratorNew); REGISTER_TEST(otbBSplinesInterpolateDeformationFieldGenerator); REGISTER_TEST(otbPointSetWithTransformToDeformationFieldGeneratorNew); +REGISTER_TEST(otbNCCRegistrationFilterNew); +REGISTER_TEST(otbMIRegistrationFilterNew); } diff --git a/Testing/Code/DisparityMap/otbMIRegistrationFilterNew.cxx b/Testing/Code/DisparityMap/otbMIRegistrationFilterNew.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c172705eacee17db0850df4632d1e771d20ab764 --- /dev/null +++ b/Testing/Code/DisparityMap/otbMIRegistrationFilterNew.cxx @@ -0,0 +1,46 @@ +/*========================================================================= + + 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 "otbMIRegistrationFilter.h" +#include "otbImage.h" + +int otbMIRegistrationFilterNew(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; + + //Create the filter + typedef otb::MIRegistrationFilter< FixedImageType, + MovingImageType, + DeformationFieldType > + RegistrationFilterType; + + // Instantiation + RegistrationFilterType::Pointer registrator = RegistrationFilterType::New(); + + return EXIT_SUCCESS; +} diff --git a/Testing/Code/DisparityMap/otbNCCRegistrationFilterNew.cxx b/Testing/Code/DisparityMap/otbNCCRegistrationFilterNew.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ae43515025757b853ec941ada06d5a0aed431d6c --- /dev/null +++ b/Testing/Code/DisparityMap/otbNCCRegistrationFilterNew.cxx @@ -0,0 +1,46 @@ +/*========================================================================= + + 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 "otbNCCRegistrationFilter.h" +#include "otbImage.h" + +int otbNCCRegistrationFilterNew(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; + + //Create the filter + typedef otb::NCCRegistrationFilter< FixedImageType, + MovingImageType, + DeformationFieldType > + RegistrationFilterType; + + // Instantiation + RegistrationFilterType::Pointer registrator = RegistrationFilterType::New(); + + return EXIT_SUCCESS; +} diff --git a/Utilities/FLTK/fluid/CMakeLists.txt b/Utilities/FLTK/fluid/CMakeLists.txt index 5cc1f0bfe2700e6678ad5df0301278319a487902..c06a0a39156d5722b9d1d694d725beb87c66f043 100644 --- a/Utilities/FLTK/fluid/CMakeLists.txt +++ b/Utilities/FLTK/fluid/CMakeLists.txt @@ -27,8 +27,8 @@ INSTALL_TARGETS(/bin fluid) TARGET_LINK_LIBRARIES(fluid ${OTB_VISU_GUI_LIBRARIES} ${FLTK_PLATFORM_DEPENDENT_LIBS}) IF(OPENGL_FOUND) TARGET_LINK_LIBRARIES(fluid fltk_gl) - IF(APPLE) - TARGET_LINK_LIBRARIES(fluid -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib) - ENDIF(APPLE) +# IF(APPLE) +# TARGET_LINK_LIBRARIES(fluid -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib) +# ENDIF(APPLE) ENDIF(OPENGL_FOUND)