18 #ifndef __otbLeeImageFilter_txx
19 #define __otbLeeImageFilter_txx
39 template <
class TInputImage,
class TOutputImage>
46 template <
class TInputImage,
class TOutputImage>
50 Superclass::GenerateInputRequestedRegion();
56 if (!inputPtr || !outputPtr)
63 typename TInputImage::RegionType inputRequestedRegion;
64 inputRequestedRegion = inputPtr->GetRequestedRegion();
67 inputRequestedRegion.PadByRadius(m_Radius);
70 if (inputRequestedRegion.Crop(inputPtr->GetLargestPossibleRegion()))
72 inputPtr->SetRequestedRegion(inputRequestedRegion);
81 inputPtr->SetRequestedRegion(inputRequestedRegion);
85 std::ostringstream msg;
86 msg << static_cast<const char *>(this->GetNameOfClass())
87 <<
"::GenerateInputRequestedRegion()";
89 e.
SetDescription(
"Requested region is (at least partially) outside the largest possible region.");
95 template<
class TInputImage,
class TOutputImage>
108 typename OutputImageType::Pointer output = this->GetOutput();
109 typename InputImageType::ConstPointer input = this->GetInput();
116 faceList = bC(input, outputRegionForThread, m_Radius);
125 double Cr2, Cv2, E_I, I, Var_I, dPixel;
128 Cv2 = 1. / (vcl_sqrt(m_NbLooks));
133 for (fit = faceList.begin(); fit != faceList.end(); ++fit)
136 const unsigned int neighborhoodSize = bit.
Size();
143 sum = itk::NumericTraits<InputRealType>::Zero;
144 sum2 = itk::NumericTraits<InputRealType>::Zero;
146 for (i = 0; i < neighborhoodSize; ++i)
148 dPixel =
static_cast<double>(bit.
GetPixel(i));
150 sum2 += dPixel * dPixel;
152 E_I = sum /
static_cast<double>(neighborhoodSize);
153 Var_I = sum2 /
static_cast<double>(neighborhoodSize) - E_I * E_I;
156 const double epsilon = 0.0000000001;
157 if (vcl_abs(E_I) < epsilon)
159 dPixel = itk::NumericTraits<OutputPixelType>::Zero;
163 Cr2 = Var_I / (E_I * E_I);
164 dPixel = E_I + ((I - E_I) * (Cr2)) / (Cr2 + Cv2);
168 it.
Set(static_cast<OutputPixelType>(dPixel));
172 progress.CompletedPixel();
180 template <
class TInputImage,
class TOutput>
184 Superclass::PrintSelf(os, indent);
185 os << indent <<
"Radius: " << m_Radius << std::endl;