# How to start my project in ITK C++ as a python programmer

**URL:** https://discourse.itk.org/t/how-to-start-my-project-in-itk-c-as-a-python-programmer/2219
**Category:** Beginner Questions
**Created:** [September 4, 2019, 11:13am UTC](https://discourse.itk.org/t/how-to-start-my-project-in-itk-c-as-a-python-programmer/2219 "2019-09-04T11:13:41Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Sara\_Caffe](https://discourse.itk.org/user_avatar/discourse.itk.org/sara_caffe/32/974_2.png) [@Sara\_Caffe](https://discourse.itk.org/u/Sara_Caffe)
#### Post date: [September 4, 2019, 11:13am UTC](https://discourse.itk.org/t/how-to-start-my-project-in-itk-c-as-a-python-programmer/2219/1 "2019-09-04T11:13:41Z")

</div>

Hi,

I have been programming in python, but now I have to move to C++. I am a beginner in ITK/VTK, C++ programming and new to these libraries. I started with [ITK examples](https://itk.org/Doxygen/html/examples.html), however, I do not know from which point should I start coding for my research. For example, working with python and writing function, reading the files from a folder, and calling the functions from a file that can be imported, is very easy and convenient.  
Is there any practical application and examples that I can see how the files and functions organization is being done?

I need to do the followings:

1. List and load the (.nii.gz) files in a folder into program

2. Extract meshes from the label files,

3. Find the corresponding points among the meshes

However, I am quite confused from which point should I start, which functions and libraries can I use.  
I know that If I follow few examples, I can apply the similar procedure on my project. Then, it will be much easier to work with C++ ITK/VTK libraries. This is how I learnt python.

Your expert opinion is really appreciate, or if you know any freely available examples or codes that can help to beginners to code the projects and learn about style of coding in ITK, could you please share?

Thanks

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [September 4, 2019, 1:32pm UTC](https://discourse.itk.org/t/how-to-start-my-project-in-itk-c-as-a-python-programmer/2219/2 "2019-09-04T13:32:58Z")

</div>

Parsing directories has nothing to do with ITK, so [this StackOverflow question](https://stackoverflow.com/questions/612097/how-can-i-get-the-list-of-files-in-a-directory-using-c-or-c) should help.

For converting labels into meshes, [BinaryMask3DMeshSource](https://itk.org/Doxygen/html/classitk_1_1BinaryMask3DMeshSource.html) could be used.

Finding the corresponding points among the meshes is a [non-trivial task](https://courses.cs.washington.edu/courses/cse577/11au/notes/Z12.pdf), and is probably better suited for a mesh processing library. ITK is an image processing library, with some mesh import, export and conversion functionality.

---

<div class="post-metadata">

### Author: ![tim-evain](https://discourse.itk.org/user_avatar/discourse.itk.org/tim-evain/32/220_2.png) [@tim-evain](https://discourse.itk.org/u/tim-evain)
#### Post date: [September 4, 2019, 2:22pm UTC](https://discourse.itk.org/t/how-to-start-my-project-in-itk-c-as-a-python-programmer/2219/3 "2019-09-04T14:22:47Z")

</div>

> [@dzenanz](#):
>
> Parsing directories has nothing to do with ITK, so [this StackOverflow question](https://stackoverflow.com/questions/612097/how-can-i-get-the-list-of-files-in-a-directory-using-c-or-c) should help.

@Sara_Caffe, as said by Dženan, filesystem manipulation is not related to ITK. However, in C++ this can be quite cumbersome compared to Python. There is no standard way before the C++17 iteration, and usually relies on third-party libraries, like [Boost](https://www.boost.org/doc/libs/1_39_0/libs/filesystem/doc/index.htm).  
Fortunately, if you have already ITK installed, it’s coming with the [KWSys](https://github.com/InsightSoftwareConsortium/ITK/tree/master/Modules/ThirdParty/KWSys) lib. While not really documented, it have plenty of easy-to-use function to access filesystem.

Also, since you seem to want to process meshes rather than images, you should take a look at [VTK](https://vtk.org), which is way more adapted.

HTH,

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [September 24, 2019, 7:46pm UTC](https://discourse.itk.org/t/how-to-start-my-project-in-itk-c-as-a-python-programmer/2219/4 "2019-09-24T19:46:23Z")

</div>

> [@tim-evain](#):
>
> Fortunately, if you have already ITK installed, it’s coming with the [KWSys](https://github.com/InsightSoftwareConsortium/ITK/tree/master/Modules/ThirdParty/KWSys) lib.

It is worth noting that in ITK, KWSys is available as _itksys_. Example usage can be found by [searching for this term in the source code](https://github.com/InsightSoftwareConsortium/ITK/search?q=itksys&unscoped_q=itksys).

If you have a newer C++ compiler, the C++17 [`filesystem`](https://en.cppreference.com/w/cpp/header/filesystem) header is part of the standard library.

> [@dzenanz](#):
>
> ITK is an image processing library, with some mesh import, export and conversion functionality.

> [@tim-evain](#):
>
> Also, since you seem to want to process meshes rather than images, you should take a look at [VTK](https://vtk.org), which is way more adapted

ITK actually contains a number of powerful methods for registration of mesh points sets. For more information, see [this example](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Registration/Metricsv4/test/itkExpectationBasedPointSetMetricRegistrationTest.cxx), for example, and @ntustison’s papers on the information-theoretic metrics:

- [(PDF) Point Set Registration Using Havrda&#x2013;Charvat&#x2013;Tsallis Entropy Measures | Nick Tustison - Academia.edu](https://www.academia.edu/20584207/Point_Set_Registration_Using_Havrda_and_x2013_Charvat_and_x2013_Tsallis_Entropy_Measures)
- [https://www.insight-journal.org/browse/publication/304](https://www.insight-journal.org/browse/publication/304)
