18 #ifndef __otbLocalRxDetectorNonThreadFilter_txx
19 #define __otbLocalRxDetectorNonThreadFilter_txx
29 template <
class TInputImage,
class TOutputImage>
33 this->m_ExternalRadius = 0;
34 this->m_InternalRadius = 0;
40 template <
class TInputImage,
class TOutputImage>
45 Superclass::PrintSelf(os, indent);
47 os << indent <<
"Internal Radius: " << m_InternalRadius << std::endl;
48 os << indent <<
"External Radius: " << m_ExternalRadius << std::endl;
54 template <
class TInputImage,
class TOutputImage>
60 this->AllocateOutputs();
70 outputPtr->FillBuffer(0);
74 radius.
Fill(m_ExternalRadius);
78 typename VectorFaceCalculatorType::FaceListType::iterator vectorFit;
80 vectorFaceList = vectorFaceCalculator(inputPtr, inputPtr->GetRequestedRegion(), radius);
81 vectorFit = vectorFaceList.begin();
87 for (
int y = -m_ExternalRadius; y <= m_ExternalRadius; y++)
90 for (
int x = -m_ExternalRadius; x <= m_ExternalRadius; x++)
93 if ((abs(x) > m_InternalRadius) || (abs(y) > m_InternalRadius))
103 typename FaceCalculatorType::FaceListType::iterator fit;
105 faceList = faceCalculator(outputPtr, inputPtr->GetRequestedRegion(), radius);
106 fit = faceList.begin();
119 listSample->SetMeasurementVectorSize(inputPtr->GetNumberOfComponentsPerPixel());
127 listSample->PushBack(ci.
Get());
132 meanCalculator->SetInputSample(listSample);
133 meanCalculator->Update();
136 meanVector = meanCalculator->GetOutput();
140 covarianceCalculator->SetInputSample(listSample);
141 covarianceCalculator->SetMean(meanVector);
142 covarianceCalculator->Update();
151 testPixVec = inputPtr->GetPixel(inputIt.
GetIndex());
156 meanVec.SetElement(i, meanVector->
GetElement(i));
160 for (
unsigned int i = 0; i < centeredTestPixMat.rows(); ++i)
162 centeredTestPixMat.put(i, 0, (testPixVec.GetElement(i) - meanVector->
GetElement(i)));
167 outputIt.
Set(rxValue.get(0, 0));
174 template <
class TInputImage,
class TOutputImage>
180 Superclass::GenerateInputRequestedRegion();
187 if ( !inputPtr || !outputPtr )
194 typename TInputImage::RegionType inputRequestedRegion;
195 inputRequestedRegion = inputPtr->GetRequestedRegion();
198 inputRequestedRegion.PadByRadius( m_ExternalRadius );
201 if ( inputRequestedRegion.Crop(inputPtr->GetLargestPossibleRegion()) )
203 inputPtr->SetRequestedRegion( inputRequestedRegion );
212 inputPtr->SetRequestedRegion( inputRequestedRegion );
217 e.
SetDescription(
"Requested region is (at least partially) outside the largest possible region.");