[Insight-users] Questions about Registering 2 image with small overlap
Michael Jackson
mike.jackson at bluequartz.net
Mon Mar 23 13:18:51 EDT 2009
Thanks for the info. I ended up calculating the intersection of the 2
images, running a ROI on each image to cut out only the overlapping
regions, then ran a registration on those images. The final
translations are applicable to the entire image so this seems to work,
plus I get a speed boost because the registration is taking place on
images that are about 5% the size of the originals.
Thanks again for the help
_________________________________________________________
Mike Jackson mike.jackson at bluequartz.net
BlueQuartz Software www.bluequartz.net
Principal Software Engineer Dayton, Ohio
On Mar 21, 2009, at 12:28 PM, Luis Ibanez wrote:
>
> Hi Michael,
>
> Are these two images that *actually* correspond to two contiguous
> fields of view from a microscope ?
>
> That is, are you actually trying to build a mosaic (or to stitch)
> these two images ?
>
> If so, then, is the width of the overlap of 20 pixels consistent
> with what you will expect as overlap, knowing how the images were
> acquired in the microscopy ?
>
> If so, then, the good news is that you just need to set the
> FixedImageRegion to be at the location (and size) of the overlapping
> region.
>
> The error that you are getting:
>
> MeanSquaresImageToImageMetric(0x569100): Too many samples map outside
> > moving image buffer: 13840 / 1722508
>
>
> Indicates that the overlap between the images is too small.
> (which may be perfectly fine for the initial locations of your two
> images, if what you are doing is building a mosaic)( but may be
> an indication of a problem, if what you are doing is registering
> two identical fields of view, acquired at different times (e.g. time
> lapse)).
>
> If you are in the "building a mosaic" case, then just replace:
>
> registration->SetFixedImageRegion(
> > fixedImageReader->GetOutput()->GetBufferedRegion());
> >
>
> with
>
> registration->SetFixedImageRegion(
> regionOverlapThanMichaelWillCompute );
>
> that region will have the width of 20 pixels that you just indicated.
>
>
>
> The mean square metric is fine for what you are doing, *IF* this
> are two images from the same modality (e.g. there were both acquired
> using the same spectrum).
>
> On the other hand, if you were registering two images that you
> acquired
> using two differen monochromatic filters, then you may want to use
> MattesMutualInformation.
>
> You will do us a great favor by simply posting the two images in a
> public web site. :-)
>
> and elaborating more on what you are actually doing. (e.g. a diagram
> will be great).
>
>
>
> Regards,
>
>
> Luis
>
>
>
> -----------------------
> Michael Jackson wrote:
>> 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);
>> _____________________________________
>> Powered by www.kitware.com
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>> Please keep messages on-topic and check the ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
More information about the Insight-users
mailing list