18 #ifndef __otbVarianceImageFilter_txx
19 #define __otbVarianceImageFilter_txx
34 template <
class TInputImage,
class TOutputImage>
41 template <
class TInputImage,
class TOutputImage>
47 Superclass::GenerateInputRequestedRegion();
51 const_cast<TInputImage *
>(this->GetInput());
54 if (!inputPtr || !outputPtr)
61 typename TInputImage::RegionType inputRequestedRegion;
62 inputRequestedRegion = inputPtr->GetRequestedRegion();
65 inputRequestedRegion.PadByRadius(m_Radius);
68 if (inputRequestedRegion.Crop(inputPtr->GetLargestPossibleRegion()))
70 inputPtr->SetRequestedRegion(inputRequestedRegion);
79 inputPtr->SetRequestedRegion(inputRequestedRegion);
84 e.
SetDescription(
"Requested region is (at least partially) outside the largest possible region.");
90 template<
class TInputImage,
class TOutputImage>
103 typename OutputImageType::Pointer output = this->GetOutput();
104 typename InputImageType::ConstPointer input = this->GetInput();
109 faceList = bC(input, outputRegionForThread, m_Radius);
121 for (fit = faceList.begin(); fit != faceList.end(); ++fit)
125 unsigned int neighborhoodSize = bit.
Size();
132 sum = itk::NumericTraits<InputRealType>::Zero;
133 sumOfSquares = itk::NumericTraits<InputRealType>::Zero;
134 for (i = 0; i < neighborhoodSize; ++i)
138 sumOfSquares += value * value;
142 const double num =
static_cast<double>(neighborhoodSize);
143 it.
Set(static_cast<OutputPixelType>(sumOfSquares - (sum * sum / num)) / (num - 1.0));
147 progress.CompletedPixel();
155 template <
class TInputImage,
class TOutput>
162 Superclass::PrintSelf(os, indent);
163 os << indent <<
"Radius: " << m_Radius << std::endl;