Skip to content
Snippets Groups Projects
Commit 8217ef04 authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

ENH: generalization of the Fine registration with any transform as a first guess

parent d99be305
No related branches found
No related tags found
No related merge requests found
......@@ -91,15 +91,15 @@ public:
typedef typename TInputImage::SpacingType SpacingType;
typedef typename TInputImage::PointType PointType;
typedef typename TInputImage::OffsetType OffsetType;
typedef typename itk::InterpolateImageFunction
<TInputImage, double> InterpolatorType;
typedef itk::InterpolateImageFunction<TInputImage, double> InterpolatorType;
typedef typename InterpolatorType::Pointer InterpolatorPointerType;
typedef typename itk::ContinuousIndex<double, 2> ContinuousIndexType;
typedef typename itk::ImageToImageMetric<TInputImage,
TInputImage> MetricType;
typedef itk::ContinuousIndex<double, 2> ContinuousIndexType;
typedef itk::ImageToImageMetric<TInputImage, TInputImage> MetricType;
typedef typename MetricType::Pointer MetricPointerType;
typedef typename itk::TranslationTransform<double,2> TranslationType;
typedef itk::TranslationTransform<double,2> TranslationType;
typedef typename TranslationType::Pointer TranslationPointerType;
typedef typename itk::Transform<double,2,2> TransformType;
typedef typename TransformType::Pointer TransformPointerType;
/** Set/Get the Metric used to compare images */
itkSetObjectMacro(Metric,MetricType);
......@@ -168,6 +168,10 @@ public:
m_GridStep.Fill(step);
}
/** Set the transform for the initial offset */
itkSetObjectMacro(Transform, TransformType);
itkGetConstObjectMacro(Transform, TransformType);
protected:
/** Constructor */
FineRegistrationImageFilter();
......@@ -217,6 +221,9 @@ private:
/** Grid step */
OffsetType m_GridStep;
/** Transform for initial offset */
TransformPointerType m_Transform;
};
} // end namespace otb
......
......@@ -65,6 +65,8 @@ FineRegistrationImageFilter<TInputImage,T0utputCorrelation,TOutputDeformationFie
// Default offset
m_InitialOffset.Fill(0);
m_Transform = NULL;
}
template <class TInputImage, class T0utputCorrelation, class TOutputDeformationField>
......@@ -327,6 +329,9 @@ FineRegistrationImageFilter<TInputImage,TOutputCorrelation,TOutputDeformationFie
deformationValue[0] = m_InitialOffset[0];
deformationValue[1] = m_InitialOffset[1];
// Local initial offset: enable the possibility of a different initial offset for each pixel
SpacingType localOffset = m_InitialOffset;
// Get fixed image spacing
SpacingType fixedSpacing = fixedPtr->GetSpacing();
......@@ -362,13 +367,28 @@ FineRegistrationImageFilter<TInputImage,TOutputCorrelation,TOutputDeformationFie
m_Metric->SetFixedImageRegion(currentMetricRegion);
m_Metric->Initialize();
// Compute the local offset if required (and the transform was specified)
if (m_Transform.IsNotNull())
{
PointType inputPoint, outputPoint;
for(unsigned int dim = 0; dim < TInputImage::ImageDimension; ++dim)
{
inputPoint[dim] = currentIndex[dim];
}
outputPoint = m_Transform->TransformPoint(inputPoint);
for(unsigned int dim = 0; dim < TInputImage::ImageDimension; ++dim)
{
localOffset[dim] = outputPoint[dim] - inputPoint[dim];//FIXME check the direction
}
}
// Compute the correlation at each location
for(int i = -static_cast<int>(m_SearchRadius[0]); i <= static_cast<int>(m_SearchRadius[0]); ++i)
{
for(int j = -static_cast<int>(m_SearchRadius[1]); j <= static_cast<int>(m_SearchRadius[1]); ++j)
{
params[0] = m_InitialOffset[0] + static_cast<double>(i*fixedSpacing[0]);
params[1] = m_InitialOffset[1] + static_cast<double>(j*fixedSpacing[1]);
params[0] = localOffset[0] + static_cast<double>(i*fixedSpacing[0]);
params[1] = localOffset[1] + static_cast<double>(j*fixedSpacing[1]);
try
{
......
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