#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 >::
void cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve >::
SetCurve( _TCurve* curve )
{
- this->itk::ProcessObject::SetInput( 1, curve );
+ this->itk::ProcessObject::SetNthInput( 1, curve );
}
// -------------------------------------------------------------------------
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__
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 );