[ITK] [ITK-users] help

Jon Haitz Legarreta jhlegarreta at vicomtech.org
Wed Apr 29 05:46:47 EDT 2015


Dear Denis,
you're welcome.

Please, keep the conversation in the mailing list so that you have better
chances of getting an answer.

If you downloaded and built the sources, you would include ITK in your
project [1] (i.e. outside the ITK source tree).

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.

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.

Then compile and test.

HTH,
JON HAITZ

[1] http://www.itk.org/Wiki/ITK/HelloInsight



On 29 April 2015 at 11:32, Abu-Sammour, Denis <
Denis.Abu-Sammour at medma.uni-heidelberg.de> wrote:

> Dear Jon,
>
>
>
> 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 ImageRegistration8.cxx
> example which actually uses itkMeanSquaresImageToImageMetricv4 as a
> metric and which is included in the header file #include
> "itkMeanSquaresImageToImageMetricv4.h”. Now suppose that I want to write
> my own metric i.e. MyMetric 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 itkMeanSquaresImageToImageMetricv4.txx, paste it inside
> the project as a new class, and modify it based on my own needs.
> Specifically, I will need to modify the 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? itkImageToImageMetric.h
> I suppose?
>
>
>
> Thank you for your time and consideration.
>
>
>
> Denis
>
>
>
>
>
> *Von:* Jon Haitz Legarreta [mailto:jhlegarreta at vicomtech.org]
> *Gesendet:* Mittwoch, 29. April 2015 10:27
> *An:* Abu-Sammour, Denis
> *Cc:* community at itk.org
> *Betreff:* Re: [ITK-users] help
>
>
>
> Hi Denis,
>
> welcome to ITK. ITK's wiki [1] can be extremely helpful to start with ITK.
>
>
>
> 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.
>
>
>
> One of the most sensible alternatives you have is to download the ITK
> sources, build them and include it in your project.
>
>
>
> Once you do that, you may want to create your own, specialized metric
> class, inheriting from the corresponding ITK base class so that you avoid
> duplicating methods and work that has already been done.
>
>
>
> 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].
>
>
>
> HTH,
>
> JON HAITZ
>
>
>
>
>
> [1] http://www.itk.org/Wiki/ITK/Getting_Started
>
> [2] http://www.itk.org/Wiki/ITK/Contribute
>
>
>
>
>
> On 29 April 2015 at 09:04, Abu-Sammour, Denis <
> Denis.Abu-Sammour at medma.uni-heidelberg.de> wrote:
>
> Dear itk Community,
>
>
>
> 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.
>
>
>
> Now I have found a itkMeanSquaresImageToImageMetric.txx on the web which I
> suppose is a templated class code (
> http://www.na-mic.org/svn/Slicer3-lib-mirrors/trunk/Insight/Code/Algorithms/itkMeanSquaresImageToImageMetric.txx).
> 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?!
>
>
>
> 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..
>
>
>
> Thanks you for your time and consideration.
>
>
>
> Denis
>
>
>
>
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> 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://public.kitware.com/mailman/listinfo/insight-users
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20150429/58842b86/attachment.html>


More information about the Community mailing list