Skip to content
Snippets Groups Projects
Commit 4d9c387d authored by Julien Michel's avatar Julien Michel
Browse files

ENH: Adding GenerateInputRequestedRegion() to MIRegistrationFilter

parent fd848145
No related branches found
No related tags found
No related merge requests found
......@@ -127,6 +127,9 @@ protected:
/** Apply update. */
virtual void ApplyUpdate(TimeStepType dt);
/** Update the Input requested region. */
virtual void GenerateInputRequestedRegion();
private:
MIRegistrationFilter(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
......
......@@ -15,9 +15,9 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbMIRegistrationFilter_txx
#define __otbMIRegistrationFilter_txx
#include "otbMIRegistrationFilter.h"
namespace otb {
......@@ -187,7 +187,73 @@ MIRegistrationFilter<TFixedImage,TMovingImage,TDeformationField>
}
template <class TFixedImage, class TMovingImage, class TDeformationField>
void
MIRegistrationFilter<TFixedImage,TMovingImage,TDeformationField>
::GenerateInputRequestedRegion()
{
// get pointers to the input and output
typename Superclass::FixedImagePointer fixedPtr =
const_cast< TFixedImage * >( this->GetFixedImage() );
typename Superclass::MovingImagePointer movingPtr =
const_cast< TMovingImage * >( this->GetMovingImage() );
typename TDeformationField::Pointer outputPtr = this->GetOutput();
if ( !fixedPtr || !movingPtr || !outputPtr )
{
return;
}
// get a copy of the input requested region (should equal the output
// requested region)
typename TDeformationField::RegionType requestedRegion;
requestedRegion = outputPtr->GetRequestedRegion();
// pad the input requested region by the operator radius
requestedRegion.PadByRadius( this->GetMIRadius() );
// crop the input requested region at the input's largest possible region
if ( requestedRegion.Crop(fixedPtr->GetLargestPossibleRegion()))
{
if ( requestedRegion.Crop(movingPtr->GetLargestPossibleRegion()))
{
fixedPtr->SetRequestedRegion( requestedRegion );
movingPtr->SetRequestedRegion( requestedRegion );
return;
}
else
{
// Couldn't crop the region (requested region is outside the largest
// possible region). Throw an exception.
// store what we tried to request (prior to trying to crop)
movingPtr->SetRequestedRegion( requestedRegion );
// build an exception
itk::InvalidRequestedRegionError e(__FILE__, __LINE__);
e.SetLocation(ITK_LOCATION);
e.SetDescription("Requested region is (at least partially) outside the largest possible region of the moving image.");
e.SetDataObject(movingPtr);
throw e;
}
}
else
{
// Couldn't crop the region (requested region is outside the largest
// possible region). Throw an exception.
// store what we tried to request (prior to trying to crop)
fixedPtr->SetRequestedRegion( requestedRegion );
// build an exception
itk::InvalidRequestedRegionError e(__FILE__, __LINE__);
e.SetLocation(ITK_LOCATION);
e.SetDescription("Requested region is (at least partially) outside the largest possible region of the fixed image.");
e.SetDataObject(fixedPtr);
throw e;
}
}
} // end namespace otb
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment