<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:10pt">
Hi Luis,<br><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><div><br>Thanks for the reply.<br><br>I have already done the task that you have mentioned. I studied the example ImageRegistration9.cxx, and it worked for me with RTS images (from BrianProtonDensity set).<br><br>Below are the set of things I added to ImageRegistration9.cxx for Mutual Information + Affine<br><br>-&nbsp; changed the metric from MeanSquare to Mutual Information, and set the required parameters<br>-&nbsp; changed RegularStepGradientDescentOptimizer to GradientDescentOptimizer (as said in example 2)<br>-&nbsp; enabled optimizer-&gt;MaximizeOn() <br>-&nbsp; started with a low value of learning rate (5.0) as it gave an exception when 15.0 was
 used.<br>-&nbsp; used NormalizeImageFilter and DiscreteGaussianImageFilter on both the images as in example 2<br>-&nbsp; used CenteredTransformInitializer as explained in the manual<br><br>- And as you have mentioned I have
 used the Parameter scaling i.e optimizer-&gt;SetScales( optimizerScales ) with translation scale value = 0.001<br>&nbsp; <br>** I got an exception when I tried to give the output of fixedSmoother and movingSmoother (from Example 2) to the initializer code below.<br><br>initializer-&gt;SetFixedImage( fixedImageReader-&gt;GetOutput() );<br>initializer-&gt;SetMovingImage( movingImageReader-&gt;GetOutput() );<br><br>Hence I retained it to the outputs from fixedImageReader and movingImageReader, as in the code snippet above. *****PLEASE LET ME KNOW IF THIS IS CORRECT ?<br><br>If I removed the Normalizing and Smoothing filters, I got an exception that the standard deviation of the metric is very low. It works when sigma = 1.5, but the output is wrong . Hence I retained these filters, with sigma = 0.4.<br><br>I followed your reply at a thread at nabble.com to download the <span style="font-weight: bold;">imageregistration.exe</span> and tried to overlay the
 output of the
 initializer (moving image warped with the initializer params) and this step is correct for BrainProtonDensitySliceShifted13x17y.png .<br><br>My current code fails for both BrainProtonDensitySliceShifted13x17y.png image and BrainProtonDensitySliceR10X13Y17.png image. It gives correct values for translation, but fails for rotation angle, and in both cases, gives high value for scaling ( Sx = ~4 and Sy= ~2) which are completely wrong.<br><br>I also tried working with MultiResImageRegistration2.cxx code which uses Matte + Affine. The output parameters obtained were <span style="font-weight: bold;">WRONG </span>when I tried with BrainProtonDensitySliceR10X13Y17.png image, instead of the example mentioned in the code.<br><br>I also tried with other optimizers such as Amoeba and OnePlusOne optimizers, with Viola MI + Affine. For Amoeba, the code gives correct result for translation for BrainProtonDensitySliceShifted13x17y.png <span style="font-weight:
 bold;">only if the Parameter scaling is DISABLED.</span> In other cases, the affine angle obtained starts with -83 degrees (where the expected value is R&nbsp; = 10 ) i.e in few cases code runs to completion, but the answer is wrong OR exception occurs, that sampled point mapped &nbsp;to outside of the moving image.<br><br>I am totally confused with the results . I have planned to use Mutual Information registration from ITK for <span style="font-weight: bold;">non-medical images</span>. <br><br>Can you please give me pointers, where I might be going wrong?<br><br>Thanks for the help,<br><br>Sharath Venkatesha<br><br><br><br></div><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Luis Ibanez &lt;luis.ibanez@kitware.com&gt;<br><b><span style="font-weight:
 bold;">To:</span></b> sharath v &lt;sharath20284@yahoo.com&gt;<br><b><span style="font-weight: bold;">Cc:</span></b> insight-users@itk.org<br><b><span style="font-weight: bold;">Sent:</span></b> Tuesday, June 23, 2009 9:21:42
 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [Insight-users] Error using Registration - Mutual Information +  AffineTransform<br></font><br><br>Hi Sharath,<br><br>If you are interested in Affine registration you should probably <br>start with ImageRegistration9.cxx instead of modifying <br>ImageRegisration2.cxx.<br><br>In particular, you are probably missing to set up the <br>
ParameterScaling array, which is critical for normalizing the<br>dynamic range of the different Transform parameters.<br><br>This was not critical for the case of the Translation Transform,<br>but it becomes very important in Rigid and Affine transforms.<br>
<br><br>Please study the ImageRegistration9.cxx example and <br>let us know if you have any questions.<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Thanks<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Luis<br><br><br>----------------------------------------------------<br>
<div class="gmail_quote">On Tue, Jun 23, 2009 at 7:44 PM, sharath v <span dir="ltr">&lt;<a rel="nofollow" ymailto="mailto:sharath20284@yahoo.com" target="_blank" href="mailto:sharath20284@yahoo.com">sharath20284@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Hi,<br>
<br>
I am trying to run example ImageRegistration2 with Affine Transform. This example uses originally used Mutual Information based registration with Translation.<br>
<br>
I extended by using AffineTransform, and used the &nbsp;CenteredTransformInitializer for initialization ( according to example ImageRegistration9, which uses Affine with MeanSquares optimizer)<br>
<br>
But, I do run into errors.<br>
<br>
For the CenteredTransformInitializer, I use the following piece of code<br>
<br>
typedef itk::CenteredTransformInitializer&lt; TransformType, &nbsp;FixedImageType, &nbsp;MovingImageType &gt; &nbsp;TransformInitializerType;<br>
 &nbsp; &nbsp;TransformInitializerType::Pointer initializer = TransformInitializerType::New();<br>
 &nbsp; &nbsp;initializer-&gt;SetTransform( &nbsp; transform );<br>
 &nbsp; &nbsp;initializer-&gt;SetFixedImage( &nbsp;fixedImageReader-&gt;GetOutput() ); //*******<br>
 &nbsp; &nbsp;initializer-&gt;SetMovingImage( movingImageReader-&gt;GetOutput() ); //*******<br>
 &nbsp; &nbsp;initializer-&gt;MomentsOn();<br>
<br>
 &nbsp; &nbsp;initializer-&gt;InitializeTransform();<br>
 &nbsp; &nbsp;registration-&gt;SetInitialTransformParameters(transform-&gt;GetParameters() );<br>
<br>
The program runs into completion, but gives WRONG values for scale and rotation parameters. The translation parameters obtained are correct.<br>
<br>
If I change the starred lines (above in the code) to the take the output of the &nbsp;fixedSmoother and movingSmoother respectively ( which I think is correct, as they are output of the smoothing function in example2) , I get an exception<br>

<br>
***** Description: itk::ERROR: MutualInformationImageToImageMetric(012D3058): All the sampled point mapped &nbsp;to outside of the moving image<br>
<br>
I have tried the same with Mattes Mutual Information example, to get the same exception.<br>
<br>
I have also used the appropriate scale setting code as in example 9.<br>
<br>
<br>
<br>
Thanks in advance for the help,<br>
<br>
Sharath Venkatesha<br>
<br>
<br>
<br>
<br>
_____________________________________<br>
Powered by <a rel="nofollow" target="_blank" href="http://www.kitware.com">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br><span>
<a rel="nofollow" target="_blank" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a></span><br>
<br><span>
Please keep messages on-topic and check the ITK FAQ at: <a rel="nofollow" target="_blank" href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</a></span><br>
<br>
Follow this link to subscribe/unsubscribe:<br><span>
<a rel="nofollow" target="_blank" href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a></span><br>
</blockquote></div><br>
</div></div></div></div><br>

      </div></div></div><br>

      </body></html>