21 #ifndef otbLineCorrelationDetectorImageFilter_hxx
22 #define otbLineCorrelationDetectorImageFilter_hxx
26 #include "itkDataObject.h"
27 #include "itkConstNeighborhoodIterator.h"
28 #include "itkNeighborhoodInnerProduct.h"
29 #include "itkImageRegionIterator.h"
30 #include "itkNeighborhoodAlgorithm.h"
31 #include "itkProgressReporter.h"
40 template <
class TInputImage,
class TOutputImage,
class TOutputImageDirection,
class TInterpolator>
43 this->m_Radius.Fill(1);
44 this->m_LengthLine = 1;
45 this->m_WidthLine = 0;
46 this->m_FaceList.Fill(0);
50 template <
class TInputImage,
class TOutputImage,
class TOutputImageDirection,
class TInterpolator>
52 std::vector<double>* m2,
53 std::vector<double>* m3)
60 std::vector<double>::iterator m1It = m1->begin();
61 std::vector<double>::iterator m1End = m1->end();
63 std::vector<double>::iterator m2It = m2->begin();
64 std::vector<double>::iterator m2End = m2->end();
66 std::vector<double>::iterator m3It = m3->begin();
67 std::vector<double>::iterator m3End = m3->end();
69 while (m1It != m1End && m2It != m2End && m3It != m3End)
94 while (m1It != m1End && m2It != m2End && m3It != m3End)
97 sigma1 += std::pow((*m1It) - M1, 2);
100 sigma2 += std::pow((*m2It) - M2, 2);
103 sigma3 += std::pow((*m3It) - M3, 2);
107 sigma1 /= m1->size();
108 sigma2 /= m2->size();
109 sigma3 /= m3->size();
129 d1 = sigma1 / std::pow(M2, 2) * m1->size();
130 d2 = sigma2 / std::pow(M2, 2) * m2->size();
132 d3 = std::pow(((M1 / M2) - 1.), 2) * (m1->size() * m2->size());
135 rho12 =
static_cast<double>(1. / (1. + ((m1->size() + m2->size()) * (d1 + d2) / d3)));
141 d1 = sigma1 / std::pow(M3, 2) * m1->size();
142 d2 = sigma3 / std::pow(M3, 2) * m2->size();
144 d3 = std::pow(((M1 / M3) - 1.), 2) * (m1->size() * m2->size());
147 rho13 =
static_cast<double>(1. / (1. + ((m1->size() + m2->size()) * (d1 + d2) / d3)));
152 rho12 = std::sqrt(rho12);
153 rho13 = std::sqrt(rho13);
156 return static_cast<double>(std::min(rho12, rho13));
162 template <
class TInputImage,
class TOutputImage,
class TOutputImageDirection,
class TInterpolator>
165 Superclass::PrintSelf(os, indent);