From 7ff425303898b812f8a85a312cfa415dd0c1abc7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Thu, 1 Dec 2016 17:23:41 -0500 Subject: [PATCH] ... --- lib/cpExtensions/DataStructures/Skeleton.h | 2 + lib/cpInstances/CMakeLists.txt | 3 ++ plugins/CMakeLists.txt | 7 +-- .../PolyLineParametricPathToSimple3DCurve.h | 26 --------- plugins/ITKIO/ImageReader.cxx | 15 ++++-- .../ImageToBoundingBoxFromThreshold.cxx | 2 + .../PolyLineParametricPathToSimple3DCurve.cxx | 9 ++-- .../PolyLineParametricPathToSimple3DCurve.h | 26 +++++++++ .../cpExtensions/SkeletonToImageFilter.cxx | 54 +++++++++++++++++++ plugins/cpExtensions/SkeletonToImageFilter.h | 30 +++++++++++ plugins/cpExtensions/cpExtensions.i | 8 +++ 11 files changed, 142 insertions(+), 40 deletions(-) delete mode 100644 plugins/Extensions/PolyLineParametricPathToSimple3DCurve.h rename plugins/{Extensions => cpExtensions}/PolyLineParametricPathToSimple3DCurve.cxx (85%) create mode 100644 plugins/cpExtensions/PolyLineParametricPathToSimple3DCurve.h create mode 100644 plugins/cpExtensions/SkeletonToImageFilter.cxx create mode 100644 plugins/cpExtensions/SkeletonToImageFilter.h create mode 100644 plugins/cpExtensions/cpExtensions.i diff --git a/lib/cpExtensions/DataStructures/Skeleton.h b/lib/cpExtensions/DataStructures/Skeleton.h index f30b601..9d0bd9b 100644 --- a/lib/cpExtensions/DataStructures/Skeleton.h +++ b/lib/cpExtensions/DataStructures/Skeleton.h @@ -20,6 +20,8 @@ namespace cpExtensions typedef typename TIndex::LexicographicCompare TIndexCompare; typedef typename TPath::Pointer TPathPointer; + itkStaticConstMacro( Dimension, unsigned int, _VDim ); + typedef Graph< TIndex, TPathPointer, TIndex, TIndexCompare > Superclass; typedef Skeleton Self; typedef itk::SmartPointer< Self > Pointer; diff --git a/lib/cpInstances/CMakeLists.txt b/lib/cpInstances/CMakeLists.txt index fc1eb7e..ece1f31 100644 --- a/lib/cpInstances/CMakeLists.txt +++ b/lib/cpInstances/CMakeLists.txt @@ -71,6 +71,9 @@ CreateLib( ${CMAKE_CURRENT_SOURCE_DIR}/Skeleton.cxx ${CMAKE_CURRENT_SOURCE_DIR}/Skeleton.h ${CMAKE_CURRENT_SOURCE_DIR}/Skeleton.d + ${CMAKE_CURRENT_SOURCE_DIR}/Simple3DCurve.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/Simple3DCurve.h + ${CMAKE_CURRENT_SOURCE_DIR}/Simple3DCurve.d ) TARGET_LINK_LIBRARIES( diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index c398949..53d00f8 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -20,12 +20,7 @@ SET( ITKSeparableFilters ITKMorphology ITKParaMorphology - #ITKSliceFilters - #ITKGenericFilters - #ImageParaMorphologyFilters - #ImageThresholdFilters - #ImageGradientFilters - #Extensions + cpExtensions ) ## =============================== diff --git a/plugins/Extensions/PolyLineParametricPathToSimple3DCurve.h b/plugins/Extensions/PolyLineParametricPathToSimple3DCurve.h deleted file mode 100644 index 2a11a09..0000000 --- a/plugins/Extensions/PolyLineParametricPathToSimple3DCurve.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef __cpPluginsExtensions__PolyLineParametricPathToSimple3DCurve__h__ -#define __cpPluginsExtensions__PolyLineParametricPathToSimple3DCurve__h__ - -#include -#include - -namespace cpPluginsExtensions -{ - /** - */ - class cpPluginsExtensions_EXPORT PolyLineParametricPathToSimple3DCurve - : public cpPlugins::BaseObjects::ProcessObject - { - cpPluginsObject( - PolyLineParametricPathToSimple3DCurve, - cpPlugins::BaseObjects::ProcessObject, - Extensions - ); - }; - -} // ecapseman - -#endif // __cpPluginsExtensions__PolyLineParametricPathToSimple3DCurve__h__ - - -// eof - $RCSfile$ diff --git a/plugins/ITKIO/ImageReader.cxx b/plugins/ITKIO/ImageReader.cxx index 64d63a2..b336078 100644 --- a/plugins/ITKIO/ImageReader.cxx +++ b/plugins/ITKIO/ImageReader.cxx @@ -55,12 +55,18 @@ _GenerateData( ) { // Get filenames auto fnames = this->m_Parameters.GetOpenFileNameList( "FileNames" ); + std::string fname = ""; if( fnames.size( ) > 1 ) { std::stringstream fname_str; fname_str << fnames[ 0 ] << cpPlugins_PATH_SEPARATOR << fnames[ 1 ]; - std::string fname = fname_str.str( ); + fname = fname_str.str( ); + } + else if( fnames.size( ) == 1 ) + fname = fnames[ 0 ]; + if( fname != "" ) + { // Guess image properties itk::ImageIOBase::Pointer io = itk::ImageIOFactory::CreateImageIO( @@ -210,10 +216,13 @@ _GD1( itk::ImageIOBase* io ) // Get filenames auto fnames = this->m_Parameters.GetOpenFileNameList( "FileNames" ); - if( fnames.size( ) == 2 ) + if( fnames.size( ) == 1 || fnames.size( ) == 2 ) { std::stringstream fname_str; - fname_str << fnames[ 0 ] << cpPlugins_PATH_SEPARATOR << fnames[ 1 ]; + if( fnames.size( ) == 1 ) + fname_str << fnames[ 0 ]; + else + fname_str << fnames[ 0 ] << cpPlugins_PATH_SEPARATOR << fnames[ 1 ]; auto f = this->_CreateITK< itk::ImageFileReader< _TImage > >( ); f->SetFileName( fname_str.str( ) ); diff --git a/plugins/ITKImageGenericFilters_1/ImageToBoundingBoxFromThreshold.cxx b/plugins/ITKImageGenericFilters_1/ImageToBoundingBoxFromThreshold.cxx index a93ba35..ca309c6 100644 --- a/plugins/ITKImageGenericFilters_1/ImageToBoundingBoxFromThreshold.cxx +++ b/plugins/ITKImageGenericFilters_1/ImageToBoundingBoxFromThreshold.cxx @@ -15,6 +15,7 @@ ImageToBoundingBoxFromThreshold( ) this->m_Parameters.ConfigureAsReal( "LowerThreshold", 0 ); this->m_Parameters.ConfigureAsReal( "UpperThreshold", 1 ); + this->m_Parameters.ConfigureAsUint( "PAD", 0 ); } // ------------------------------------------------------------------------- @@ -46,6 +47,7 @@ _GD0( _TImage* image ) filter->SetImage( image ); filter->SetLowerThreshold( this->m_Parameters.GetReal( "LowerThreshold" ) ); filter->SetUpperThreshold( this->m_Parameters.GetReal( "UpperThreshold" ) ); + filter->SetPAD( this->m_Parameters.GetUint( "PAD" ) ); filter->Compute( ); // Create output diff --git a/plugins/Extensions/PolyLineParametricPathToSimple3DCurve.cxx b/plugins/cpExtensions/PolyLineParametricPathToSimple3DCurve.cxx similarity index 85% rename from plugins/Extensions/PolyLineParametricPathToSimple3DCurve.cxx rename to plugins/cpExtensions/PolyLineParametricPathToSimple3DCurve.cxx index ec6cc01..ec1cc9e 100644 --- a/plugins/Extensions/PolyLineParametricPathToSimple3DCurve.cxx +++ b/plugins/cpExtensions/PolyLineParametricPathToSimple3DCurve.cxx @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -7,7 +7,7 @@ #include // ------------------------------------------------------------------------- -cpPluginsExtensions::PolyLineParametricPathToSimple3DCurve:: +cpPluginscpExtensions::PolyLineParametricPathToSimple3DCurve:: PolyLineParametricPathToSimple3DCurve( ) : Superclass( ) { @@ -19,13 +19,13 @@ PolyLineParametricPathToSimple3DCurve( ) } // ------------------------------------------------------------------------- -cpPluginsExtensions::PolyLineParametricPathToSimple3DCurve:: +cpPluginscpExtensions::PolyLineParametricPathToSimple3DCurve:: ~PolyLineParametricPathToSimple3DCurve( ) { } // ------------------------------------------------------------------------- -void cpPluginsExtensions::PolyLineParametricPathToSimple3DCurve:: +void cpPluginscpExtensions::PolyLineParametricPathToSimple3DCurve:: _GenerateData( ) { typedef cpExtensions::DataStructures::PolyLineParametricPath< 3 > _TPath; @@ -41,7 +41,6 @@ _GenerateData( ) filter->SetNumberOfSamples( this->m_Parameters.GetUint( "NumberOfSamples" ) ); filter->Update( ); this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); - } // eof - $RCSfile$ diff --git a/plugins/cpExtensions/PolyLineParametricPathToSimple3DCurve.h b/plugins/cpExtensions/PolyLineParametricPathToSimple3DCurve.h new file mode 100644 index 0000000..8c7c08d --- /dev/null +++ b/plugins/cpExtensions/PolyLineParametricPathToSimple3DCurve.h @@ -0,0 +1,26 @@ +#ifndef __cpPluginscpExtensions__PolyLineParametricPathToSimple3DCurve__h__ +#define __cpPluginscpExtensions__PolyLineParametricPathToSimple3DCurve__h__ + +#include +#include + +namespace cpPluginscpExtensions +{ + /** + */ + class cpPluginscpExtensions_EXPORT PolyLineParametricPathToSimple3DCurve + : public cpPlugins::BaseObjects::ProcessObject + { + cpPluginsObject( + PolyLineParametricPathToSimple3DCurve, + cpPlugins::BaseObjects::ProcessObject, + cpExtensions + ); + }; + +} // ecapseman + +#endif // __cpPluginscpExtensions__PolyLineParametricPathToSimple3DCurve__h__ + + +// eof - $RCSfile$ diff --git a/plugins/cpExtensions/SkeletonToImageFilter.cxx b/plugins/cpExtensions/SkeletonToImageFilter.cxx new file mode 100644 index 0000000..6b5e5a7 --- /dev/null +++ b/plugins/cpExtensions/SkeletonToImageFilter.cxx @@ -0,0 +1,54 @@ +#include +#include +#include + +#include +#include + +// ------------------------------------------------------------------------- +cpPluginscpExtensions::SkeletonToImageFilter:: +SkeletonToImageFilter( ) + : Superclass( ) +{ + this->_ConfigureInput< cpInstances::Skeleton >( "Skeleton", true, false ); + this->_ConfigureInput< cpInstances::Image >( "TemplateImage", true, false ); + this->_ConfigureOutput< cpInstances::Image >( "Output" ); + this->m_Parameters.ConfigureAsUint( "InsideValue", 1 ); + this->m_Parameters.ConfigureAsUint( "OutsideValue", 0 ); +} + +// ------------------------------------------------------------------------- +cpPluginscpExtensions::SkeletonToImageFilter:: +~SkeletonToImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginscpExtensions::SkeletonToImageFilter:: +_GenerateData( ) +{ + auto o = this->GetInputData( "Skeleton" ); + cpPlugins_Demangle_Skeleton_All_1( o, _GD0 ) + this->_Error( "Invalid input skeleton." ); +} + +// ------------------------------------------------------------------------- +template< class _TSkeleton > +void cpPluginscpExtensions::SkeletonToImageFilter:: +_GD0( _TSkeleton* skeleton ) +{ + typedef itk::ImageBase< _TSkeleton::Dimension > _TImageBase; + typedef itk::Image< unsigned char, _TSkeleton::Dimension > _TImage; + typedef cpExtensions::Algorithms::SkeletonToImageFilter< _TSkeleton, _TImage > _TFilter; + + auto image = this->GetInputData< _TImageBase >( "TemplateImage" ); + auto filter = this->_CreateITK< _TFilter >( ); + filter->SetTemplateImage( image ); + filter->SetSkeleton( skeleton ); + filter->SetInsideValue( this->m_Parameters.GetUint( "InsideValue" ) ); + filter->SetOutsideValue( this->m_Parameters.GetUint( "OutsideValue" ) ); + filter->Update( ); + this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); +} + +// eof - $RCSfile$ diff --git a/plugins/cpExtensions/SkeletonToImageFilter.h b/plugins/cpExtensions/SkeletonToImageFilter.h new file mode 100644 index 0000000..6f7229e --- /dev/null +++ b/plugins/cpExtensions/SkeletonToImageFilter.h @@ -0,0 +1,30 @@ +#ifndef __cpPluginscpExtensions__SkeletonToImageFilter__h__ +#define __cpPluginscpExtensions__SkeletonToImageFilter__h__ + +#include +#include + +namespace cpPluginscpExtensions +{ + /** + */ + class cpPluginscpExtensions_EXPORT SkeletonToImageFilter + : public cpPlugins::BaseObjects::ProcessObject + { + cpPluginsObject( + SkeletonToImageFilter, + cpPlugins::BaseObjects::ProcessObject, + cpExtensions + ); + + protected: + template< class _TSkeleton > + inline void _GD0( _TSkeleton* skeleton ); + }; + +} // ecapseman + +#endif // __cpPluginscpExtensions__SkeletonToImageFilter__h__ + + +// eof - $RCSfile$ diff --git a/plugins/cpExtensions/cpExtensions.i b/plugins/cpExtensions/cpExtensions.i new file mode 100644 index 0000000..f0099eb --- /dev/null +++ b/plugins/cpExtensions/cpExtensions.i @@ -0,0 +1,8 @@ +header #define ITK_MANUAL_INSTANTIATION + +tinclude cpExtensions/Algorithms/SkeletonToImageFilter:h|hxx +cinclude cpExtensions/DataStructures/Skeleton.h + +instances cpExtensions::Algorithms::SkeletonToImageFilter< cpExtensions::DataStructures::Skeleton< #pdims# > , itk::Image< unsigned char, #pdims# > > + +** eof - $RCSfile$ -- 2.47.1