Building and integrating external modules

Hello again,

I want to use an external module e.g. itkOBBLabelMap.

My approach to buidl ITK with the external module:

  1. The following is a brief list of instructions to get a external module into ITK:
    cd ITK/Modules/External/
    git clone https://github.com/blowekamp/itkOBBLabelMap.git

  2. After this is rerun cmake (version 3.10) and configured the build with Module_ITKOBBLabelMap=ON.
    Clicked Configure, then Generate.

  3. When I opened the solution file in VS2015 the external module is listed as project ‘ITKOBBLabelMap-all’. I built the project. The build was successful (at least what VS said).

Once I open a file from the module. I got errors because of missing header files for ITK modules. For example in “itkBoundingBoxImageLabelMapFilter.h” “itkInPlaceLabelMapFilter.h” could not be found. I checked the project configurations and neither include paths (except from the standard paths are set) nor libs were set/linked.

When I set up an own project with the module the headers are found (CMakeLists.txt and testfile.cxx below). But if I want to build it the same errors are shown as before.
Unfortunately External Module Wikipage does not provide more information.

Maybe the CMakeLists file of the external module is not up-to-date or did i miss a step?
(I am using Windows 10, 64bit, cmake-gui, VS2015)

Sincerly,
Gordian

==CMakeLists.txt==
cmake_minimum_required(VERSION 3.10)
project(testproject)
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})
add_executable(testproject testfile.cxx)
target_link_libraries(testproject ${ITK_LIBRARIES})

==testfile.cxx==
#include “itkOrientedBoundingBoxImageLabelMapFilter.h”

const unsigned int dim = 3;
typedef itk::Image<float, dim> ImageType;
typedef itk::OrientedBoundingBoxImageLabelMapFilter<ImageType, ImageType> BoundingBoxFilter;

int main(int argc, const char * argv[])
{
auto boxFilter = BoundingBoxFilter::New();
return EXIT_SUCCESS;
}

Hello @Gordian,

@jhlegarreta has proposed additions and improvements to the external module documentation for the ITK Software Guide. Your review of these changes would be appreciated.

For your build error, in the CMakeLists.txt, change

find_package(ITK REQUIRED)

to

find_package(ITK REQUIRED COMPONENTS ITKOBBLabelMap <OtherModule1> <OtherModule1> [...])

where ITKOBBLabelMap is the name of the module, and <OtherModule1> <OtherModule2> [...] are the other modules that your code needs. These can be found by running the WhatModulesITK.py script.

Hope this helps,
Matt

Thank you for your fast response.

I scanned through the proposed additions but I didnt find anything helpful.
After incorporating your change in the CMakeLists.txt the errors still exist.
By running the WhatModulesITK.py script the result was that I need one module since I have only a single include.

interestingly if I use the right-click to open the itkobb-include files using the dropdown menu it works in my test example but not in the ITK-project with the external module.

Any other thoughts?

Hello Gordian,

That is my module I worked on quite a few years ago at this point. Has not been updated much, and the documentation was thin to say the least.

The computations for the Oriented Bounding Box has been integrated in ITK as part of the LabelShapObject computed in the ShapeLabelMapFilter which is utilized by the convenient LabelImageToShapLabelMapFilter. This method has been improved for performance, and accuracy along with now being thoroughly tested with non-trivial oriented images.

The one filter you utilized, OrientedBoundingBoxImageLabelMapFilter, utilizes that above it formation to resample into original image in to oriented smaller images. This has not been incorporated into ITK (yet?). But it’s fairly trivial to just use the ResampleImageFilter.

There is also a SimpleITK note book which demonstrates this usage:

HTH,
Brad

2 Likes

Hello Brad,
thank you for pointing out that the itkOBBImageFilter is already include in the ITK. This helped my immediate problem. The general problem still exist.

I will try to create an external module for my topic. Along the way I can describe what problems I encounter. This might clarify things for me. I will report back.

1 Like

@gordian Needless to say that I’d be happy to improve the existing documentation, to remove redundant or flawed instructions, etc.

This could also be part of a reduced documentation for ITKModuleTemplate.

So if you have proposal in which the doc could be improved, contribute with a branch or PR to the concerned doc, either ITK CONTRIBUTING, the ITK SW Guide or ITKModuleTemplate.

We’d glad to assist in the process of contributing as well.

So please report and propose enhancements for any specific aspects that needs to be improved.

Hi again,

i wrote a doucmentation about my process for dowloading and building an external module.
I tried two different ways (td;dr):

  1. Src in ITK source tree/Modules/External/MyModule and build in the ITK build tree/Modules/External/MyModule
    Build was successful(?) but (itk-)header could not be found.

  2. Src in somewhereElse/MyModule and build in the ITK build tree/Modules/External/MyModule
    Build was successful. Test finished fine but the module is not listed in the itk_modules.

If someone is interested in the document (it not so much to read) I would mail it and we could discuss the unclear topics here so that everyone else can participate.

I have no idea what the cause of this is but I would like to have it sorted out.

Thank you for your help this far.

Hi @Gordian,

The ideal approach is for both the MyModule source and build trees to be outside the ITK source and build trees. The ITKModuleTemplate that @jhlegarreta referenced makes this possible.

Hope this helps,
Matt

Hi, @matt.mccormick and @Gordian

I have a rather simple question regarding external modules as well. I’m interested in using the code for Label object representation and manipulation with ITK. However, when I download the source code, place it in ITK/Modules/External and rerun CMake, I don’t see any flag to turn on this particular module. Could you please help me with this?

Thank you very much!

Hi @pfreire,

I believe the classes from this IJ have already been integrated into the toolkit. See

ITK: Module ITKLabelMap

1 Like

A post was split to a new topic: ITKIOScanco module