forked from InsightSoftwareConsortium/ITKWikiExamples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitkImageFilterMultipleInputs.txx
70 lines (55 loc) · 1.44 KB
/
itkImageFilterMultipleInputs.txx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef itkImageFilterMultipleInputs_txx
#define itkImageFilterMultipleInputs_txx
#include "itkImageFilterMultipleInputs.h"
#include "itkObjectFactory.h"
#include "itkImageRegionIterator.h"
#include "itkImageRegionConstIterator.h"
namespace itk
{
template< class TImage>
ImageFilterMultipleInputs<TImage>
::ImageFilterMultipleInputs()
{
this->SetNumberOfRequiredInputs(2);
}
template< class TImage>
void
ImageFilterMultipleInputs<TImage>
::SetInputImage(const TImage* image)
{
this->SetNthInput(0, const_cast<TImage*>(image));
}
template< class TImage>
void
ImageFilterMultipleInputs<TImage>
::SetInputMask(const TImage* mask)
{
this->SetNthInput(1, const_cast<TImage*>(mask));
}
template< class TImage>
void
ImageFilterMultipleInputs<TImage>
::GenerateData()
{
typename TImage::ConstPointer input = this->GetInput();
typename TImage::Pointer output = this->GetOutput();
output->SetRegions(input->GetLargestPossibleRegion());
output->Allocate();
itk::ImageRegionIterator<TImage> outputIterator(output, output->GetLargestPossibleRegion());
itk::ImageRegionConstIterator<TImage> inputIterator(input, input->GetLargestPossibleRegion());
while(!outputIterator.IsAtEnd())
{
if(inputIterator.GetIndex()[0] == inputIterator.GetIndex()[1])
{
outputIterator.Set(255);
}
else
{
outputIterator.Set(inputIterator.Get());
}
++inputIterator;
++outputIterator;
}
}
}// end namespace
#endif