23 #ifndef otbKullbackLeiblerSupervizedDistanceImageFilter_hxx
24 #define otbKullbackLeiblerSupervizedDistanceImageFilter_hxx
34 template <
class TInput1,
class TInput2,
class TInputROIImage,
class TOutput>
41 template <
class TInput1,
class TInput2,
class TInputROIImage,
class TOutput>
51 template <
class TInput1,
class TInput2,
class TInputROIImage,
class TOutput>
53 const typename TInput2::ImageType* img2,
54 const TInputROIImage* imgROI)
57 conversion1->SetInputImage(img1);
58 conversion1->SetROIImage(imgROI);
59 conversion1->Update();
61 if (m_CumROI1 !=
nullptr)
66 if (!m_CumROI1->IsDataAvailable())
68 throw itk::ExceptionObject(__FILE__, __LINE__,
"Cumulants estimated from ROI in image 1 are not usable", ITK_LOCATION);
72 conversion2->SetInputImage(img2);
73 conversion2->SetROIImage(imgROI);
74 conversion2->Update();
76 if (m_CumROI2 !=
nullptr)
81 if (!m_CumROI2->IsDataAvailable())
83 throw itk::ExceptionObject(__FILE__, __LINE__,
"Cumulants estimated from ROI in image 2 are not usable", ITK_LOCATION);
87 template <
class TInput1,
class TInput2,
class TInputROIImage,
class TOutput>
94 return static_cast<TOutput
>(0.);
101 return static_cast<TOutput
>(0.);
104 return static_cast<TOutput
>(m_CumROI1->Divergence(cum1) + m_CumROI2->Divergence(cum2));
116 template <
class TInputImage1,
class TInputImage2,
class TInputROIImage,
class TOutputImage>
118 const TInputROIImage* trainingImage)
120 this->itk::ProcessObject::SetNthInput(2,
const_cast<TInputROIImage*
>(trainingImage));
123 template <
class TInputImage1,
class TInputImage2,
class TInputROIImage,
class TOutputImage>
126 typename TInputImage1::ConstPointer inputPtr1 =
dynamic_cast<const TInputImage1*
>(this->GetInput(0));
127 typename TInputImage2::ConstPointer inputPtr2 =
dynamic_cast<const TInputImage2*
>(this->GetInput(1));
128 typename TInputROIImage::ConstPointer trainingImage =
static_cast<const TInputROIImage*
>(this->itk::ProcessObject::GetInput(2));
130 this->GetFunctor().Evaluate(inputPtr1, inputPtr2, trainingImage);