21 #ifndef otbNCCRegistrationFilter_hxx
22 #define otbNCCRegistrationFilter_hxx
31 template <
class TFixedImage,
class TMovingImage,
class TDisplacementField>
36 drfp = NCCRegistrationFunctionType::New();
38 drfp->SetDisplacementField(this->GetDisplacementField());
43 template <
class TFixedImage,
class TMovingImage,
class TDisplacementField>
46 Superclass::PrintSelf(os, indent);
47 os << indent <<
"NCC Radius: " << this->GetNCCRadius() << std::endl;
53 template <
class TFixedImage,
class TMovingImage,
class TDisplacementField>
58 Superclass::InitializeIteration();
65 itkExceptionMacro(<<
"Could not cast difference function to NCCRegistrationFunction");
81 template <
class TFixedImage,
class TMovingImage,
class TDisplacementField>
89 itkExceptionMacro(<<
"Could not cast difference function to NCCRegistrationFunction");
92 return drfp->GetEnergy();
98 template <
class TFixedImage,
class TMovingImage,
class TDisplacementField>
107 itkExceptionMacro(<<
"Could not cast difference function to NCCRegistrationFunction");
110 return drfp->GetRadius();
116 template <
class TFixedImage,
class TMovingImage,
class TDisplacementField>
124 itkExceptionMacro(<<
"Could not cast difference function to NCCRegistrationFunction");
127 drfp->SetRadius(radius);
132 template <
class TFixedImage,
class TMovingImage,
class TDisplacementField>
136 typename Superclass::FixedImagePointer fixedPtr =
const_cast<TFixedImage*
>(this->GetFixedImage());
137 typename Superclass::MovingImagePointer movingPtr =
const_cast<TMovingImage*
>(this->GetMovingImage());
138 typename TDisplacementField::Pointer outputPtr = this->GetOutput();
140 if (!fixedPtr || !movingPtr || !outputPtr)
147 typename TDisplacementField::RegionType requestedRegion;
148 requestedRegion = outputPtr->GetRequestedRegion();
151 requestedRegion.PadByRadius(this->GetNCCRadius());
154 if (requestedRegion.Crop(fixedPtr->GetLargestPossibleRegion()))
156 if (requestedRegion.Crop(movingPtr->GetLargestPossibleRegion()))
158 fixedPtr->SetRequestedRegion(requestedRegion);
159 movingPtr->SetRequestedRegion(requestedRegion);
168 movingPtr->SetRequestedRegion(requestedRegion);
171 itk::InvalidRequestedRegionError e(__FILE__, __LINE__);
172 e.SetLocation(ITK_LOCATION);
173 e.SetDescription(
"Requested region is (at least partially) outside the largest possible region of the moving image.");
174 e.SetDataObject(movingPtr);
184 fixedPtr->SetRequestedRegion(requestedRegion);
187 itk::InvalidRequestedRegionError e(__FILE__, __LINE__);
188 e.SetLocation(ITK_LOCATION);
189 e.SetDescription(
"Requested region is (at least partially) outside the largest possible region of the fixed image.");
190 e.SetDataObject(fixedPtr);
198 template <
class TFixedImage,
class TMovingImage,
class TDisplacementField>
208 this->Superclass::ApplyUpdate(dt);
214 itkExceptionMacro(<<
"Could not cast difference function to NCCRegistrationFunction");