example_BaseInteractorStyle
example_ContourWidget
example_Test_async
+ ## example_MacheteFilter
## example_Test_DoubleClick
## example_ExtractDICOMSeries
## example_ImageGaussianModelEstimator
--- /dev/null
+#include <itkImage.h>
+#include <itkImageFileReader.h>
+#include "itkImageFileWriter.h"
+#include <itkRescaleIntensityImageFilter.h>
+
+#include <iostream>
+
+//#include "MacheteImageFilter.h"
+#include "itkObjectFactory.h"
+#include "itkImageRegionIterator.h"
+#include "itkImageRegionConstIterator.h"
+
+#include <cpExtensions/Algorithms/MacheteImageFilter.h>
+
+
+int main(int, char*[])
+{
+ std::cout << "Machete image filter";
+
+ // 1. work with the filter
+ typedef itk::Image<unsigned char, 2> ImageType;
+ ImageType::Pointer image;
+
+ typedef itk::ImageFileReader<ImageType> ReaderType;
+ ReaderType::Pointer reader = ReaderType::New();
+ reader->SetFileName("c://img//lung.jpg");
+ image = reader->GetOutput();
+
+ typedef cpExtensions::Algorithms::MacheteImageFilter<ImageType, ImageType> FilterType;
+
+ FilterType::Pointer filter = FilterType::New();
+ filter->SetInput(image);
+ filter->SetRadius(151);
+
+ itk::Point<double, 3> p0;
+ p0[0] = 250.0;
+ p0[1] = 250.0;
+ p0[2] = 0.0;
+
+ filter->SetPoint(p0);
+ filter->Update();
+
+ // 2. write result
+
+ typedef itk::ImageFileWriter< ImageType > WriterType;
+ WriterType::Pointer writer = WriterType::New();
+ writer->SetFileName("c://img//out.jpg");
+ writer->SetInput(filter->GetOutput());
+ writer->Update();
+
+ // 3.display result visualization
+
+ /* vtkSmartPointer<vtkImageActor> actor =
+ vtkSmartPointer<vtkImageActor>::New();
+#if VTK_MAJOR_VERSION <= 5
+ actor->SetInput(connector->GetOutput());
+#else
+ connector->Update();
+ actor->GetMapper()->SetInputData(connector->GetOutput());
+#endif
+ vtkSmartPointer<vtkRenderer> renderer =
+ vtkSmartPointer<vtkRenderer>::New();
+ renderer->AddActor(actor);
+ renderer->ResetCamera();
+
+ vtkSmartPointer<vtkRenderWindow> renderWindow =
+ vtkSmartPointer<vtkRenderWindow>::New();
+ renderWindow->AddRenderer(renderer);
+
+ vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
+ vtkSmartPointer<vtkRenderWindowInteractor>::New();
+ vtkSmartPointer<vtkInteractorStyleImage> style =
+ vtkSmartPointer<vtkInteractorStyleImage>::New();
+
+ renderWindowInteractor->SetInteractorStyle(style);
+
+ renderWindowInteractor->SetRenderWindow(renderWindow);
+ renderWindowInteractor->Initialize();
+
+ renderWindowInteractor->Start();*/
+
+ return 0;
+}
\ No newline at end of file
--- /dev/null
+// -------------------------------------------------------------------------
+// @author Jose Luis Guzman (cycopepe@gmail.com)
+// -------------------------------------------------------------------------
+
+
+#ifndef __CPEXTENSIONS__ALGORITHMS__MACHETEIMAGEFILTER__H__
+#define __CPEXTENSIONS__ALGORITHMS__MACHETEIMAGEFILTER__H__
+
+#include <cpExtensions/cpExtensions_Export.h>
+
+#include <itkImageToImageFilter.h>
+
+namespace cpExtensions
+{
+ namespace Algorithms
+ {
+ template< class I, class O>
+ class MacheteImageFilter :public itk::ImageToImageFilter < I, O >
+ {
+ public:
+ /** Standard class typedefs. */
+ typedef MacheteImageFilter Self;
+
+ typedef itk::ImageToImageFilter< I, O > Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+
+ /** Method for creation through the object factory. */
+ itkNewMacro(Self);
+
+ /** Run-time type information (and related methods). */
+ itkTypeMacro(MacheteImageFilter, ImageToImageFilter);
+
+ void SetRadius(double radius);
+ void SetPoint(itk::Point<double, 3> point);
+
+ protected:
+ MacheteImageFilter(){}
+ ~MacheteImageFilter(){}
+
+ /** Does the real work. */
+ virtual void GenerateData();
+
+
+ private:
+ MacheteImageFilter(const Self &); //purposely not implemented
+ void operator=(const Self &); //purposely not implemented
+
+ double radius;
+ itk::Point<double, 3> point;
+ };
+
+ } // ecapseman
+
+} // ecapseman
+
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include <cpExtensions/Algorithms/MacheteImageFilter.hxx>
+#endif
+
+
+#endif // __CPEXTENSIONS__ALGORITHMS__MACHETEIMAGEFILTER__H__
\ No newline at end of file
--- /dev/null
+#ifndef __CPEXTENSIONS__ALGORITHMS__MACHETEIMAGEFILTER__HXX__
+#define __CPEXTENSIONS__ALGORITHMS__MACHETEIMAGEFILTER__HXX__
+
+#include <cpExtensions/Algorithms/MacheteImageFilter.h>
+
+//filter stuff
+#include "itkObjectFactory.h"
+#include "itkImageRegionIterator.h"
+#include "itkImageRegionConstIterator.h"
+
+//typedef itk::Image<unsigned char, 2> ImageType;
+
+template< class I, class O>
+void cpExtensions::Algorithms::MacheteImageFilter< I, O>
+::GenerateData()
+{
+ 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());
+
+ while (!outputIterator.IsAtEnd())
+ {
+ auto p0 = inputIterator.GetIndex();
+ itk::Point<double, 3> otherPoint;
+ otherPoint[0] = p0[0];
+ otherPoint[1] = p0[1];
+ otherPoint[2] = p0[2];
+ otherPoint[2] = this->point[2]; // TODO : Solve this hammer
+
+ double dist = this->point.EuclideanDistanceTo(otherPoint);
+ if (dist <= this->radius)
+ {
+ outputIterator.Set(0);
+ }
+ else
+ {
+ outputIterator.Set(inputIterator.Get());
+ }
+
+ ++inputIterator;
+ ++outputIterator;
+ }
+
+}
+
+template< class I, class O>
+void cpExtensions::Algorithms::MacheteImageFilter< I, O>::SetRadius(double rad){
+ this->radius = rad;
+}
+
+template< class I, class O>
+void cpExtensions::Algorithms::MacheteImageFilter< I, O>::SetPoint(itk::Point<double, 3> point){
+ this->point = point;
+}
+
+
+
+
+#endif
\ No newline at end of file