]> Creatis software - cpPlugins.git/commitdiff
Image visualization objects updated
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 14 Apr 2015 23:50:43 +0000 (18:50 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 14 Apr 2015 23:50:43 +0000 (18:50 -0500)
CMakeLists.txt
lib/cpPlugins/Extensions/Algorithms/IterativeGaussianModelEstimator.hxx
lib/cpPlugins/Extensions/Visualization/ImageInteractorStyle.h
lib/cpPlugins/Extensions/Visualization/MPRWithDifferentWindows.cxx

index e4f2e37e0ef5d5cbc9b60406c5414ede44546a0c..1d6af7523fb31f826af49c1c257f5c6c7556fabc 100644 (file)
@@ -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)
 
 ## ================================================
index c8c652f6462cb70171d1bb631d9ac85fa6a22f56..bf87054cf79a25fc68047b3365315b9627e015a1 100644 (file)
@@ -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( );
 }
index 277a6064e410b7726aaa0cbfaee96d9dcd414791..7ff6dbd6f5fdc0647cc396738da5ce0f3897c764 100644 (file)
 
 #include <cpPlugins/Extensions/cpPlugins_Extensions_Export.h>
 
-/* TODO
-   #include <vtkInteractorStyleImage.h>
-   #include <vtkLineWidget2.h>
-   #include <vtkLineRepresentation.h>
-   #include <vtkPlane.h>
-   class vtkImageData;
-*/
-
 // -------------------------------------------------------------------------
 #define cpPlugins_ImageInteractorStyle_ObserverMacro( e )               \
   inline unsigned long Add##e##Observer( vtkCommand* observer )         \
index 103d32136cb226aac62108a01c21b108c17612d6..e87005197a08f4768cdfb11557eee4037178be4a 100644 (file)
@@ -1,4 +1,5 @@
 #include <cpPlugins/Extensions/Visualization/MPRWithDifferentWindows.h>
+#include <vtkCamera.h>
 
 // -------------------------------------------------------------------------
 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( );