<div class="gmail_quote"><div>Hi, </div><div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="border-collapse:separate;font-family:arial"><div><br></div><div>I found what i missed in the code.</div>
<div>I forgot set translation of the transform. Sorry for wasting your time!</div><div><br></div><div>Here is the code, if you want to.</div><div>---------------------------------------------------</div><div><div>.......... </div>
<div class="im">
<div> transform->SetScale(1.08438);</div><div><span style="white-space:pre">        </span>transform->SetAngle(0.154531);</div><div><span style="white-space:pre">        </span>TransformType::TranslationType translation;</div>
<div><span style="white-space:pre">        </span>translation[0] = -26.6822;</div><div><span style="white-space:pre">        </span>translation[1] = -93.6822;</div><div><br></div></div><div>
<span style="white-space:pre">        </span><b><i>transform->SetTranslation(translation);</i></b></div><div class="im"><div><br></div><div><span style="white-space:pre">        </span>MetricType::TransformParametersType transformParams = transform->GetParameters();</div>
<div><br></div><div><span style="white-space:pre">        </span>double metricval = metric->GetValue(transformParams);</div></div><div>.............</div><div>----------------------------------------------------</div>
<div><br></div><div>The metric value is 4570.285. It is much closer to <span style="font-family:arial, sans-serif;font-size:12px;border-collapse:collapse">4551.86, still not the same ???</span></div>
<div><span style="font-family:arial, sans-serif;font-size:12px;border-collapse:collapse"><br></span></div><div><span style="font-family:arial, sans-serif;font-size:12px;border-collapse:collapse">I found a strange problem, i played around with the images, i swap role of images (fixed.bmp <-> moving.bmp) and the result i got (2715.557) event smaller than the value from registration process (4551.86). As far as i know, the registration's result is supposed to produce minimum value of metric value (is that right?) if so, what is wrong here? </span></div>
<div><span style="font-family:arial, sans-serif;font-size:12px;border-collapse:collapse"><br></span></div><div><span style="font-family:arial, sans-serif;font-size:12px;border-collapse:collapse"><span style="border-collapse:separate;font-family:arial;font-size:small"><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse">You can reproduce the result with following two images </span></font></div><div><font color="#666666" face="Arial" size="2"><span style="border-collapse:collapse;font-size:10px;white-space:pre"><a href="http://picasaweb.google.com/lh/photo/qq5iA-PTGX6o3ZtslBX5HQ?authkey=Gv1sRgCPfxyPeBwITjkwE&feat=directlink" target="_blank">fixed.bmp</a>; <a href="http://picasaweb.google.com/phamsyquybk/DropBox?authkey=Gv1sRgCPfxyPeBwITjkwE#5388585730742727138" target="_blank">moving.bmp</a><br>
</span></font></div><div><font color="#666666" face="Arial" size="2"><br></font></div></span></span></div><div><span style="font-family:arial, sans-serif;font-size:12px;border-collapse:collapse">Thanks,</span></div>
<div><span style="font-family:arial, sans-serif;font-size:12px;border-collapse:collapse">Quyps</span></div><div><span style="font-family:arial, sans-serif;font-size:12px;border-collapse:collapse"><br>
</span></div></div></span></span></font></div><div class="gmail_quote">2009/10/4 Quy Pham Sy <span dir="ltr"><<a href="mailto:phamsyquybk@gmail.com" target="_blank">phamsyquybk@gmail.com</a>></span><div><div></div>
<div class="h5"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi, sorry for this lack,<div><br></div><div><div><span style="font-family:arial, sans-serif;font-size:12px;border-collapse:collapse">/*For cases*/</span></div>
<div><span style="font-family:arial, sans-serif;font-size:12px;border-collapse:collapse">transform->SetAngle(8.85397); --> metric value = 12528.007</span></div>
<div><span style="font-family:arial, sans-serif;font-size:12px;border-collapse:collapse">transform->SetAngle(<span style="font-family:arial, sans-serif;font-size:12px;border-collapse:collapse">0.154531</span>); --> metric value = 10993.347</span></div>
<div><br></div><div>result from example is <span style="font-family:arial, sans-serif;font-size:12px;border-collapse:collapse">4551.86</span></div><div><span style="font-family:arial, sans-serif;font-size:12px;border-collapse:collapse"><br>
</span></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">I send you two image, could you please try to reproduce this? </span></font></div><div><div></div><div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">Thanks,</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">Quyps</span></font></div><div><br><div class="gmail_quote">2009/10/3 Bill Lorensen <span dir="ltr"><<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">What value did you get?<br>
<div><div></div><div><br>
On Sat, Oct 3, 2009 at 4:55 AM, Quy Pham Sy <<a href="mailto:phamsyquybk@gmail.com" target="_blank">phamsyquybk@gmail.com</a>> wrote:<br>
> Hi,<br>
> I tried with radian,<br>
> --------------------------------------------<br>
> .....<br>
> transform->SetScale(1.08438);<br>
> transform->SetAngle(0.154531);<br>
> TransformType::TranslationType translation;<br>
> translation[0] = -26.6822;<br>
> translation[1] = -93.6822;<br>
> .....<br>
> --------------------------------------------<br>
> I got new value but still not '4551.86' (the value from example).<br>
> I read from "ITK software guide ver 2.4" textbook, page 366. they explained<br>
> (as i understand) that the output transform params from registration process<br>
> are actually applied to FixeImage, in order to get the minimum metric<br>
> value.<br>
> It is still not clear that, the transform params pass directly to metric<br>
> object are interpreted same way as in registration process (i mean they also<br>
> applied to Fixed image instead of Moving Image). I guess the reason may come<br>
> from this unobvious understanding. Do you have any idea about this?<br>
><br>
> Thanks,<br>
> Quyps<br>
><br>
> 2009/10/3 Bill Lorensen <<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>><br>
>><br>
>> /** Set/Get the angle of rotation in radians */<br>
>> ----------<br>
>> void SetAngle(TScalarType angle);<br>
>> itkGetConstReferenceMacro( Angle, TScalarType );<br>
>><br>
>> Try:<br>
>> transform->SetAngle(0.154531);<br>
>><br>
>> On Fri, Oct 2, 2009 at 4:09 PM, Quy Pham Sy <<a href="mailto:phamsyquybk@gmail.com" target="_blank">phamsyquybk@gmail.com</a>> wrote:<br>
>> > hi,<br>
>> > I run ImageRegistration7 example in ITK.<br>
>> > and the output like following<br>
>> > -------------------------------------<br>
>> > Scale = 1.08438<br>
>> > Angle (radians) 0.154531<br>
>> > Angle (degrees) 8.85397<br>
>> > Center X = 170.327<br>
>> > Center Y = 148.556<br>
>> > Translation X = -26.6822<br>
>> > Translation Y = -93.4428<br>
>> > Iterations = 500<br>
>> > Metric value = 4551.86<br>
>> > ---------------------------------------<br>
>> > I made a program in which i use a same metric, transformation,<br>
>> > interpolate<br>
>> > object type as above example, with same two input image file. I set<br>
>> > above<br>
>> > value to calculate metric value directly from metric object, but the<br>
>> > result<br>
>> > is not same as what the example made..<br>
>> > here is the code, did i miss something?<br>
>> > I'm running out of time! really appreciate any help!<br>
>> ><br>
>> > -------------------------------------------------------------------------<br>
>> > int main( int argc, char * argv[] )<br>
>> > {<br>
>> > const unsigned int Dimension = 2;<br>
>> > typedef unsigned char PixelType;<br>
>> > typedef itk::Image< PixelType, Dimension > ImageType;<br>
>> > typedef itk::ImageFileReader< ImageType > ReaderType;<br>
>> > ReaderType::Pointer fixedReader = ReaderType::New();<br>
>> > ReaderType::Pointer movingReader = ReaderType::New();<br>
>> > fixedReader->SetFileName( "fixed.bmp" );<br>
>> > movingReader->SetFileName( "moving.bmp" );<br>
>> > try<br>
>> > {<br>
>> > fixedReader->Update();<br>
>> > movingReader->Update();<br>
>> > }<br>
>> > catch( itk::ExceptionObject & excep )<br>
>> > {<br>
>> > std::cerr << "Exception catched !" << std::endl;<br>
>> > std::cerr << excep << std::endl;<br>
>> > }<br>
>> > typedef itk::MeanSquaresImageToImageMetric< ImageType, ImageType ><br>
>> > MetricType;<br>
>> > MetricType::Pointer metric = MetricType::New();<br>
>> > typedef itk::CenteredSimilarity2DTransform < double > TransformType;<br>
>> > TransformType::Pointer transform = TransformType::New();<br>
>> > typedef itk::LinearInterpolateImageFunction< ImageType, double ><br>
>> > InterpolatorType;<br>
>> > InterpolatorType::Pointer interpolator = InterpolatorType::New();<br>
>> > ImageType::Pointer fixedImage = fixedReader->GetOutput();<br>
>> > ImageType::Pointer movingImage = movingReader->GetOutput();<br>
>> > typedef itk::CenteredTransformInitializer< TransformType, ImageType,<br>
>> > ImageType > TransformInitializerType;<br>
>> > TransformInitializerType::Pointer initializer =<br>
>> > TransformInitializerType::New();<br>
>> > initializer->SetTransform( transform );<br>
>> > initializer->SetFixedImage( fixedImage );<br>
>> > initializer->SetMovingImage( movingImage );<br>
>> > initializer->MomentsOn();<br>
>> > initializer->InitializeTransform();<br>
>> > metric->SetTransform( transform );<br>
>> > metric->SetInterpolator( interpolator );<br>
>> > metric->SetFixedImage( fixedImage );<br>
>> > metric->SetMovingImage( movingImage );<br>
>> > metric->SetFixedImageRegion( fixedImage->GetBufferedRegion() );<br>
>> > try<br>
>> > {<br>
>> > metric->Initialize();<br>
>> > }<br>
>> > catch( itk::ExceptionObject & excep )<br>
>> > {<br>
>> > std::cerr << "Exception catched !" << std::endl;<br>
>> > std::cerr << excep << std::endl;<br>
>> > return EXIT_FAILURE;<br>
>> > }<br>
>> > transform->SetScale(1.08438);<br>
>> > transform->SetAngle(0.154531);<br>
>> > TransformType::TranslationType translation;<br>
>> > translation[0] = -26.6822;<br>
>> > translation[1] = -93.6822;<br>
>> > MetricType::TransformParametersType transformParams =<br>
>> > transform->GetParameters();<br>
>> > double metricval = metric->GetValue(transformParams);<br>
>> > return EXIT_SUCCESS;<br>
>> > }<br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> > _____________________________________<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>
><br>
><br>
>> _____________________________________<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>
</div></div></blockquote></div><br>
</div></div></div></div>
</blockquote></div></div></div><br><br>
</div>
</div><br><br clear="all"><br>-- <br>Pham Sy Quy<br>HCI Lab, Advanced Fusion Technology Department, <br>Room 1211, New Millennium Building<br>Konkuk University, Seoul, Korea<br>Mobile: +82-10-9800-8104<br>