From: Jose Luis Guzman Date: Mon, 19 Oct 2015 21:25:22 +0000 (+0200) Subject: plugin filter machete X-Git-Tag: v0.1~327^2 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=053d8cf79b27bbef92a92a076d67e1b94fa509d1;p=cpPlugins.git plugin filter machete --- diff --git a/lib/cpExtensions/Algorithms/MacheteImageFilter.hxx b/lib/cpExtensions/Algorithms/MacheteImageFilter.hxx index 4da9428..4a38149 100644 --- a/lib/cpExtensions/Algorithms/MacheteImageFilter.hxx +++ b/lib/cpExtensions/Algorithms/MacheteImageFilter.hxx @@ -14,14 +14,16 @@ template< class I, class O> void cpExtensions::Algorithms::MacheteImageFilter< I, O> ::GenerateData() { + //const typename Superclass::OutputImageRegionType& region; + typename I::ConstPointer input = this->GetInput(); typename O::Pointer output = this->GetOutput(); output->SetRegions(input->GetLargestPossibleRegion()); output->Allocate(); - itk::ImageRegionIterator outputIterator(output, output->GetLargestPossibleRegion()); - itk::ImageRegionConstIterator inputIterator(input, input->GetLargestPossibleRegion()); + itk::ImageRegionIterator outputIterator(output, output->GetLargestPossibleRegion()); + itk::ImageRegionConstIterator inputIterator(input, input->GetLargestPossibleRegion()); while (!outputIterator.IsAtEnd()) { diff --git a/lib/cpPlugins/Plugins/BasicFilters/MacheteImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/MacheteImageFilter.cxx new file mode 100644 index 0000000..ff4e03a --- /dev/null +++ b/lib/cpPlugins/Plugins/BasicFilters/MacheteImageFilter.cxx @@ -0,0 +1,93 @@ +#include "MacheteImageFilter.h" +#include + +//#include +#include +#include + +#include + +// ------------------------------------------------------------------------- +cpPlugins::BasicFilters::MacheteImageFilter:: +MacheteImageFilter( ) + : Superclass( ) +{ + this->_AddInput( "Input" ); + this->_MakeOutput< cpPlugins::Interface::Image >( "Output" ); + + this->m_Parameters->ConfigureAsUint( "Radius", 2 ); + +} + +// ------------------------------------------------------------------------- +cpPlugins::BasicFilters::MacheteImageFilter:: +~MacheteImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +std::string cpPlugins::BasicFilters::MacheteImageFilter:: +_GenerateData( ) +{ + cpPlugins::Interface::Image* image = + this->GetInput< cpPlugins::Interface::Image >( "Input" ); + if( image == NULL ) + return( "MacheteImageFilter: No input image." ); + + itk::DataObject* itk_image = NULL; + std::string r = ""; + cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 ); + else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 ); + else cpPlugins_Image_Demangle_AllScalarTypes( 4, image, itk_image, r, _GD0 ); + else r = "MacheteImageFilter: Input image type not supported."; + return( r ); +} + +// ------------------------------------------------------------------------- +template< class I > +std::string cpPlugins::BasicFilters::MacheteImageFilter:: +_GD0( itk::DataObject* image ) +{ + return( + this->_RealGD< I, itk::Image< unsigned char, I::ImageDimension > >( + image + ) + ); +} + +// ------------------------------------------------------------------------- +template< class I, class O > +inline std::string cpPlugins::BasicFilters::MacheteImageFilter:: +_RealGD( itk::DataObject* image ) +{ + typedef cpExtensions::Algorithms::MacheteImageFilter< I, O > _F; + //typedef typename _F::radius _RT; + + // Get parameters + //_RT rad_val; + //rad_val.Fill( this->m_Parameters->GetUint( "Radius" ) ); + + // Configure filter + + _F* filter = this->_CreateITK< _F >(); + filter->SetInput(dynamic_cast< I* >(image)); + filter->SetRadius(this->m_Parameters->GetUint("Radius")); + filter->Update(); + + //_F* filter = this->_CreateITK< _F >( ); + //filter->SetInput( dynamic_cast< I* >( image ) ); + //filter->Update( ); + + // Connect output + cpPlugins::Interface::Image* out = + this->GetOutput< cpPlugins::Interface::Image >( "Output" ); + if( out != NULL ) + { + //out->SetITK< O >( filter->GetOutput( ) ); + return( "" ); + } + else + return( "MacheteImageFilter: output not correctly created." ); +} + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/BasicFilters/MacheteImageFilter.h b/lib/cpPlugins/Plugins/BasicFilters/MacheteImageFilter.h new file mode 100644 index 0000000..ab7a6e9 --- /dev/null +++ b/lib/cpPlugins/Plugins/BasicFilters/MacheteImageFilter.h @@ -0,0 +1,60 @@ +#ifndef __CPPLUGINS__PLUGINS__MACHETEIMAGEFILTER__H__ +#define __CPPLUGINS__PLUGINS__MACHETEIMAGEFILTER__H__ + +#include +#include + +namespace cpPlugins +{ + namespace BasicFilters + { + /** + */ + class cpPluginsBasicFilters_EXPORT MacheteImageFilter + : public cpPlugins::Interface::ImageToImageFilter + { + public: + typedef MacheteImageFilter Self; + typedef cpPlugins::Interface::ImageToImageFilter Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( + MacheteImageFilter, + cpPluginsInterfaceImageToImageFilter + ); + cpPlugins_Id_Macro( + cpPlugins::BasicFilters::MacheteImageFilter, + "ImageToImageFilter" + ); + + protected: + MacheteImageFilter( ); + virtual ~MacheteImageFilter( ); + + virtual std::string _GenerateData( ); + + template< class I > + inline std::string _GD0( itk::DataObject* image ); + + template< class I, class O > + inline std::string _RealGD( itk::DataObject* image ); + + private: + // Purposely not implemented + MacheteImageFilter( const Self& ); + Self& operator=( const Self& ); + }; + + // --------------------------------------------------------------------- + CPPLUGINS_INHERIT_PROVIDER( MacheteImageFilter ); + + } // ecapseman + +} // ecapseman + +#endif // __CPPLUGINS__PLUGINS__MacheteImageFilter__H__ + +// eof - $RCSfile$