From: Leonardo Florez-Valencia Date: Tue, 14 Apr 2015 23:50:43 +0000 (-0500) Subject: Image visualization objects updated X-Git-Tag: v0.1~405 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=ab179c6d27a7b6952d52a10da584a9e4acddbf24;p=cpPlugins.git Image visualization objects updated --- diff --git a/CMakeLists.txt b/CMakeLists.txt index e4f2e37..1d6af75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,38 +42,32 @@ OPTION(BUILD_EXAMPLES "Build examples" OFF) INCLUDE(GenerateExportHeader) +FIND_PACKAGE(VTK REQUIRED) FIND_PACKAGE(ITK REQUIRED) INCLUDE(${ITK_USE_FILE}) -FIND_PACKAGE(VTK REQUIRED) -INCLUDE(${VTK_USE_FILE}) +## Check for required modules +IF(NOT ITKVtkGlue_LOADED) + MESSAGE(FATAL_ERROR "ITKVtkGlue module is required but not available.") +ENDIF(NOT ITKVtkGlue_LOADED) IF(USE_QT4) - IF(NOT WIN32) - FIND_LIBRARY( - VTK_USES_QT - NAMES vtkGUISupportQt-${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION} - HINTS ${VTK_LIBRARY_DIRS} - PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64 - ) - FIND_LIBRARY( - VTK_USES_QT_OPENGL - vtkGUISupportQtOpenGL-${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION} - HINTS ${VTK_LIBRARY_DIRS} - PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64 - ) - MARK_AS_ADVANCED(FORCE VTK_USES_QT) - MARK_AS_ADVANCED(FORCE VTK_USES_QT_OPENGL) - IF(VTK_USES_QT AND VTK_USES_QT_OPENGL) - FIND_PACKAGE(Qt4 REQUIRED) - INCLUDE(${QT_USE_FILE}) - ELSE(VTK_USES_QT AND VTK_USES_QT_OPENGL) - MESSAGE(FATAL_ERROR "VTK ${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION} was not compiled with Qt4 support!") - ENDIF(VTK_USES_QT AND VTK_USES_QT_OPENGL) - ELSE(NOT WIN32) - FIND_PACKAGE(Qt4 REQUIRED) - INCLUDE(${QT_USE_FILE}) - ENDIF(NOT WIN32) + FIND_PACKAGE(Qt4 REQUIRED) + INCLUDE(${QT_USE_FILE}) + + ## Check for required modules + IF(NOT vtkGUISupportQt_LOADED) + MESSAGE( + FATAL_ERROR + "vtkGUISupportQt module is required but not available." + ) + ENDIF(NOT vtkGUISupportQt_LOADED) + IF(NOT vtkGUISupportQtOpenGL_LOADED) + MESSAGE( + FATAL_ERROR + "vtkGUISupportQtOpenGL module is required but not available." + ) + ENDIF(NOT vtkGUISupportQtOpenGL_LOADED) ENDIF(USE_QT4) ## ================================================ diff --git a/lib/cpPlugins/Extensions/Algorithms/IterativeGaussianModelEstimator.hxx b/lib/cpPlugins/Extensions/Algorithms/IterativeGaussianModelEstimator.hxx index c8c652f..bf87054 100644 --- a/lib/cpPlugins/Extensions/Algorithms/IterativeGaussianModelEstimator.hxx +++ b/lib/cpPlugins/Extensions/Algorithms/IterativeGaussianModelEstimator.hxx @@ -36,31 +36,6 @@ UpdateModel( ) else this->m_Cov.fill( S( 0 ) ); - /* TODO - TMatrix Es = ( this->m_S1 * this->m_S1.transpose( ) ); - for( unsigned int i = 0; i < D; ++i ) - { - this->m_Mean[ i ][ 0 ] = this->m_S1[ i ][ 0 ]; - if( this->m_N > 0 ) - this->m_Mean[ i ][ 0 ] /= S( this->m_N ); - - for( unsigned int j = 0; j < D; ++j ) - { - this->m_Cov[ i ][ j ] = S( 0 ); - if( this->m_N > 0 ) - this->m_Cov[ i ][ j ] -= Es[ i ][ j ] / S( this->m_N ); - if( this->m_N > 1 ) - { - this->m_Cov[ i ][ j ] += this->m_S2[ i ][ j ]; - this->m_Cov[ i ][ j ] /= S( this->m_N - 1 ); - - } // fi - - } // rof - - } // rof - */ - // Compute inverse and determinant S det = vnl_determinant( this->m_Cov ); if( !( det > S( 0 ) ) ) @@ -98,15 +73,6 @@ UpdateModel( ) } // rof this->m_Updated = true; - - /* DEBUG: - std::cout << "--------------------" << std::endl; - std::cout << this->m_Cov << std::endl; - std::cout << "--------------------" << std::endl; - std::cout << this->m_InvCov << std::endl; - std::cout << "--------------------" << std::endl; - std::cout << this->m_Mean << std::endl; - */ } // ------------------------------------------------------------------------- @@ -118,10 +84,23 @@ Probability( const V& sample ) const TMatrix c( D, 1 ); for( unsigned int d = 0; d < D; ++d ) c[ d ][ 0 ] = S( sample[ d ] ) - this->m_Mean[ d ][ 0 ]; - double v = double( ( c.transpose( ) * ( this->m_InvCov * c ) )[ 0 ][ 0 ] ); - v /= double( 2 ); + if( S( 0 ) < this->m_DensityCoeff ) + { + // Covariance is NOT null + double v = double( ( c.transpose( ) * ( this->m_InvCov * c ) )[ 0 ][ 0 ] ); + v /= double( 2 ); - return( S( std::exp( -v ) ) ); + return( S( std::exp( -v ) ) ); + } + else + { + // Covariance is null + bool equal = true; + for( unsigned int d = 0; d < D && equal; ++d ) + equal &= !( S( 0 ) < S( std::fabs( double( c[ d ][ 0 ] ) ) ) ); + return( ( equal )? S( 1 ): S( 0 ) ); + + } // fi } // ------------------------------------------------------------------------- @@ -187,23 +166,6 @@ AddSample( const V& sample ) this->m_S1 += s; this->m_S2 += s * s.transpose( ); - /* DEBUG: - std::cout - << sample[ 0 ] << " " << sample[ 1 ] << " " << sample[ 2 ] << std::endl; - */ - - /* TODO - { - this->m_S1[ i ][ 0 ] += S( sample[ i ] ); - for( unsigned int j = i; j < D; ++j ) - { - this->m_S2[ i ][ j ] += S( sample[ i ] ) * S( sample[ j ] ); - this->m_S2[ j ][ i ] = this->m_S2[ i ][ j ]; - - } // rof - - } // rof - */ this->m_Updated = false; this->Modified( ); } diff --git a/lib/cpPlugins/Extensions/Visualization/ImageInteractorStyle.h b/lib/cpPlugins/Extensions/Visualization/ImageInteractorStyle.h index 277a606..7ff6dbd 100644 --- a/lib/cpPlugins/Extensions/Visualization/ImageInteractorStyle.h +++ b/lib/cpPlugins/Extensions/Visualization/ImageInteractorStyle.h @@ -10,14 +10,6 @@ #include -/* TODO - #include - #include - #include - #include - class vtkImageData; -*/ - // ------------------------------------------------------------------------- #define cpPlugins_ImageInteractorStyle_ObserverMacro( e ) \ inline unsigned long Add##e##Observer( vtkCommand* observer ) \ diff --git a/lib/cpPlugins/Extensions/Visualization/MPRWithDifferentWindows.cxx b/lib/cpPlugins/Extensions/Visualization/MPRWithDifferentWindows.cxx index 103d321..e870051 100644 --- a/lib/cpPlugins/Extensions/Visualization/MPRWithDifferentWindows.cxx +++ b/lib/cpPlugins/Extensions/Visualization/MPRWithDifferentWindows.cxx @@ -1,4 +1,5 @@ #include +#include // ------------------------------------------------------------------------- cpPlugins::Extensions::Visualization::MPRWithDifferentWindows:: @@ -84,6 +85,12 @@ SetImage( vtkImageData* image ) this->m_Renderers[ 3 ] ); + // Correct cameras positions + vtkCamera* zCam = this->m_Renderers[ 2 ]->GetActiveCamera( ); + zCam->SetViewUp( 0, -1, 0 ); + zCam->SetPosition( 0, 0, -1 ); + zCam->SetFocalPoint( 0, 0, 0 ); + // First rendering this->ResetCameras( ); this->RenderAll( );