From 22c3c302e6fb4932c6598a8acbf043436c4c06c6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Thu, 3 Nov 2016 19:57:26 -0500 Subject: [PATCH] ... --- lib/Instances/BaseObjects.i | 13 +++ lib/Instances/CMakeLists.txt | 4 + lib/Instances/ImageComplexFilters.i | 5 ++ lib/Instances/ImageInterpolators.i | 14 ++++ lib/Instances/Transforms.i | 18 +++++ lib/cpExtensions/Algorithms/CPRImageFilter.h | 10 ++- .../Algorithms/CPRImageFilter.hxx | 73 ++++++++--------- .../DataStructures/Simple3DCurve.cxx | 9 ++- lib/cpPlugins/DataObjects/Simple3DCurve.cxx | 15 +--- lib/cpPlugins/DataObjects/Simple3DCurve.d | 4 + plugins/CMakeLists.txt | 4 + plugins/IO/ImageReader.cxx | 80 +++++++++---------- .../ImageGenericFilters/ImageGenericFilters.i | 2 + plugins/ImageSliceFilters/CPRImageFilter.cxx | 66 +++++++++++++++ plugins/ImageSliceFilters/CPRImageFilter.h | 32 ++++++++ plugins/ImageSliceFilters/ImageSliceFilters.i | 13 +++ 16 files changed, 268 insertions(+), 94 deletions(-) create mode 100644 lib/Instances/ImageInterpolators.i create mode 100644 lib/Instances/Transforms.i create mode 100644 lib/cpPlugins/DataObjects/Simple3DCurve.d create mode 100644 plugins/ImageSliceFilters/CPRImageFilter.cxx create mode 100644 plugins/ImageSliceFilters/CPRImageFilter.h diff --git a/lib/Instances/BaseObjects.i b/lib/Instances/BaseObjects.i index 88d6266..704af33 100644 --- a/lib/Instances/BaseObjects.i +++ b/lib/Instances/BaseObjects.i @@ -1,5 +1,13 @@ header #define ITK_MANUAL_INSTANTIATION +header #include +header VCL_DEFINE_SPECIALIZATION struct vnl_complex_traits< bool > +header { +header enum { isreal = true }; +header static bool conjugate( bool x ) { return( x ); } +header static std::complex< bool > complexify( bool x ) { return( std::complex< bool >( x, false ) ); } +header }; +tinclude itkArray2D:h|hxx tinclude itkArray:h|hxx tinclude itkFixedArray:h|hxx tinclude itk#color_pixels#:h|hxx @@ -8,11 +16,15 @@ tinclude itk#matrices#:h|hxx tinclude itk#diff_tensors#:h|hxx tinclude itkSymmetricEigenAnalysis:h|hxx tinclude itkSimpleDataObjectDecorator:h|hxx +tinclude itkVariableLengthVector:h|hxx tinclude vnl/vnl_vector:h|hxx +tinclude vnl/vnl_matrix:h|hxx cinclude vnl/vnl_c_vector.hxx instances vnl_vector< bool > +instances vnl_matrix< bool > +instances itk::Array2D< #scalar_pixels# > instances itk::Array< #scalar_pixels# > instances itk::FixedArray< #scalar_pixels#, #process_dims# > instances itk::FixedArray< #scalar_pixels#, 8 > @@ -23,6 +35,7 @@ instances itk::#matrices#< #real_types#, #process_dims#, #process_dims# > instances itk::SymmetricEigenAnalysis< itk::Matrix< #real_types#, #process_dims#, #process_dims# >, itk::FixedArray< #real_types#, #process_dims# >, itk::Matrix< #real_types#, #process_dims#, #process_dims# > > instances itk::SimpleDataObjectDecorator< #scalar_pixels# > +instances itk::VariableLengthVector< #scalar_pixels# > define my_vectors=FixedArray;Vector;Point diff --git a/lib/Instances/CMakeLists.txt b/lib/Instances/CMakeLists.txt index 6275091..623325a 100644 --- a/lib/Instances/CMakeLists.txt +++ b/lib/Instances/CMakeLists.txt @@ -6,9 +6,11 @@ SET( ImageNeighborhoodIterators ImageFiltersBases ImageComplexFilters + ImageInterpolators BoundingBoxes Meshes Paths + Transforms ) SET(_all_libs) @@ -31,8 +33,10 @@ TARGET_LINK_LIBRARIES(cpInstances_ImageIterators cpInstances_SimpleImages) TARGET_LINK_LIBRARIES(cpInstances_ImageNeighborhoodIterators cpInstances_SimpleImages) TARGET_LINK_LIBRARIES(cpInstances_ImageFiltersBases cpInstances_SimpleImages) TARGET_LINK_LIBRARIES(cpInstances_ImageComplexFilters cpInstances_ImageFiltersBases cpInstances_ImageIterators) +TARGET_LINK_LIBRARIES(cpInstances_ImageInterpolators cpInstances_BaseObjects) TARGET_LINK_LIBRARIES(cpInstances_BoundingBoxes cpInstances_BaseObjects) TARGET_LINK_LIBRARIES(cpInstances_Meshes cpInstances_BoundingBoxes) TARGET_LINK_LIBRARIES(cpInstances_Paths cpInstances_BaseObjects ${VTK_LIBRARIES}) +TARGET_LINK_LIBRARIES(cpInstances_Transforms cpInstances_BaseObjects) ## eof - $RCSfilfe$ diff --git a/lib/Instances/ImageComplexFilters.i b/lib/Instances/ImageComplexFilters.i index 167c0f5..961364c 100644 --- a/lib/Instances/ImageComplexFilters.i +++ b/lib/Instances/ImageComplexFilters.i @@ -6,6 +6,11 @@ tinclude itkImageToImageFilter:h|hxx tinclude itkInPlaceImageFilter:h|hxx tinclude itkRecursiveSeparableImageFilter:h|hxx +instances itk::ImageToImageFilter< itk::Image< #scalar_pixels#, 3 >, itk::Image< #scalar_pixels#, 2 > > +instances itk::ImageToImageFilter< itk::Image< #scalar_pixels#, 2 >, itk::Image< #scalar_pixels#, 3 > > +instances itk::InPlaceImageFilter< itk::Image< #scalar_pixels#, 3 >, itk::Image< #scalar_pixels#, 2 > > +instances itk::InPlaceImageFilter< itk::Image< #scalar_pixels#, 2 >, itk::Image< #scalar_pixels#, 3 > > + instances itk::ImageToImageFilter< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< itk::CovariantVector< #real_types#, #process_dims# >, #process_dims# > > instances itk::ImageToImageFilter< itk::Image< itk::CovariantVector< #real_types#, #process_dims# >, #process_dims# >, itk::Image< #scalar_pixels#, #process_dims# > > instances itk::RecursiveSeparableImageFilter< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #real_types#, #process_dims# > > diff --git a/lib/Instances/ImageInterpolators.i b/lib/Instances/ImageInterpolators.i new file mode 100644 index 0000000..f4464fd --- /dev/null +++ b/lib/Instances/ImageInterpolators.i @@ -0,0 +1,14 @@ +header #define ITK_MANUAL_INSTANTIATION + +define i_real=#real_types# +define o_real=#real_types# + +tinclude itkImageFunction:h|hxx +tinclude itkLinearInterpolateImageFunction:h|hxx + +cinclude itkImage.h + +instances itk::ImageFunction< itk::Image< #scalar_pixels#, #process_dims# >, #i_real#, #o_real# > +instances itk::LinearInterpolateImageFunction< itk::Image< #scalar_pixels#, #process_dims# >, #real_types# > + +** eof - $RCSfile$ diff --git a/lib/Instances/Transforms.i b/lib/Instances/Transforms.i new file mode 100644 index 0000000..a242495 --- /dev/null +++ b/lib/Instances/Transforms.i @@ -0,0 +1,18 @@ +header #define ITK_MANUAL_INSTANTIATION + +define tr=AffineTransform + +tinclude itkOptimizerParameters:h|hxx +tinclude itkTransform:h|hxx +tinclude itkMatrixOffsetTransformBase:h|hxx +tinclude itk#tr#:h|hxx +tinclude itkDataObjectDecorator:h|hxx + +instances itk::OptimizerParameters< #real_types# > +instances itk::MatrixOffsetTransformBase< #real_types#, #process_dims#, #process_dims# > +instances itk::Transform< #real_types#, #process_dims#, #process_dims# > +instances itk::#tr#< #real_types#, #process_dims# > +instances itk::DataObjectDecorator< itk::Transform< #real_types#, #process_dims#, #process_dims# > > +instances itk::DataObjectDecorator< itk::#tr#< #real_types#, #process_dims# > > + +** eof - $RCSfile$ diff --git a/lib/cpExtensions/Algorithms/CPRImageFilter.h b/lib/cpExtensions/Algorithms/CPRImageFilter.h index 9161260..ed13da3 100644 --- a/lib/cpExtensions/Algorithms/CPRImageFilter.h +++ b/lib/cpExtensions/Algorithms/CPRImageFilter.h @@ -1,7 +1,9 @@ #ifndef __cpExtensions__Algorithms__CPRImageFilter__h__ #define __cpExtensions__Algorithms__CPRImageFilter__h__ +#include #include +#include #include namespace cpExtensions @@ -24,8 +26,11 @@ namespace cpExtensions typedef _TCurve TCurve; typedef typename TCurve::TScalar TScalar; - typedef IsoImageSlicer< TImage, TScalar > TSlicer; + typedef IsoImageSlicer< TImage, TScalar > TSlicer; typedef typename TSlicer::TInterpolateFunction TInterpolateFunction; + typedef typename TSlicer::TSliceImage TSliceImage; + + typedef itk::JoinSeriesImageFilter< TSliceImage, TImage > TJoinFilter; public: itkNewMacro( Self ); @@ -53,6 +58,9 @@ namespace cpExtensions protected: double m_SliceRadius; typename TInterpolateFunction::Pointer m_Interpolator; + + std::vector< typename TSlicer::Pointer > m_Slicers; + typename TJoinFilter::Pointer m_Join; }; } // ecapseman diff --git a/lib/cpExtensions/Algorithms/CPRImageFilter.hxx b/lib/cpExtensions/Algorithms/CPRImageFilter.hxx index b2b8d96..de76e7f 100644 --- a/lib/cpExtensions/Algorithms/CPRImageFilter.hxx +++ b/lib/cpExtensions/Algorithms/CPRImageFilter.hxx @@ -1,8 +1,6 @@ #ifndef __cpExtensions__Algorithms__CPRImageFilter__hxx__ #define __cpExtensions__Algorithms__CPRImageFilter__hxx__ -#include -#include #include // ------------------------------------------------------------------------- @@ -72,9 +70,7 @@ template< class _TImage, class _TCurve > void cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve >:: GenerateData( ) { - typedef itk::MinimumMaximumImageCalculator< _TImage > _TMinMax; - typedef itk::ImageSliceIteratorWithIndex< _TImage > _T3DIt; - typedef itk::ImageRegionIterator< typename TSlicer::TSliceImage > _T2DIt; + typedef itk::MinimumMaximumImageCalculator< _TImage > _TMinMax; auto input = this->GetInput( ); auto curve = this->GetCurve( ); @@ -85,50 +81,45 @@ GenerateData( ) 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( ); + // Main loop + this->m_Join = TJoinFilter::New( ); + this->m_Slicers.clear( ); unsigned long N = curve->GetNumberOfPoints( ); + double len = 0; + typename _TCurve::TPoint p, q; for( unsigned long n = 0; n < N; ++n ) { - slicer->SetTranslation( curve->GetPoint( n ) ); + p = curve->GetPoint( n ); + if( n > 0 ) + len += p.EuclideanDistanceTo( q ); + q = p; + + // 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( ); + slicer->SetTranslation( p ); 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 + this->m_Join->SetInput( n, slicer->GetOutput( ) ); + this->m_Slicers.push_back( slicer ); } // rof + this->m_Join->SetSpacing( len / double( N ) ); + this->m_Join->Update( ); + this->GetOutput( )->Graft( this->m_Join->GetOutput( ) ); } #endif // __cpExtensions__Algorithms__CPRImageFilter__hxx__ diff --git a/lib/cpExtensions/DataStructures/Simple3DCurve.cxx b/lib/cpExtensions/DataStructures/Simple3DCurve.cxx index cda4399..1d1a92e 100644 --- a/lib/cpExtensions/DataStructures/Simple3DCurve.cxx +++ b/lib/cpExtensions/DataStructures/Simple3DCurve.cxx @@ -50,6 +50,10 @@ GetFrame( unsigned int id ) const prev_no[ 1 ] = _TScalar( 1 ); for( unsigned int i = 0; i < N; ++i ) { + auto ntg = tg[ i ].GetNorm( ); + if( double( ntg ) > double( 0 ) ) + tg[ i ] /= ntg; + _TScalar ct = prev_tg * tg[ i ]; TVector a = itk::CrossProduct( prev_tg, tg[ i ] ); _TScalar st = a.GetNorm( ); @@ -60,6 +64,10 @@ GetFrame( unsigned int id ) const ( prev_no * ct ) + ( itk::CrossProduct( a, prev_no ) * st ) + ( a * ( ( a * prev_no ) * ( _TScalar( 1 ) - ct ) ) ); + auto nno = no[ i ].GetNorm( ); + if( double( nno ) > double( 0 ) ) + no[ i ] /= nno; + bn[ i ] = itk::CrossProduct( tg[ i ], no[ i ] ); prev_tg = tg[ i ]; @@ -80,7 +88,6 @@ GetFrame( unsigned int id ) const } // rof this->m_Frames.push_back( m ); - } // rof this->m_FramesUpdated = true; diff --git a/lib/cpPlugins/DataObjects/Simple3DCurve.cxx b/lib/cpPlugins/DataObjects/Simple3DCurve.cxx index 27097c9..7f79bba 100644 --- a/lib/cpPlugins/DataObjects/Simple3DCurve.cxx +++ b/lib/cpPlugins/DataObjects/Simple3DCurve.cxx @@ -2,24 +2,17 @@ #include #include +#include + // ------------------------------------------------------------------------- void cpPlugins::DataObjects::Simple3DCurve:: SetITK( itk::LightObject* o ) { - typedef cpExtensions::DataStructures::Simple3DCurve< float > _TF; - typedef cpExtensions::DataStructures::Simple3DCurve< double > _TD; - - this->Superclass::SetITK( o ); - auto lf = dynamic_cast< _TF* >( o ); - auto ld = dynamic_cast< _TD* >( o ); - if ( lf != NULL ) this->_ITK_2_VTK( lf ); - else if( ld != NULL ) this->_ITK_2_VTK( ld ); - else + cpPlugins_Demangle_Simple3DCurve_All_1( o, _ITK_2_VTK ) { this->m_VTK = NULL; this->m_ITKvVTK = NULL; - - } // fi + } } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/DataObjects/Simple3DCurve.d b/lib/cpPlugins/DataObjects/Simple3DCurve.d new file mode 100644 index 0000000..998b791 --- /dev/null +++ b/lib/cpPlugins/DataObjects/Simple3DCurve.d @@ -0,0 +1,4 @@ + +All cpExtensions::DataStructures::Simple3DCurve< #real_types# > + +** eof - $RCSfile$ diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index c8223be..fbe5996 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -48,6 +48,10 @@ TARGET_LINK_LIBRARIES( cpPluginsImageDistanceMaps cpPluginsImageThresholdFilters ) +TARGET_LINK_LIBRARIES( + cpPluginsImageSliceFilters + cpPluginsImageGenericFilters + ) IF(ParabolicMorphology_LOADED) TARGET_LINK_LIBRARIES( cpPluginsImageParaMorphologyFilters diff --git a/plugins/IO/ImageReader.cxx b/plugins/IO/ImageReader.cxx index 972ae5b..ffd3e8b 100644 --- a/plugins/IO/ImageReader.cxx +++ b/plugins/IO/ImageReader.cxx @@ -129,12 +129,12 @@ _GD0( itk::ImageIOBase* io ) if( ct == itk::ImageIOBase::LONG ) success = this->_GD1< long, _Dim >( io ); if( ct == itk::ImageIOBase::ULONG ) success = this->_GD1< ulong, _Dim >( io ); #endif // cpPlugins_CONFIG_INTEGER_TYPES_long -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_float +#ifdef cpPlugins_CONFIG_REAL_TYPES_float if( ct == itk::ImageIOBase::FLOAT ) success = this->_GD1< float, _Dim >( io ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_float -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_double +#endif // cpPlugins_CONFIG_REAL_TYPES_float +#ifdef cpPlugins_CONFIG_REAL_TYPES_double if( ct == itk::ImageIOBase::DOUBLE ) success = this->_GD1< double, _Dim >( io ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_double +#endif // cpPlugins_CONFIG_REAL_TYPES_double } else if( pt == itk::ImageIOBase::RGB ) { @@ -155,12 +155,12 @@ _GD0( itk::ImageIOBase* io ) if( ct == itk::ImageIOBase::LONG ) success = this->_GD1< itk::RGBPixel< long >, _Dim >( io ); if( ct == itk::ImageIOBase::ULONG ) success = this->_GD1< itk::RGBPixel< ulong >, _Dim >( io ); # endif // cpPlugins_CONFIG_INTEGER_TYPES_long -# ifdef cpPlugins_CONFIG_INTEGER_TYPES_float +# ifdef cpPlugins_CONFIG_REAL_TYPES_float if( ct == itk::ImageIOBase::FLOAT ) success = this->_GD1< itk::RGBPixel< float >, _Dim >( io ); -# endif // cpPlugins_CONFIG_INTEGER_TYPES_float -# ifdef cpPlugins_CONFIG_INTEGER_TYPES_double +# endif // cpPlugins_CONFIG_REAL_TYPES_float +# ifdef cpPlugins_CONFIG_REAL_TYPES_double if( ct == itk::ImageIOBase::DOUBLE ) success = this->_GD1< itk::RGBPixel< double >, _Dim >( io ); -# endif // cpPlugins_CONFIG_INTEGER_TYPES_double +# endif // cpPlugins_CONFIG_REAL_TYPES_double #endif // cpPlugins_CONFIG_COLOR_PIXELS_RGBPixel } else if( pt == itk::ImageIOBase::RGBA ) @@ -182,81 +182,81 @@ _GD0( itk::ImageIOBase* io ) if( ct == itk::ImageIOBase::LONG ) success = this->_GD1< itk::RGBAPixel< long >, _Dim >( io ); if( ct == itk::ImageIOBase::ULONG ) success = this->_GD1< itk::RGBAPixel< ulong >, _Dim >( io ); # endif // cpPlugins_CONFIG_INTEGER_TYPES_long -# ifdef cpPlugins_CONFIG_INTEGER_TYPES_float +# ifdef cpPlugins_CONFIG_REAL_TYPES_float if( ct == itk::ImageIOBase::FLOAT ) success = this->_GD1< itk::RGBAPixel< float >, _Dim >( io ); -# endif // cpPlugins_CONFIG_INTEGER_TYPES_float -# ifdef cpPlugins_CONFIG_INTEGER_TYPES_double +# endif // cpPlugins_CONFIG_REAL_TYPES_float +# ifdef cpPlugins_CONFIG_REAL_TYPES_double if( ct == itk::ImageIOBase::DOUBLE ) success = this->_GD1< itk::RGBAPixel< double >, _Dim >( io ); -# endif // cpPlugins_CONFIG_INTEGER_TYPES_double +# endif // cpPlugins_CONFIG_REAL_TYPES_double #endif // cpPlugins_CONFIG_COLOR_PIXELS_RGBAPixel } else if( pt == itk::ImageIOBase::COMPLEX ) { -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_float +#ifdef cpPlugins_CONFIG_REAL_TYPES_float if( ct == itk::ImageIOBase::FLOAT ) success = this->_GD1< std::complex< float >, _Dim >( io ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_float -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_double +#endif // cpPlugins_CONFIG_REAL_TYPES_float +#ifdef cpPlugins_CONFIG_REAL_TYPES_double if( ct == itk::ImageIOBase::DOUBLE ) success = this->_GD1< std::complex< double >, _Dim >( io ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_double +#endif // cpPlugins_CONFIG_REAL_TYPES_double } else if( pt == itk::ImageIOBase::COVARIANTVECTOR ) { -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_float +#ifdef cpPlugins_CONFIG_REAL_TYPES_float if( ct == itk::ImageIOBase::FLOAT ) success = this->_GD1< itk::CovariantVector< float, _Dim >, _Dim >( io ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_float -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_double +#endif // cpPlugins_CONFIG_REAL_TYPES_float +#ifdef cpPlugins_CONFIG_REAL_TYPES_double if( ct == itk::ImageIOBase::FLOAT ) success = this->_GD1< itk::CovariantVector< double, _Dim >, _Dim >( io ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_double +#endif // cpPlugins_CONFIG_REAL_TYPES_double } else if( pt == itk::ImageIOBase::POINT ) { -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_float +#ifdef cpPlugins_CONFIG_REAL_TYPES_float if( ct == itk::ImageIOBase::FLOAT ) success = this->_GD1< itk::Point< float, _Dim >, _Dim >( io ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_float -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_double +#endif // cpPlugins_CONFIG_REAL_TYPES_float +#ifdef cpPlugins_CONFIG_REAL_TYPES_double if( ct == itk::ImageIOBase::FLOAT ) success = this->_GD1< itk::Point< double, _Dim >, _Dim >( io ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_double +#endif // cpPlugins_CONFIG_REAL_TYPES_double } else if( pt == itk::ImageIOBase::VECTOR ) { -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_float +#ifdef cpPlugins_CONFIG_REAL_TYPES_float if( ct == itk::ImageIOBase::FLOAT ) success = this->_GD1< itk::Vector< float, _Dim >, _Dim >( io ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_float -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_double +#endif // cpPlugins_CONFIG_REAL_TYPES_float +#ifdef cpPlugins_CONFIG_REAL_TYPES_double if( ct == itk::ImageIOBase::FLOAT ) success = this->_GD1< itk::Vector< double, _Dim >, _Dim >( io ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_double +#endif // cpPlugins_CONFIG_REAL_TYPES_double } else if( pt == itk::ImageIOBase::SYMMETRICSECONDRANKTENSOR ) { -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_float +#ifdef cpPlugins_CONFIG_REAL_TYPES_float if( ct == itk::ImageIOBase::FLOAT ) success = this->_GD1< itk::SymmetricSecondRankTensor< float, _Dim >, _Dim >( io ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_float -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_double +#endif // cpPlugins_CONFIG_REAL_TYPES_float +#ifdef cpPlugins_CONFIG_REAL_TYPES_double if( ct == itk::ImageIOBase::FLOAT ) success = this->_GD1< itk::SymmetricSecondRankTensor< double, _Dim >, _Dim >( io ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_double +#endif // cpPlugins_CONFIG_REAL_TYPES_double } else if( pt == itk::ImageIOBase::DIFFUSIONTENSOR3D ) { if( _Dim == 3 ) { -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_float +#ifdef cpPlugins_CONFIG_REAL_TYPES_float if( ct == itk::ImageIOBase::FLOAT ) success = this->_GD1< itk::DiffusionTensor3D< float >, _Dim >( io ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_float -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_double +#endif // cpPlugins_CONFIG_REAL_TYPES_float +#ifdef cpPlugins_CONFIG_REAL_TYPES_double if( ct == itk::ImageIOBase::FLOAT ) success = this->_GD1< itk::DiffusionTensor3D< double >, _Dim >( io ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_double +#endif // cpPlugins_CONFIG_REAL_TYPES_double } else this->_Error( "DiffusionTensor3D dimension not supported." ); } else if( pt == itk::ImageIOBase::MATRIX ) { -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_float +#ifdef cpPlugins_CONFIG_REAL_TYPES_float if( ct == itk::ImageIOBase::FLOAT ) success = this->_GD1< itk::Matrix< float, _Dim, _Dim >, _Dim >( io ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_float -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_double +#endif // cpPlugins_CONFIG_REAL_TYPES_float +#ifdef cpPlugins_CONFIG_REAL_TYPES_double if( ct == itk::ImageIOBase::FLOAT ) success = this->_GD1< itk::Matrix< double, _Dim, _Dim >, _Dim >( io ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_double +#endif // cpPlugins_CONFIG_REAL_TYPES_double } else if( pt == itk::ImageIOBase::OFFSET ) { diff --git a/plugins/ImageGenericFilters/ImageGenericFilters.i b/plugins/ImageGenericFilters/ImageGenericFilters.i index 5ddb452..360bcbd 100644 --- a/plugins/ImageGenericFilters/ImageGenericFilters.i +++ b/plugins/ImageGenericFilters/ImageGenericFilters.i @@ -3,11 +3,13 @@ header #define ITK_MANUAL_INSTANTIATION tinclude itkRegionOfInterestImageFilter:h|hxx tinclude itkRescaleIntensityImageFilter:h|hxx tinclude itkMinimumMaximumImageCalculator:h|hxx +tinclude itkExtractImageFilter:h|hxx cinclude itk#color_pixels#.h cinclude itkImageAlgorithm.hxx cinclude itkUnaryFunctorImageFilter.hxx +instances itk::ExtractImageFilter< itk::Image< #scalar_pixels#, 3 >, itk::Image< #scalar_pixels#, 2 > > instances itk::RegionOfInterestImageFilter< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #scalar_pixels#, #process_dims# > > instances itk::RegionOfInterestImageFilter< itk::Image< itk::#color_pixels#< #scalar_pixels# >, #process_dims# >, itk::Image< itk::#color_pixels#< #scalar_pixels# >, #process_dims# > > diff --git a/plugins/ImageSliceFilters/CPRImageFilter.cxx b/plugins/ImageSliceFilters/CPRImageFilter.cxx new file mode 100644 index 0000000..4e80ed2 --- /dev/null +++ b/plugins/ImageSliceFilters/CPRImageFilter.cxx @@ -0,0 +1,66 @@ +#include +#include +#include + +#include +#include + +#include +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsImageSliceFilters::CPRImageFilter:: +CPRImageFilter( ) + : Superclass( ) +{ + typedef cpPlugins::DataObjects::Image _TImage; + typedef cpPlugins::DataObjects::Simple3DCurve _TCurve; + this->_ConfigureInput< _TImage >( "Image", true, false ); + this->_ConfigureInput< _TCurve >( "Curve", true, false ); + this->_ConfigureOutput< _TImage >( "Output" ); + + this->m_Parameters.ConfigureAsReal( "SliceRadius", 1 ); +} + +// ------------------------------------------------------------------------- +cpPluginsImageSliceFilters::CPRImageFilter:: +~CPRImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginsImageSliceFilters::CPRImageFilter:: +_GenerateData( ) +{ + auto o = this->GetInputData( "Image" ); + cpPlugins_Demangle_Image_ScalarPixels_1( o, _GD0, 3 ) + this->_Error( "Invalid input image." ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +void cpPluginsImageSliceFilters::CPRImageFilter:: +_GD0( _TImage* image ) +{ + auto o = this->GetInputData( "Curve" ); + cpPlugins_Demangle_Simple3DCurve_All_2( o, _GD1, image ) + this->_Error( "Invalid input curve." ); +} + +// ------------------------------------------------------------------------- +template< class _TCurve, class _TImage > +void cpPluginsImageSliceFilters::CPRImageFilter:: +_GD1( _TCurve* curve, _TImage* image ) +{ + typedef cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve > _TFilter; + + auto filter = this->_CreateITK< _TFilter >( ); + filter->SetInput( image ); + filter->SetCurve( curve ); + filter->SetSliceRadius( this->m_Parameters.GetReal( "SliceRadius" ) ); + filter->Update( ); + this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); +} + +// eof - $RCSfile$ diff --git a/plugins/ImageSliceFilters/CPRImageFilter.h b/plugins/ImageSliceFilters/CPRImageFilter.h new file mode 100644 index 0000000..faab230 --- /dev/null +++ b/plugins/ImageSliceFilters/CPRImageFilter.h @@ -0,0 +1,32 @@ +#ifndef __cpPluginsImageSliceFilters__CPRImageFilter__h__ +#define __cpPluginsImageSliceFilters__CPRImageFilter__h__ + +#include +#include + +namespace cpPluginsImageSliceFilters +{ + /** + */ + class cpPluginsImageSliceFilters_EXPORT CPRImageFilter + : public cpPlugins::BaseObjects::ProcessObject + { + cpPluginsObject( + CPRImageFilter, + cpPlugins::BaseObjects::ProcessObject, + ImageSliceFilters + ); + + protected: + template< class _TImage > + inline void _GD0( _TImage* image ); + + template< class _TCurve, class _TImage > + inline void _GD1( _TCurve* curve, _TImage* image ); + }; + +} // ecapseman + +#endif // __cpPluginsImageSliceFilters__CPRImageFilter__h__ + +// eof - $RCSfile$ diff --git a/plugins/ImageSliceFilters/ImageSliceFilters.i b/plugins/ImageSliceFilters/ImageSliceFilters.i index 69bbbd5..e2fdf0d 100644 --- a/plugins/ImageSliceFilters/ImageSliceFilters.i +++ b/plugins/ImageSliceFilters/ImageSliceFilters.i @@ -1,6 +1,19 @@ +header #define ITK_MANUAL_INSTANTIATION tinclude cpExtensions/Algorithms/CPRImageFilter:h|hxx +tinclude cpExtensions/Algorithms/IsoImageSlicer:h|hxx +tinclude itkResampleImageFilter:h|hxx +tinclude itkJoinSeriesImageFilter:h|hxx + cinclude cpExtensions/DataStructures/Simple3DCurve.h +cinclude itkImageAlgorithm.hxx + +instances itk::ResampleImageFilter< itk::Image< #scalar_pixels#, 3u >, itk::Image< #scalar_pixels#, 3u >, #real_types#, #real_types# > + +instances itk::JoinSeriesImageFilter< itk::Image< #scalar_types#, 2 >, itk::Image< #scalar_types#, 3 > > + +instances cpExtensions::Algorithms::BaseImageSlicer< itk::ResampleImageFilter< itk::Image< #scalar_pixels#, 3u >, itk::Image< #scalar_pixels#, 3u >, #real_types#, #real_types# >, itk::InterpolateImageFunction< itk::Image< #scalar_pixels#, 3u >, #real_types# > > + instances cpExtensions::Algorithms::CPRImageFilter< itk::Image< #scalar_pixels#, 3 >, cpExtensions::DataStructures::Simple3DCurve< #real_types# > > -- 2.47.1