<div dir="ltr"><span style="font-size:12.8000001907349px">Dear Denis,</span><div style="font-size:12.8000001907349px">you're welcome.</div><div style="font-size:12.8000001907349px"><br><div>Please, keep the conversation in the mailing list so that you have better chances of getting an answer.</div><div><br></div><div>If you downloaded and built the sources, you would include ITK in your project [1] (i.e. outside the ITK source tree).</div><div><br></div><div>Then you can create your image-to-image metric. If your metric is an specialization or variant of itkMeanSquaresImageToImageMetricv4, you can take the class (i.e. the .h and .hxx files), make a new one with the name you deem appropriate, and modify the methods you want to enhance/specialize.</div><div><br></div><div>Then write your own example inspired by the most appropriate example from the registration series (say, ImageRegistration8.cxx as you mention), include the .h file of your new metric class, and modify the example appropriately.</div><div><br></div><div>Then compile and test.</div><div><br></div><div>HTH,</div><div>JON HAITZ</div><div><br></div><div>[1] <a href="http://www.itk.org/Wiki/ITK/HelloInsight" target="_blank">http://www.itk.org/Wiki/ITK/HelloInsight</a></div><div><br></div></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On 29 April 2015 at 11:32, Abu-Sammour, Denis <span dir="ltr"><<a href="mailto:Denis.Abu-Sammour@medma.uni-heidelberg.de" target="_blank">Denis.Abu-Sammour@medma.uni-heidelberg.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif"">Dear Jon,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif"">Thank you for your reply. I am done with the Getting Started phase of itk i.e. itk sources are downloaded, built successfully and some examples tested. My specific interest is about (highlighted below)  what is the easiest way of starting writing a new metric (similarity measure) on an existing Registration example. So suppose I take </span><span style="font-family:"Courier New"">ImageRegistration8.cxx</span><span style="font-family:"Calibri","sans-serif""> example which actually uses </span><span style="font-family:"Courier New"">itkMeanSquaresImageToImageMetricv4</span><span style="font-family:"Calibri","sans-serif""> as a metric and which is included in the header file </span><span style="font-family:"Courier New"">#include "itkMeanSquaresImageToImageMetricv4.h”. </span><span style="font-family:"Calibri","sans-serif"">Now suppose that I want to write my own metric i.e. </span><span style="font-family:"Courier New"">MyMetric </span><span style="font-family:"Calibri","sans-serif"">which I can link to the registration process as done in the examples. I imagine that the easiest way to proceed is copy the code of the </span><span style="font-family:"Courier New"">itkMeanSquaresImageToImageMetricv4.txx, </span><span style="font-family:"Calibri","sans-serif"">paste it inside the project as a new class, and modify it based on my own needs. Specifically, I will need to modify the </span><span style="font-family:"Calibri","sans-serif"">GetValue (), GetDerivative  () and GetValueAndDerivative () members of that class. Is this the right (i.e. the easiest way for a novice itk and cpp user) to proceed? And what header should I include for this metric class to be derived from? </span><span style="font-family:"Courier New"">itkImageToImageMetric.h </span><span style="font-family:"Calibri","sans-serif"">I suppose? <u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif"">Thank you for your time and consideration. <u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif"">Denis<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><b><span lang="DE" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">Von:</span></b><span lang="DE" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Jon Haitz Legarreta [mailto:<a href="mailto:jhlegarreta@vicomtech.org" target="_blank">jhlegarreta@vicomtech.org</a>] <br><b>Gesendet:</b> Mittwoch, 29. April 2015 10:27<br><b>An:</b> Abu-Sammour, Denis<br><b>Cc:</b> <a href="mailto:community@itk.org" target="_blank">community@itk.org</a><br><b>Betreff:</b> Re: [ITK-users] help<u></u><u></u></span></p><div><div class="h5"><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">Hi Denis,<u></u><u></u></p><div><p class="MsoNormal">welcome to ITK. ITK's wiki [1] can be extremely helpful to start with ITK.<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Copying the code of the class you are referring to will be of no advantage, since it includes and inherits from a variety of other ITK classes. And unless your project includes and links against ITK, your approach will not work.<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">One of the most sensible alternatives you have is to download the ITK sources, build them and include it in your project.<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><span style="background:yellow">Once you do that, you may want to create your own, specialized metric class, inheriting from the corresponding ITK base class</span> so that you avoid duplicating methods and work that has already been done.<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">And last but not least, if your metric has an added value compared to what exists in ITK, you may want to submit a contribution to the library [2].<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">HTH,<u></u><u></u></p></div><div><p class="MsoNormal">JON HAITZ<u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">[1] <a href="http://www.itk.org/Wiki/ITK/Getting_Started" target="_blank">http://www.itk.org/Wiki/ITK/Getting_Started</a><u></u><u></u></p></div><div><p class="MsoNormal">[2] <a href="http://www.itk.org/Wiki/ITK/Contribute" target="_blank">http://www.itk.org/Wiki/ITK/Contribute</a><u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">On 29 April 2015 at 09:04, Abu-Sammour, Denis <<a href="mailto:Denis.Abu-Sammour@medma.uni-heidelberg.de" target="_blank">Denis.Abu-Sammour@medma.uni-heidelberg.de</a>> wrote:<u></u><u></u></p><div><div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Calibri","sans-serif"">Dear itk Community,<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Calibri","sans-serif""> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Calibri","sans-serif"">I am a fresh user of itk and c++ as well. I am trying to implement a new metric (similarity measure) to be used for image registration which is not available in the metrics provided by itk. I have seen comments on how to do that which simply stated to take a metric that is already implemented in itk such as “MeanSquaresImageToImageMetric” and modify the content specifically GetValue (), GetDerivative  () and GetValueAndDerivative () members. <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Calibri","sans-serif""> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Calibri","sans-serif"">Now I have found a itkMeanSquaresImageToImageMetric.txx on the web which I suppose is a templated class code (<a href="http://www.na-mic.org/svn/Slicer3-lib-mirrors/trunk/Insight/Code/Algorithms/itkMeanSquaresImageToImageMetric.txx" target="_blank">http://www.na-mic.org/svn/Slicer3-lib-mirrors/trunk/Insight/Code/Algorithms/itkMeanSquaresImageToImageMetric.txx</a>).  As a primitive itk and cpp user, what I have in mind is to copy and paste the content of this class into my code, modify the GetValue (), GetDerivative () and GetValueAndDerivative () functions and rename anything that says  “MeanSquaresImageToImageMetric” with my own metric i.e. “MyMetric”. Afterwards link it to the registration as outlined in the itk examples. Is that the way to go for it?! <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Calibri","sans-serif""> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Calibri","sans-serif"">Additionally, in the “itkMeanSquaresImageToImageMetric.txx” there is also #include “itkMeanSquaresImageToImageMetric.h”, should I leave it as is or modify it to #include “itkImageToImageMetric.h” instead? I am a bit lost here.. <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Calibri","sans-serif""> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Calibri","sans-serif"">Thanks you for your time and consideration.<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#888888"> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#888888">Denis<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#888888"> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#888888"> <u></u><u></u></span></p></div></div><p class="MsoNormal" style="margin-bottom:12.0pt"><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>Kitware offers ITK Training Courses, for more information visit:<br><a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</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://public.kitware.com/mailman/listinfo/insight-users" target="_blank">http://public.kitware.com/mailman/listinfo/insight-users</a><u></u><u></u></p></div><p class="MsoNormal"><u></u> <u></u></p></div></div></div></div></div></div></blockquote></div><br></div></div>