]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Algorithms/MacheteImageFilter.hxx
plugin filter machete
[cpPlugins.git] / lib / cpExtensions / Algorithms / MacheteImageFilter.hxx
1 #ifndef __CPEXTENSIONS__ALGORITHMS__MACHETEIMAGEFILTER__HXX__
2 #define __CPEXTENSIONS__ALGORITHMS__MACHETEIMAGEFILTER__HXX__
3
4 #include <cpExtensions/Algorithms/MacheteImageFilter.h>
5
6 //filter stuff
7 #include "itkObjectFactory.h"
8 #include "itkImageRegionIterator.h"
9 #include "itkImageRegionConstIterator.h"
10
11 //typedef itk::Image<unsigned char, 2>  ImageType;
12
13 template< class I, class O>
14 void cpExtensions::Algorithms::MacheteImageFilter<  I, O>
15 ::GenerateData()
16 {
17   //const typename Superclass::OutputImageRegionType& region;
18
19   typename I::ConstPointer input = this->GetInput();
20
21   typename O::Pointer output = this->GetOutput();
22   output->SetRegions(input->GetLargestPossibleRegion());
23   output->Allocate();
24
25   itk::ImageRegionIterator<O> outputIterator(output, output->GetLargestPossibleRegion());
26   itk::ImageRegionConstIterator<I> inputIterator(input, input->GetLargestPossibleRegion());
27
28   while (!outputIterator.IsAtEnd())
29   {
30     auto p0 = inputIterator.GetIndex();
31     itk::Point<double, 3> otherPoint;
32     otherPoint[0] = p0[0];
33     otherPoint[1] = p0[1];
34     otherPoint[2] = p0[2];
35     otherPoint[2] = this->point[2]; // TODO : Solve this hammer
36
37     double dist = this->point.EuclideanDistanceTo(otherPoint);
38     if (dist <= this->radius)
39     {
40       outputIterator.Set(0);
41     }
42     else
43     {
44       outputIterator.Set(inputIterator.Get());
45     }
46
47     ++inputIterator;
48     ++outputIterator;
49   }
50
51 }
52
53 template< class I, class O>
54 void cpExtensions::Algorithms::MacheteImageFilter< I, O>::SetRadius(double rad){
55   this->radius = rad;
56 }
57
58 template< class I, class O>
59 void cpExtensions::Algorithms::MacheteImageFilter< I, O>::SetPoint(itk::Point<double, 3> point){
60   this->point = point;
61 }
62
63
64
65
66 #endif