17 #ifndef __itkConvolutionImageFilter_txx
18 #define __itkConvolutionImageFilter_txx
30 #include "vnl/vnl_math.h"
34 template<
class TInputImage,
class TOutputImage>
38 this->SetNumberOfRequiredInputs( 2 );
42 template<
class TInputImage,
class TOutputImage>
48 template<
class TInputImage,
class TOutputImage>
55 ProgressReporter progress(
this, threadId, outputRegionForThread.GetNumberOfPixels() );
58 typedef typename NeighborhoodIteratorType::RadiusType RadiusType;
59 typedef typename RadiusType::SizeValueType SizeValueType;
61 for(
unsigned int i = 0; i < ImageDimension; i++ )
63 radius[i] = Math::Floor< SizeValueType >( 0.5 *
64 this->GetImageKernelInput()->GetLargestPossibleRegion().GetSize()[i] );
67 double scalingFactor = 1.0;
68 if( this->GetNormalize() )
72 this->GetImageKernelInput()->GetLargestPossibleRegion() );
75 sum +=
static_cast<double>( It.
Get() );
79 scalingFactor = 1.0 / sum;
85 FaceCalculatorType faceCalculator;
91 static_cast<const InputImageType*>(
95 typename FaceCalculatorType::FaceListType faceList = faceCalculator(
96 this->GetInput( 0 ), outputRegionForThread, radius );
97 typename FaceCalculatorType::FaceListType::iterator fit;
99 for( fit = faceList.begin(); fit != faceList.end(); ++fit )
101 NeighborhoodIteratorType inIt( radius, this->GetInput( 0 ), *fit );
104 for( inIt.GoToBegin(), outIt.
GoToBegin(); !inIt.IsAtEnd();
107 outIt.
Set( static_cast<OutputPixelType>(
108 scalingFactor * innerProduct( inIt, imageKernelOperator ) ) );
109 progress.CompletedPixel();
122 template <
class TInputImage,
class TOutputImage>
129 for(
unsigned int idx = 0; idx < 2; ++idx )
131 if( this->GetInput( idx ) )
139 typename ImageBaseType::ConstPointer constInput
140 =
dynamic_cast<ImageBaseType
const *
>(
143 if ( constInput.IsNull() )
145 itkExceptionMacro(
"Input image " << idx
146 <<
" not correctly specified." );
151 typename InputImageType::Pointer input =
152 const_cast<TInputImage *
>( this->GetInput( idx ) );
154 typename InputImageType::RegionType inputRegion;
157 Superclass::CallCopyOutputRegionToInputRegion( inputRegion,
158 this->GetOutput()->GetRequestedRegion() );
162 typename InputImageType::RegionType::SizeType inputSize;
163 typename InputImageType::RegionType::IndexType inputIndex;
164 inputSize = this->GetInput(
165 idx )->GetLargestPossibleRegion().GetSize();
166 inputIndex = this->GetInput(
167 idx )->GetLargestPossibleRegion().GetIndex();
168 inputRegion.SetSize(inputSize);
169 inputRegion.SetIndex(inputIndex);
171 input->SetRequestedRegion( inputRegion );
178 template <
class TInputImage,
class TOutputImage>
183 Superclass::PrintSelf(os, indent);
185 os << indent <<
"Normalize: " << m_Normalize << std::endl;