]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 31 Oct 2016 16:20:27 +0000 (11:20 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 31 Oct 2016 16:20:27 +0000 (11:20 -0500)
lib/cpExtensions/Algorithms/CPRImageFilter.hxx
lib/cpExtensions/DataStructures/Simple3DCurve.h
plugins/ImageSliceFilters/ImageSliceFilters.i

index a29c6565f0fb8a79bf4653f7c621d6e417936bb3..b2b8d969b1a6e69a8bfcbd7060f8c270c1e892e4 100644 (file)
@@ -1,6 +1,10 @@
 #ifndef __cpExtensions__Algorithms__CPRImageFilter__hxx__
 #define __cpExtensions__Algorithms__CPRImageFilter__hxx__
 
+#include <itkImageRegionIterator.h>
+#include <itkImageSliceIteratorWithIndex.h>
+#include <itkMinimumMaximumImageCalculator.h>
+
 // -------------------------------------------------------------------------
 template< class _TImage, class _TCurve >
 _TCurve* cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve >::
@@ -26,7 +30,7 @@ template< class _TImage, class _TCurve >
 void cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve >::
 SetCurve( _TCurve* curve )
 {
-  this->itk::ProcessObject::SetInput( 1, curve );
+  this->itk::ProcessObject::SetNthInput( 1, curve );
 }
 
 // -------------------------------------------------------------------------
@@ -68,10 +72,63 @@ template< class _TImage, class _TCurve >
 void cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve >::
 GenerateData( )
 {
-  /* TODO
-     double m_SliceRadius
-     typename TInterpolateFunction::Pointer m_Interpolator
-  */
+  typedef itk::MinimumMaximumImageCalculator< _TImage >           _TMinMax;
+  typedef itk::ImageSliceIteratorWithIndex< _TImage >               _T3DIt;
+  typedef itk::ImageRegionIterator< typename TSlicer::TSliceImage > _T2DIt;
+
+  auto input = this->GetInput( );
+  auto curve = this->GetCurve( );
+  auto output = this->GetOutput( );
+
+  // Compute image intensity range
+  typename _TMinMax::Pointer minmax = _TMinMax::New( );
+  minmax->SetImage( input );
+  minmax->Compute( );
+
+  // Prepare slicer
+  typename TSlicer::Pointer slicer = TSlicer::New( );
+  slicer->SetInput( input );
+  slicer->SetDefaultValue( minmax->GetMinimum( ) );
+  slicer->SpacingFromMinimumOn( );
+  if( this->m_Interpolator.IsNotNull( ) )
+    slicer->SetInterpolator( this->m_Interpolator );
+  slicer->SizeFromMaximumOff( );
+  if( this->m_SliceRadius > double( 0 ) )
+  {
+    slicer->SizeFromMinimumOff( );
+    slicer->SetSize( this->m_SliceRadius );
+  }
+  else
+    slicer->SizeFromMinimumOn( );
+
+  // Slice image
+  _T3DIt oIt( output, output->GetRequestedRegion( ) );
+  oIt.SetFirstDirection( 1 );
+  oIt.SetSecondDirection( 2 );
+  oIt.GoToBegin( );
+  unsigned long N = curve->GetNumberOfPoints( );
+  for( unsigned long n = 0; n < N; ++n )
+  {
+    slicer->SetTranslation( curve->GetPoint( n ) );
+    slicer->SetRotation( curve->GetFrame( n ) );
+    slicer->Update( );
+
+    // Fill output image
+    _T2DIt sIt(
+      slicer->GetOutput( ), slicer->GetOutput( )->GetRequestedRegion( )
+      );
+    for( sIt.GoToBegin( ); !sIt.IsAtEnd( ); ++sIt )
+    {
+      oIt.Set( sIt.Get( ) );
+      ++oIt;
+      if( oIt.IsAtEndOfLine( ) )
+        oIt.NextLine( );
+      if( oIt.IsAtEndOfSlice( ) )
+        oIt.NextSlice( );
+
+    } // rof
+
+  } // rof
 }
 
 #endif // __cpExtensions__Algorithms__CPRImageFilter__hxx__
index cbbef541993afd25201ae438748ac87910456e84..0641d43e8e0aaddc7aa742b51f77381ef8bd33e7 100644 (file)
@@ -23,9 +23,10 @@ namespace cpExtensions
       typedef itk::SmartPointer< Self >       Pointer;
       typedef itk::SmartPointer< const Self > ConstPointer;
 
-      typedef itk::Matrix< _TScalar, 3, 3 > TMatrix;
-      typedef itk::Point< _TScalar, 3 >     TPoint;
-      typedef typename TPoint::VectorType   TVector;
+      typedef _TScalar TScalar;
+      typedef itk::Matrix< TScalar, 3, 3 > TMatrix;
+      typedef itk::Point< TScalar, 3 >     TPoint;
+      typedef typename TPoint::VectorType  TVector;
 
     public:
       itkNewMacro( Self );
index cd8395a3182959ac309b1227da3c69497e79ee33..69bbbd5bb5531cc3daf96c3635c70d40397fee31 100644 (file)
@@ -1 +1,7 @@
+
+tinclude cpExtensions/Algorithms/CPRImageFilter:h|hxx
+cinclude cpExtensions/DataStructures/Simple3DCurve.h
+
+instances cpExtensions::Algorithms::CPRImageFilter< itk::Image< #scalar_pixels#, 3 >, cpExtensions::DataStructures::Simple3DCurve< #real_types# > >
+
 ** eof - $RCSfile$