1 #ifndef itkNeighborhoodFunctorImageFilter_cpp
2 #define itkNeighborhoodFunctorImageFilter_cpp
5 #include "itkNeighborhoodAlgorithm.h"
6 #include <itkVectorImageToImageAdaptor.h>
11 template<
typename TInputImage,
typename TFeatureImageType ,
class FunctorType>
16 const TInputImage * input = this->GetInput(0);
18 for(
unsigned int i = 0 ; i < FunctorType::OutputCount; i ++)
21 output->SetRegions(input->GetLargestPossibleRegion());
22 output->SetSpacing(input->GetSpacing());
23 output->SetOrigin(input->GetOrigin());
24 output->SetDirection(input->GetDirection());
26 this->SetNthOutput( i, output.GetPointer() );
29 if(m_MaskImage.IsNull())
32 m_MaskImage->SetRegions(input->GetLargestPossibleRegion());
33 m_MaskImage->Allocate();
34 m_MaskImage->FillBuffer(1);
38 template<
typename TInputImage,
typename TFeatureImageType ,
class FunctorType>
42 throw ( InvalidRequestedRegionError )
47 Superclass::GenerateInputRequestedRegion();
50 TInputImage * inputPtr =
const_cast< TInputImage *
>( this->GetInput() );
59 typename TInputImage::RegionType inputRequestedRegion;
60 inputRequestedRegion = inputPtr->GetRequestedRegion();
63 inputRequestedRegion.PadByRadius( m_Size );
66 if ( inputRequestedRegion.Crop( inputPtr->GetLargestPossibleRegion() ) )
68 inputPtr->SetRequestedRegion(inputRequestedRegion);
77 inputPtr->SetRequestedRegion(inputRequestedRegion);
80 InvalidRequestedRegionError e(__FILE__, __LINE__);
81 e.SetLocation(ITK_LOCATION);
82 e.SetDescription(
"Requested region is (at least partially) outside the largest possible region.");
83 e.SetDataObject(inputPtr);
88 template<
typename TInputImage,
typename TFeatureImageType,
class FunctorType >
96 typedef NeighborhoodAlgorithm::ImageBoundaryFacesCalculator< InputImageType > BFC;
97 typedef typename BFC::FaceListType FaceListType;
99 FaceListType faceList;
109 faceList = faceCalculator( input, outputRegionForThread, m_Size );
111 typename FaceListType::iterator fit;
112 ImageRegionConstIterator< MaskImageType > mit;
116 ConstNeighborhoodIterator< InputImageType > bit;
119 bit = ConstNeighborhoodIterator< InputImageType >(m_Size, input, outputRegionForThread);
121 mit = ImageRegionConstIterator< MaskImageType >(m_MaskImage, outputRegionForThread);
123 std::vector<ImageRegionIterator< FeatureImageType > > featureImageIterators;
125 for(
unsigned int i = 0; i < FunctorType::OutputCount; i++)
127 featureImageIterators.push_back(ImageRegionIterator< FeatureImageType >(this->GetOutput(i), outputRegionForThread));
128 featureImageIterators[i].GoToBegin();
134 while ( !bit.IsAtEnd() || !mit.IsAtEnd() )
139 typename FunctorType::OutputVectorType
features = ( m_Functor( bit ) );
141 for(
unsigned int i = 0 ; i < FunctorType::OutputCount; i++)
142 featureImageIterators[i].Set(features[i]);
145 for(
unsigned int i = 0 ; i < FunctorType::OutputCount; i++)
146 ++featureImageIterators[i];
152 std::cout <<
"Thread done!" << std::endl;
157 #endif //itkNeighborhoodFunctorImageFilter_cpp
itk::SmartPointer< Self > Pointer
virtual void GenerateInputRequestedRegion()
void BeforeThreadedGenerateData()
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId)
Superclass::OutputImageRegionType OutputImageRegionType
TInputImageType InputImageType
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.