To develop desktop medical image software, several essential C++ libraries are recommended for GUI design, graphical rendering and image processing. Here we will provide a detailed instruction on the configuration and compilation of the toolchain.
The toolchain we recommended is cross platform applicable (Windows, MacOS, Linux). The procedure works almost the same on different OS. Also the suggested library packages also provide Python interface for users who are not familiar with C++ coding.
Beware of software version and build sequence. Wrong version may cause compilation error.
If trying to build with Qt-5.12
and Microsoft Visual Studio 2019
, then build will fail with the error error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QLinkedListData::QLinkedListData(void)"
. The solution is to either change the toolset version to an earlier one (e.g., Visual Studio 2015) or upgrade Qt (e.g., use Qt-5.15 with Visual Studio 2019).
It is known that newer version of ITK and VTK is not compatible with VMTK 1.4.
Since the libraries relies on one another, sequence of build is also essential to bind the toolchain. Recommended flow is Qt
->VTK
->OpenCV
->DCMTK(optnional)
->ITK
->others
For users who would like to develop with Python interface, Anaconda would include most of the dependent libraries like pyqt and vtk. You may install other necessary packages like OpenCV or ITK via pip or conda.
C++ | Python | |
---|---|---|
GUI | Qt | pyqt |
Graphical Rendering | VTK | vtk |
Image Processing (2D/3D/N-D) | ITK | SimpleITK |
Image Processing (2D) | OpenCV | OpenCV |
Note that SimpleITK is a lite version of ITK that provides convenient manipulation methods for Python users. ITK also provide Python interface yet is not a popular choice for its relative complex syntax.
Here we will demonstrate the install procedures for MSVC 2015. For Unix you may follow the CMake terminal build guild.
We recommend to build the toolchain with following folder hierarchy:
.
├── source
│ ├── qt-installer.exe
│ ├── vtk
│ ├── itk
│ └── ...
├── build
│ ├── qt
│ ├── vtk
│ ├── itk
│ └── ...
.
├── qt
├── vtk
│ ├── build
│ ├── <source-code>
│ └── ...
├── itk
│ ├── build
│ ├── <source-code>
│ └── ...
├── ...
Note: Qt does not provide 64bit MinGW pre-compiled version.
git clone -b v8.2.0 https://github.com/Kitware/VTK.git
Open CMake and choose the source code directory and binary build directory. Here we choose Style 1
folder structure.
Press Configure
and choose Visual Studio 14 2015 Win64
for 64bit build. Wait until first time configuration complete. This step may take around 10 min.
Configure
again to take effective. Some options like Qt5_DIR
and VTK_QT_VERSION
will only appear after VTK_Group_Qt
is checked and configured. You may need to configure several times before all the necessary values are set.
# speed up the build
BUILD_DOCUMENTATION:BOOL=OFF
BUILD_EXAMPLES:BOOL=OFF
BUILD_TESTING:BOOL=OFF
# must check shared library build to export for future use
BUILD_SHARED_LIBS:BOOL=ON
# OpenGL stuff
Module_vtkImagingOpenGL2:BOOL=ON
Module_vtkIOExportOpenGL2:BOOL=ON
Module_vtkRenderingLICOpenGL2:BOOL=ON
#
VTK_QT_VERSION:STRING=5
VTK_Group_Qt:BOOL=ON
Module_vtkGUISupportQt:BOOL=ON
Module_vtkGUISupportQtOpenGL:BOOL=ON
Module_vtkGUISupportQtSQL:BOOL=ON
Module_vtkGUISupportQtWebkit:BOOL=OFF
Qt5_DIR:PATH=${Qt5_DIR}
Qt5Core_DIR:PATH=${Qt5_DIR}/Core
Qt5Gui_DIR:PATH=${Qt5_DIR}/Gui
Qt5OpenGL_DIR:PATH=${Qt5_DIR}/OpenGL
Qt5Sql_DIR:PATH=${Qt5_DIR}/Sql
Qt5UiPlugin_DIR:PATH=${Qt5_DIR}/UiPlugin
Qt5Widgets_DIR:PATH=${Qt5_DIR}/Widgets
Error box will popup after choosing VTK_Group_Qt
. You need to provide the correct path to make the configuration success.
${Qt5_DIR}
is located at <qt-install-directory>/5.10.1/msvc2015_64/lib/cmake
if you are using Qt 5.10.1 and MSVC 2015.
The new values are highlighted in red. If the configuration is complete you will see Configuring done
at the lower part output, or else error messages will be displayed.
Generate
for C++ build..sln
file in the binary build folder and choose build version Debug
and x64
.
Build
-> Build Solution
and wait until all build success.
Release
build type and redo step 7 again.make
command to build the library. Similar build method applies for XCode. git clone -b v3.4 https://github.com/opencv/opencv
Open CMake and choose the source code directory and binary build directory. Here we choose Style 1
folder structure.
Press Configure
and choose Visual Studio 14 2015 Win64
for 64bit build. Wait until first time configuration complete. This step may take around 10 min.
Change the following build options. Then press Configure
again to take effective.
BUILD_DOCS:BOOL=OFF
BUILD_EXAMPLES:BOOL=OFF
BUILD_TESTS:BOOL=OFF
BUILD_SHARED_LIBS:BOOL=ON
BUILD_WITH_STATIC_CRT:BOOL=ON
BUILD_opencv_java:BOOL=OFF
BUILD_opencv_python3:BOOL=OFF
WITH_MATLAB:BOOL=OFF
# Choose ON if you need OpenCV with CUDA acceleration
WITH_CUDA:BOOL=OFF
git clone -b v4.13.3 https://github.com/Kitware/ITK.git
Open CMake and choose the source code directory and binary build directory. Here we choose Style 1
folder structure.
Press Configure
and choose Visual Studio 14 2015 Win64
for 64bit build. Wait until first time configuration complete. This step may take around 10 min.
Configure
again to take effective.
BUILD_DOCUMENTATION:BOOL=OFF
BUILD_EXAMPLES:BOOL=OFF
BUILD_SHARED_LIBS:BOOL=ON
BUILD_TESTING:BOOL=OFF
# VTK
Module_ITKVtkGlue:BOOL=ON
VTK_DIR:PATH=${CMAKE_BINARY_DIR}/VTK-build
# OpenCV
Module_ITKVideoBridgeOpenCV:BOOL=ON
OpenCV_DIR:PATH=${CMAKE_BINARY_DIR}/OpenCV-build
# VMTK requires class in ITKReview
Module_ITKReview:BOOL=ON
ITK_USE_SYSTEM_DOUBLECONVERSION=ON
You can extend the toolchain with other medical image related libraries
A set of common support code for medical imaging, surgical navigation, and related purposes.
BUILD_DOCUMENTATION:BOOL=OFF
CTK_BUILD_EXAMPLES:BOOL=OFF
CTK_BUILD_SHARED_LIBS:BOOL=ON
BUILD_TESTING:BOOL=OFF
CTK_ENABLE_DICOM:BOOL=ON
CTK_LIB_DICOM/Core:BOOL=ON
CTK_LIB_DICOM/Widgets:BOOL=ON
CTK_QT_VERSION:STRING=5
Qt5_DIR:PATH=${Qt5_DIR}
DCMTK is a collection of libraries and applications implementing large parts the DICOM standard. It includes software for examining, constructing and converting DICOM image files, handling offline media, sending and receiving images over a network connection, as well as demonstrative image storage and worklist servers. DCMTK is is written in a mixture of ANSI C and C++. It comes in complete source code and is made available as “open source” software.
CMAKE_INSTALL_PREFIX:PATH=${DCMTK_INSTALL_DIR}
The Vascular Modeling Toolkit is a collection of libraries and tools for 3D reconstruction, geometric analysis, mesh generation and surface data analysis for image-based modeling of blood vessels.
The Image-Guided Surgery Toolkit (IGSTK) is a framework that integrates a set of high-level components with low-level open source software libraries and application programming interfaces (APIs) from hardware vendors. In addition to its interface to common tracking hardware (e.g., Aurora from Northern Digital Inc.), IGSTK has a GUI.
TubeTK is an open-source toolkit for the segmentation, registration, and analysis of tubes and surfaces in images.
Tubes and surfaces, as generalized 1D and 2D manifolds in N-dimensional images, are essential components in a variety of image analysis tasks. Instances of tubular structures in images include blood vessels in magnetic resonance angiograms and b-mode ultrasound images, wires in microscopy images of integrated circuits, roads in aerial photographs, and nerves in confocal microscopy.