From acf80d9081e1eda21b82b6bcc405db3448b1aae9 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Tue, 16 Feb 2016 22:35:20 -0500 Subject: [PATCH 1/1] ... --- lib/cpExtensions/Algorithms/CPRFilter.h | 85 ---------- lib/cpExtensions/Algorithms/CPRFilter.hxx | 148 ------------------ .../Plugins/BasicFilters/CPRFilter.cxx | 102 ------------ .../Plugins/BasicFilters/CPRFilter.h | 57 ------- 4 files changed, 392 deletions(-) delete mode 100644 lib/cpExtensions/Algorithms/CPRFilter.h delete mode 100644 lib/cpExtensions/Algorithms/CPRFilter.hxx delete mode 100644 lib/cpPlugins/Plugins/BasicFilters/CPRFilter.cxx delete mode 100644 lib/cpPlugins/Plugins/BasicFilters/CPRFilter.h diff --git a/lib/cpExtensions/Algorithms/CPRFilter.h b/lib/cpExtensions/Algorithms/CPRFilter.h deleted file mode 100644 index 4a4e660..0000000 --- a/lib/cpExtensions/Algorithms/CPRFilter.h +++ /dev/null @@ -1,85 +0,0 @@ -// ------------------------------------------------------------------------- -// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) -// ------------------------------------------------------------------------- - -#ifndef __CPEXTENSIONS__ALGORITHMS__CPRFILTER__H__ -#define __CPEXTENSIONS__ALGORITHMS__CPRFILTER__H__ - -#include - -#include -#include -#include -#include -#include - -namespace cpExtensions -{ - namespace Algorithms - { - /** - */ - template< class I, class S = float > - class CPRFilter - : public itk::ImageToImageFilter< I, I > - { - public: - // Standard ITK typedefs. - typedef CPRFilter Self; - typedef itk::ImageToImageFilter< I, I > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - itkStaticConstMacro( VDimension, unsigned int, I::ImageDimension ); - - typedef I TImage; - typedef S TScalar; - - typedef itk::InterpolateImageFunction< I, S > TInterpolator; - typedef itk::PolyLineParametricPath< VDimension > TAxis; - typedef cpExtensions::Algorithms::IsoImageSlicer< I, S > TSlicer; - typedef typename TSlicer::TSliceImage TSlice; - typedef itk::JoinSeriesImageFilter< TSlice, I > TJoin; - - public: - itkNewMacro( Self ); - itkTypeMacro( CPRFilter, itk::ImageToImageFilter ); - - itkGetConstMacro( SliceRadius, double ); - itkGetConstMacro( NumberOfSlices, unsigned int ); - itkGetObjectMacro( Interpolator, TInterpolator ); - - itkSetMacro( SliceRadius, double ); - itkSetMacro( NumberOfSlices, unsigned int ); - itkSetObjectMacro( Interpolator, TInterpolator ); - - public: - const TAxis* GetAxis( ) const; - void SetAxis( const TAxis* axis ); - - protected: - CPRFilter( ); - virtual ~CPRFilter( ); - - virtual void GenerateOutputInformation( ); - virtual void GenerateData( ); - - protected: - double m_SliceRadius; - unsigned int m_NumberOfSlices; - - typename TInterpolator::Pointer m_Interpolator; - typename TJoin::Pointer m_Join; - std::vector< typename TSlicer::Pointer > m_Slices; - }; - - } // ecapseman - -} // ecapseman - -#ifndef ITK_MANUAL_INSTANTIATION -#include -#endif // ITK_MANUAL_INSTANTIATION - -#endif // __CPEXTENSIONS__ALGORITHMS__CPRFILTER__H__ - -// eof - $RCSfile$ diff --git a/lib/cpExtensions/Algorithms/CPRFilter.hxx b/lib/cpExtensions/Algorithms/CPRFilter.hxx deleted file mode 100644 index 4a2169e..0000000 --- a/lib/cpExtensions/Algorithms/CPRFilter.hxx +++ /dev/null @@ -1,148 +0,0 @@ -// ------------------------------------------------------------------------- -// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) -// ------------------------------------------------------------------------- - -#ifndef __CPEXTENSIONS__ALGORITHMS__CPRFILTER__HXX__ -#define __CPEXTENSIONS__ALGORITHMS__CPRFILTER__HXX__ - -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -template< class I, class S > -const typename cpExtensions::Algorithms::CPRFilter< I, S >:: -TAxis* cpExtensions::Algorithms::CPRFilter< I, S >:: -GetAxis( ) const -{ - return( - dynamic_cast< const TAxis* >( this->itk::ProcessObject::GetInput( 1 ) ) - ); -} - -// ------------------------------------------------------------------------- -template< class I, class S > -void cpExtensions::Algorithms::CPRFilter< I, S >:: -SetAxis( const TAxis* axis ) -{ - this->itk::ProcessObject::SetNthInput( 1, const_cast< TAxis* >( axis ) ); -} - -// ------------------------------------------------------------------------- -template< class I, class S > -cpExtensions::Algorithms::CPRFilter< I, S >:: -CPRFilter( ) - : Superclass( ) -{ - this->m_Interpolator = - itk::LinearInterpolateImageFunction< I, S >::New( ); -} - -// ------------------------------------------------------------------------- -template< class I, class S > -cpExtensions::Algorithms::CPRFilter< I, S >:: -~CPRFilter( ) -{ -} - -// ------------------------------------------------------------------------- -template< class I, class S > -void cpExtensions::Algorithms::CPRFilter< I, S >:: -GenerateOutputInformation( ) -{ - // Do nothing since the output has different geometry and topology. -} - -// ------------------------------------------------------------------------- -template< class I, class S > -void cpExtensions::Algorithms::CPRFilter< I, S >:: -GenerateData( ) -{ - typedef itk::Point< S, VDimension > _P; - typedef typename _P::VectorType _V; - typedef cpExtensions::Algorithms::BezierCurveFunction< _V > _Bezier; - typedef typename _Bezier::TFrame _M; - typedef itk::MinimumMaximumImageCalculator< I > _MinMax; - - auto image = this->GetInput( ); - auto axis = this->GetAxis( ); - - // 0. Get image properties - typename _MinMax::Pointer minmax = _MinMax::New( ); - minmax->SetImage( image ); - minmax->Compute( ); - auto background = minmax->GetMinimum( ); - - // 1. Construct Bezier curve - typename _Bezier::Pointer bezier = _Bezier::New( ); - auto vertices = axis->GetVertexList( ); - for( unsigned int i = 0; i < vertices->Size( ); ++i ) - { - auto index = vertices->GetElement( i ); - _P point; - image->TransformContinuousIndexToPhysicalPoint( index, point ); - bezier->AddPoint( point.GetVectorFromOrigin( ) ); - - } // rof - - // 2. Slice image and prepare join filter - this->m_Join = TJoin::New( ); - unsigned int nSlices = this->m_NumberOfSlices; - if( nSlices == 0 ) - nSlices = bezier->GetNumberOfPoints( ); - _V vpre; - _M mpre; - S len = S( 0 ); - for( unsigned int i = 0; i <= nSlices; ++i ) - { - // Get geometrical data and correct Frenet frame - S u = S( i ) / S( nSlices ); - std::cout << u << std::endl; - _V vnex = bezier->Evaluate( u ); - _M mnex = bezier->EvaluateFrenetFrame( u ); - if( i > 0 ) - { - len += ( vpre - vnex ).GetNorm( ); - - // TODO: Update Frenet frame orientation - - } // fi - - // Slice image - typename TSlicer::Pointer slicer = TSlicer::New( ); - slicer->SetInput( image ); - slicer->SetRotation( mnex ); - slicer->SetTranslation( vnex ); - slicer->SetSize( S( this->m_SliceRadius ) ); - slicer->SpacingFromMinimumOn( ); - slicer->SetDefaultValue( background ); - slicer->SetInterpolator( this->m_Interpolator ); - slicer->Update( ); - - std::cout << slicer->GetOutput( )->GetLargestPossibleRegion( ).GetSize( ) << std::endl; - - // Add output to join filter and keep track of the current slicer - this->m_Join->SetInput( i, slicer->GetOutput( ) ); - this->m_Slices.push_back( slicer ); - - // Update values - vpre = vnex; - mpre = mnex; - - } // rof - - // 3. Finish join filter configuration - this->m_Join->SetSpacing( double( len / S( nSlices + 1 ) ) ); - std::cout << this->m_Join->GetSpacing( ) << std::endl; - this->m_Join->SetOrigin( double( 0 ) ); - - // 4. Graft outputs - this->m_Join->GraftOutput( this->GetOutput( ) ); - this->m_Join->Update( );//LargestPossibleRegion( ); - this->GraftOutput( this->m_Join->GetOutput( ) ); -} - -#endif // __CPEXTENSIONS__ALGORITHMS__CPRFILTER__HXX__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/BasicFilters/CPRFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/CPRFilter.cxx deleted file mode 100644 index a67baa1..0000000 --- a/lib/cpPlugins/Plugins/BasicFilters/CPRFilter.cxx +++ /dev/null @@ -1,102 +0,0 @@ -#include "CPRFilter.h" -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -cpPlugins::BasicFilters::CPRFilter:: -CPRFilter( ) - : Superclass( ) -{ - this->_AddInput( "InputImage" ); - this->_AddInput( "InputAxis" ); - this->_AddInput( "Interpolator", false ); - this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); - - this->m_Parameters->ConfigureAsUint( "NumberOfSlices" ); - this->m_Parameters->ConfigureAsReal( "SliceRadius" ); - std::vector< std::string > choices; - choices.push_back( "float" ); - choices.push_back( "double" ); - this->m_Parameters->ConfigureAsChoices( "ScalarType", choices ); - - this->m_Parameters->SetUint( "NumberOfSlices", 0 ); - this->m_Parameters->SetReal( "SliceRadius", 10 ); - this->m_Parameters->SetSelectedChoice( "ScalarType", "float" ); -} - -// ------------------------------------------------------------------------- -cpPlugins::BasicFilters::CPRFilter:: -~CPRFilter( ) -{ -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::BasicFilters::CPRFilter:: -_GenerateData( ) -{ - auto image = - this->GetInputData< cpPlugins::Interface::Image >( "InputImage" ); - itk::DataObject* itk_image = NULL; - std::string r = ""; - cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 ); - else r = "CPRFilter: Input image type not supported."; - return( r ); -} - -// ------------------------------------------------------------------------- -template< class I > -std::string cpPlugins::BasicFilters::CPRFilter:: -_GD0( itk::DataObject* dobj ) -{ - I* image = dynamic_cast< I* >( dobj ); - - auto choice = this->m_Parameters->GetSelectedChoice( "ScalarType" ); - if( choice == "float" ) - return( this->_GD1< I, float >( image ) ); - else if( choice == "double" ) - return( this->_GD1< I, double >( image ) ); - else - return( "CPRFilter: Scalar type not supported." ); -} - -// ------------------------------------------------------------------------- -template< class I, class S > -std::string cpPlugins::BasicFilters::CPRFilter:: -_GD1( I* image ) -{ - typedef cpExtensions::Algorithms::CPRFilter< I, S > _Filter; - typedef itk::PolyLineParametricPath< I::ImageDimension > _Path; - typedef itk::InterpolateImageFunction< I, S > _Interpolator; - - auto axis = - this->GetInputData< cpPlugins::Interface::PolyLineParametricPath >( - "InputAxis" - )->GetITK< _Path >( ); - if( axis == NULL ) - return( "CPRFilter: Invalid input axis." ); - auto w_int = - this->GetInputData< cpPlugins::Interface::DataObject >( "Interpolator" ); - _Interpolator* interpolator = NULL; - if( w_int != NULL ) - interpolator = w_int->GetITK< _Interpolator >( ); - - // Configure filter - _Filter* filter = this->_CreateITK< _Filter >( ); - filter->SetInput( image ); - filter->SetAxis( axis ); - if( interpolator != NULL ) - filter->SetInterpolator( interpolator ); - filter->SetNumberOfSlices( this->m_Parameters->GetUint( "NumberOfSlices" ) ); - filter->SetSliceRadius( this->m_Parameters->GetReal( "SliceRadius" ) ); - filter->Update( ); - - // Assign output - auto out = - this->GetOutputData< cpPlugins::Interface::Image >( "Output" ); - out->SetITK( filter->GetOutput( ) ); - return( "" ); -} - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/BasicFilters/CPRFilter.h b/lib/cpPlugins/Plugins/BasicFilters/CPRFilter.h deleted file mode 100644 index cb1a879..0000000 --- a/lib/cpPlugins/Plugins/BasicFilters/CPRFilter.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef __CPPLUGINS__PLUGINS__CPRFILTER__H__ -#define __CPPLUGINS__PLUGINS__CPRFILTER__H__ - -#include -#include - -namespace cpPlugins -{ - namespace BasicFilters - { - /** - */ - class cpPluginsBasicFilters_EXPORT CPRFilter - : public cpPlugins::Interface::ImageToImageFilter - { - public: - typedef CPRFilter Self; - typedef cpPlugins::Interface::ImageToImageFilter Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( - CPRFilter, - cpPluginsInterfaceImageToImageFilter - ); - cpPlugins_Id_Macro( - cpPlugins::BasicFilters::CPRFilter, - ImageToImageFilter - ); - - protected: - CPRFilter( ); - virtual ~CPRFilter( ); - - virtual std::string _GenerateData( ); - - template< class I > - inline std::string _GD0( itk::DataObject* dobj ); - - template< class I, class S > - inline std::string _GD1( I* image ); - - private: - // Purposely not implemented - CPRFilter( const Self& ); - Self& operator=( const Self& ); - }; - - } // ecapseman - -} // ecapseman - -#endif // __CPPLUGINS__PLUGINS__CPRFILTER__H__ - -// eof - $RCSfile$ -- 2.45.2