From: Leonardo Florez-Valencia Date: Mon, 31 Oct 2016 16:20:27 +0000 (-0500) Subject: ... X-Git-Tag: v0.1~69 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=9d315ac836e5fe246a8c987681085ee19898affc;p=cpPlugins.git ... --- diff --git a/lib/cpExtensions/Algorithms/CPRImageFilter.hxx b/lib/cpExtensions/Algorithms/CPRImageFilter.hxx index a29c656..b2b8d96 100644 --- a/lib/cpExtensions/Algorithms/CPRImageFilter.hxx +++ b/lib/cpExtensions/Algorithms/CPRImageFilter.hxx @@ -1,6 +1,10 @@ #ifndef __cpExtensions__Algorithms__CPRImageFilter__hxx__ #define __cpExtensions__Algorithms__CPRImageFilter__hxx__ +#include +#include +#include + // ------------------------------------------------------------------------- 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__ diff --git a/lib/cpExtensions/DataStructures/Simple3DCurve.h b/lib/cpExtensions/DataStructures/Simple3DCurve.h index cbbef54..0641d43 100644 --- a/lib/cpExtensions/DataStructures/Simple3DCurve.h +++ b/lib/cpExtensions/DataStructures/Simple3DCurve.h @@ -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 ); diff --git a/plugins/ImageSliceFilters/ImageSliceFilters.i b/plugins/ImageSliceFilters/ImageSliceFilters.i index cd8395a..69bbbd5 100644 --- a/plugins/ImageSliceFilters/ImageSliceFilters.i +++ b/plugins/ImageSliceFilters/ImageSliceFilters.i @@ -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$