1 #ifndef __cpExtensions__Algorithms__CPRImageFilter__hxx__
2 #define __cpExtensions__Algorithms__CPRImageFilter__hxx__
4 #include <itkMinimumMaximumImageCalculator.h>
6 // -------------------------------------------------------------------------
7 template< class _TImage, class _TCurve >
8 _TCurve* cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve >::
12 dynamic_cast< _TCurve* >( this->itk::ProcessObject::GetInput( 1 ) )
16 // -------------------------------------------------------------------------
17 template< class _TImage, class _TCurve >
18 const _TCurve* cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve >::
22 dynamic_cast< const _TCurve* >( this->itk::ProcessObject::GetInput( 1 ) )
26 // -------------------------------------------------------------------------
27 template< class _TImage, class _TCurve >
28 void cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve >::
29 SetCurve( _TCurve* curve )
31 this->itk::ProcessObject::SetNthInput( 1, curve );
34 // -------------------------------------------------------------------------
35 template< class _TImage, class _TCurve >
36 cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve >::
41 this->Superclass::SetNumberOfRequiredInputs( 2 );
44 // -------------------------------------------------------------------------
45 template< class _TImage, class _TCurve >
46 cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve >::
51 // -------------------------------------------------------------------------
52 template< class _TImage, class _TCurve >
53 void cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve >::
54 GenerateOutputInformation( )
58 // -------------------------------------------------------------------------
59 template< class _TImage, class _TCurve >
60 void cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve >::
61 GenerateInputRequestedRegion( )
63 TImage* input = const_cast< TImage* >( this->GetInput( ) );
65 input->SetRequestedRegionToLargestPossibleRegion( );
68 // -------------------------------------------------------------------------
69 template< class _TImage, class _TCurve >
70 void cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve >::
73 typedef itk::MinimumMaximumImageCalculator< _TImage > _TMinMax;
75 auto input = this->GetInput( );
76 auto curve = this->GetCurve( );
77 auto output = this->GetOutput( );
79 // Compute image intensity range
80 typename _TMinMax::Pointer minmax = _TMinMax::New( );
81 minmax->SetImage( input );
85 this->m_Join = TJoinFilter::New( );
86 this->m_Slicers.clear( );
87 unsigned long N = curve->GetNumberOfPoints( );
89 typename _TCurve::TPoint p, q;
90 for( unsigned long n = 0; n < N; ++n )
92 p = curve->GetPoint( n );
94 len += p.EuclideanDistanceTo( q );
98 typename TSlicer::Pointer slicer = TSlicer::New( );
99 slicer->SetInput( input );
100 slicer->SetDefaultValue( minmax->GetMinimum( ) );
101 slicer->SpacingFromMinimumOn( );
102 if( this->m_Interpolator.IsNotNull( ) )
103 slicer->SetInterpolator( this->m_Interpolator );
104 slicer->SizeFromMaximumOff( );
105 if( this->m_SliceRadius > double( 0 ) )
107 slicer->SizeFromMinimumOff( );
108 slicer->SetSize( this->m_SliceRadius );
111 slicer->SizeFromMinimumOn( );
112 slicer->SetTranslation( p );
113 slicer->SetRotation( curve->GetFrame( n ) );
116 this->m_Join->SetInput( n, slicer->GetOutput( ) );
117 this->m_Slicers.push_back( slicer );
120 this->m_Join->SetSpacing( len / double( N ) );
121 this->m_Join->Update( );
122 this->GetOutput( )->Graft( this->m_Join->GetOutput( ) );
125 #endif // __cpExtensions__Algorithms__CPRImageFilter__hxx__