Hi again,<br><div class="gmail_quote"><br>Thanks Luis your answer, it is working correctly in 2D.<br><br>Now I'm extending the code to 3D images. I modified the Dimension to 3 and the optimizer scales (9 for rotation and 3 for translation). <br>
<br>I test the code using the same images with the same command arguments that you told me before and a new error appears before doing the registration:<br><br>##################################################<br><br>FixedImage schedule: [4, 4, 4]<br>
[2, 2, 2]<br>[1, 1, 1]<br><br>MovingImage schedule: [4, 4, 4]<br>[2, 2, 2]<br>[1, 1, 1]<br><br>-------------------------------------<br>MultiResolution Level : 0<br><br>ExceptionObject caught !<br><br>itk::ExceptionObject (0100FDF4)<br>
Location: "void __thiscall itk::MattesMutualInformationImageToImageMetric<class itk::Image<float,3>,class itk::Image<floa<br>t,3> >::GetValueAndDerivative(const class itk::Array<double> &,double &,class itk::Array<double> &) const"<br>
File: c:\bert\itk_vtk\src\itk\insighttoolkit-3.12.0\code\algorithms\itkMattesMutualInformationImageToImageMetric.txx<br>Line: 1138<br>Description: itk::ERROR: MattesMutualInformationImageToImageMetric(014A27B8): Joint PDF summed to zero<br>
<br>#######################################<br><br>I thought that the error is produced because I'm working with 2d images, but the registration works if the number of levels of the multiresolution registration is 1. Can the 3d registration work with 2d images? I know that with Mean Squares metric it isn't possible but this problem shouldn't appear with Mattes Mutual information metric because it works with histograms...<br>
<br>However, I test it with 3d images (the same 2d images of the brain repeated 4 times) and the error appear when the number of levels are 4 (works correctly with 1,2 and 3 levels). Also I've worked with different percentage of samples (from 20% to 100%) and number of bins (32 and 128) and the error continues appearing.<br>
<br>I read in <a href="http://www.itk.org/pipermail/insight-users/2009-February/028917.html" target="_blank">http://www.itk.org/pipermail/insight-users/2009-February/028917.html</a> that it could be caused by something missed, but I think I do all the necessary changes to do the 3D registration. <br>
<br>What could the mistake be? Working with 2d images? Something missed?<br><br>Thanks in advance,<br><br>Albert<br><br><br><br><div class="gmail_quote">2009/3/17 Luis Ibanez <span dir="ltr"><<a href="mailto:luis.ibanez@kitware.com" target="_blank">luis.ibanez@kitware.com</a>></span><div>
<div></div><div class="h5"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Albert,<br>
<br>
Thanks for your detailed post.<br>
<br>
We ran the MultiResImageRegistration2.cxx example on<br>
the two images that your suggested:<br>
<br>
* BrainProtonDensitySlice.png<br>
* BrainProtonDensitySliceR10X13Y17.png<br>
<br>
This led us to find a bug (Thank you very much!), and a new set<br>
of parameters that are appropriate for these two images.<br>
<br>
<br>
The changes that we identified are;<br>
<br>
cvs diff: Diffing .<br>
Index: MultiResImageRegistration2.cxx<br>
===================================================================<br>
RCS file: /cvsroot/Insight/Insight/Examples/Registration/MultiResImageRegistration2.cxx,v<br>
retrieving revision 1.49<br>
diff -r1.49 MultiResImageRegistration2.cxx<br>
152c152<br>
< optimizer->SetMaximumStepLength( 16.00 );<br>
---<br>
> optimizer->SetMaximumStepLength( 0.10 );<br>
348,349c348,349<br>
< optimizerScales[4] = 1.0 / 1e7; // scale for translation on X<br>
< optimizerScales[5] = 1.0 / 1e7; // scale for translation on Y<br>
---<br>
> optimizerScales[4] = 1.0 / 1e3; // scale for translation on X<br>
> optimizerScales[5] = 1.0 / 1e3; // scale for translation on Y<br>
555a556,557<br>
> finalTransform->SetFixedParameters( transform->GetFixedParameters() );<br>
><br>
<br>
<br>
The bug we found is that the finalTransform is a new instance<br>
of an affine transform whose center has not been initialized.<br>
This leads to an incorrect resampling of the output image.<br>
<br>
This bug is fixed by the new line:<br>
<br>
> finalTransform->SetFixedParameters( transform->GetFixedParameters() );<br>
<br>
<br>
The executable can be run with the following parameters:<br>
<br>
MultiResImageRegistration2<br>
BrainProtonDensitySlice.png BrainProtonDensitySliceR10X13Y17.png<br>
registered.mha 100 checkerBoardBefore.mha<br>
checkerBoardAfter.mha 1 32 3000<br>
<br>
<br>
Please try the code with these changes<br>
and let us know if you still find any problems.<br>
<br>
<br>
Thanks<br>
<br>
<br>
Luis<br>
<br>
<br>
<br>
---------------------------------------------------------------------------------------------<br>
<div><div></div><div>On Mon, Mar 16, 2009 at 6:38 PM, Albert Gubern <<a href="mailto:bertkrek@gmail.com" target="_blank">bertkrek@gmail.com</a>> wrote:<br>
> Hi,<br>
><br>
> I'm using MultiResImageRegistration2.cxx in order to correct global pose<br>
> differences of two images. My goal is a registration of prostate MRI of<br>
> differents patients for a atlas building. I am testing this example with<br>
> images from Examples/Data of ITK source: BrainProtonDensitySliceBorder2<br>
> 0.png as a fixed and BrainProtonDensitySliceR10X13Y17.png as a moving.<br>
><br>
> The registration works if the moving image only has a translation but it<br>
> doesn't work with the images that i'm testing it (translation and rotation).<br>
><br>
> I have tuned the parameters following the instructions of<br>
> <a href="http://www.itk.org/pipermail/insight-users/2007-March/021435.html" target="_blank">http://www.itk.org/pipermail/insight-users/2007-March/021435.html</a> but it is<br>
> no way to obtain a good result. If I set the translationScales and<br>
> rotationScales with the same value (for example 1), the result image appears<br>
> correctly rotated but in the right corner of the top of the image<br>
> (<a href="http://img208.imageshack.us/img208/5148/test1.png" target="_blank">http://img208.imageshack.us/img208/5148/test1.png</a>). Otherwise, if I set the<br>
> translationScales with smaller values than rotationScales ( 1/1000 and 1<br>
> respectively) the images appears correctly in the center but not enough<br>
> rotated (<a href="http://img24.imageshack.us/img24/9317/test2m.png" target="_blank">http://img24.imageshack.us/img24/9317/test2m.png</a>). The maxStep<br>
> length is 0.1, the minstepLength 0.001, 100% of samples and 128 number of<br>
> bins.<br>
><br>
> I tested with a lot of combinations of parameters with and without sense,<br>
> and I don't understand the behaviour. What is the problem? Is The way how I<br>
> tune the parameters? This framework it isn't right for translation+rotation?<br>
><br>
> Thanks in advance,<br>
><br>
> --<br>
> Albert<br>
><br>
</div></div>> _____________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the ITK FAQ at:<br>
> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
><br>
><br>
</blockquote></div></div></div><br><br clear="all"><br>-- <br><font color="#888888">Albert<br>
</font></div><br><br clear="all"><br>-- <br>Albert<br>