[Insight-users] Questions about Registering 2 image with small overlap
Michael Jackson
mike.jackson at bluequartz.net
Fri Mar 20 15:54:52 EDT 2009
I'm _still_ new to the whole ITK/Image Registration thing. I have been
over the ITK manual a few times (selected sections that I thought was
relevant) but I am having a tough time getting a registration to work
out. Here is what I have.
2 Images. Both are 1292 pixels wide by 968 pixels high. The scaling of
the image is 0.207987 microns/pixel. The origins (upper left, not the
it probably matters) are:
Image 0: 47113.2, 48448.5 (microns)
Image 1: 47369.2, 48448.8 (microns).
So basically the edges overlap by a little bit (about 20 pixels or
so). The edges are not quite lined up properly with those settings
(which came from the instrument the image was captured on) so I am
trying to run the images through ITK in order to align them better.
I am getting the exception: Description: itk::ERROR:
MeanSquaresImageToImageMetric(0x569100): Too many samples map outside
moving image buffer: 13840 / 1722508
which I _think_ is telling me that something is "off" in where the
images are being placed in physical space.
I am not even sure if I am using the proper Image Metric for this type
of problem. The images are grayscale in nature.
Here is some code for your perusal. Any pointers on what I might be
doing wrong would surely be appreciated.
Thanks
Mike Jackson
const unsigned int Dimension = 2;
typedef unsigned char PixelType;
typedef itk::Image<PixelType, Dimension> FixedImageType;
typedef itk::Image<PixelType, Dimension> MovingImageType;
typedef itk::TranslationTransform<double, Dimension> TransformType;
typedef itk::RegularStepGradientDescentOptimizer
OptimizerType;
typedef itk::MeanSquaresImageToImageMetric
<FixedImageType, MovingImageType> MetricType;
typedef itk::LinearInterpolateImageFunction
<MovingImageType, double> InterpolatorType;
typedef itk::ImageRegistrationMethod
<FixedImageType, MovingImageType> RegistrationType;
typedef itk::ImageFileReader< FixedImageType > ReaderType;
typedef itk::ImageFileWriter< FixedImageType > WriterType;
typedef itk::Point< double, FixedImageType::ImageDimension > PointType;
FixedImageType::PointType fixedOrigin;
fixedOrigin[0] = 47113.2;
fixedOrigin[1] = 48448.5;
MovingImageType::PointType movingOrigin;
movingOrigin[0] = 47369.2;
movingOrigin[1] = 48447.8;
fixedImageReader->GetOutput()->SetOrigin(fixedOrigin);
movingImageReader->GetOutput()->SetOrigin(movingOrigin);
//--- Set the Spacing of the images
FixedImageType::SpacingType fixedSpacing;
fixedSpacing[0] = 0.207987;
fixedSpacing[1] = 0.207987;
MovingImageType::SpacingType movingSpacing;
movingSpacing[0] = 0.207987;
movingSpacing[1] = 0.207987;
fixedImageReader->GetOutput()->SetSpacing(fixedSpacing);
movingImageReader->GetOutput()->SetSpacing(movingSpacing);
registration->SetFixedImage(fixedImageReader->GetOutput());
registration->SetMovingImage(movingImageReader->GetOutput());
registration->SetFixedImageRegion(
fixedImageReader->GetOutput()->GetBufferedRegion());
typedef RegistrationType::ParametersType ParametersType;
ParametersType initialParameters(transform->GetNumberOfParameters());
initialParameters[0] = INITIAL_TRANS_X; // Initial offset in mm along X
initialParameters[1] = INITIAL_TRANS_Y; // Initial offset in mm along
Y registration->SetInitialTransformParameters(initialParameters);
More information about the Insight-users
mailing list