]> Creatis software - cpPlugins.git/commitdiff
plugin filter machete
authorJose Luis Guzman <cycopepe@gmail.com>
Mon, 19 Oct 2015 21:25:22 +0000 (23:25 +0200)
committerJose Luis Guzman <cycopepe@gmail.com>
Mon, 19 Oct 2015 21:25:22 +0000 (23:25 +0200)
lib/cpExtensions/Algorithms/MacheteImageFilter.hxx
lib/cpPlugins/Plugins/BasicFilters/MacheteImageFilter.cxx [new file with mode: 0644]
lib/cpPlugins/Plugins/BasicFilters/MacheteImageFilter.h [new file with mode: 0644]

index 4da94282055c51900c3d13aba16d62ac9b757fff..4a381498fecd3638d6c777f8b6f7b703741f6efa 100644 (file)
@@ -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<I> outputIterator(output, output->GetLargestPossibleRegion());
-  itk::ImageRegionConstIterator<O> inputIterator(input, input->GetLargestPossibleRegion());
+  itk::ImageRegionIterator<O> outputIterator(output, output->GetLargestPossibleRegion());
+  itk::ImageRegionConstIterator<I> 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 (file)
index 0000000..ff4e03a
--- /dev/null
@@ -0,0 +1,93 @@
+#include "MacheteImageFilter.h"
+#include <cpPlugins/Interface/Image.h>
+
+//#include <MacheteImageFilter.h>
+#include <itkImage.h>
+#include <itkBinaryBallStructuringElement.h>
+
+#include <cpExtensions/Algorithms/MacheteImageFilter.h>
+
+// -------------------------------------------------------------------------
+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 (file)
index 0000000..ab7a6e9
--- /dev/null
@@ -0,0 +1,60 @@
+#ifndef __CPPLUGINS__PLUGINS__MACHETEIMAGEFILTER__H__
+#define __CPPLUGINS__PLUGINS__MACHETEIMAGEFILTER__H__
+
+#include <cpPlugins/BasicFilters/cpPluginsBasicFilters_Export.h>
+#include <cpPlugins/Interface/BaseProcessObjects.h>
+
+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$