Environment:
cmake 3.16.0-rc4
InsightToolkit-5.0.1
macOS Catalina 10.15

Build And Install ITK

Download tar.gz file, extract it, create a building directory and go into it.
Then build the ITK project and install it.

cmake ../ -G "Unix Makefiles" \
-DModule_ItkVtkGlue:BOOL=ON

make 
sudo make install

-- Installing: /usr/local/include/ITK-5.0/itkWatershedSegmentTree.h
-- Installing: /usr/local/include/ITK-5.0/itkMorphologicalWatershedImageFilter.h
-- Installing: /usr/local/include/ITK-5.0/itkWatershedSegmenter.hxx
-- Installing: /usr/local/lib/libITKWatersheds-5.0.a
-- Installing: /usr/local/include/ITK-5.0/ITKWatershedsExport.h
-- Installing: /usr/local/lib/cmake/ITK-5.0/Modules/ITKWatersheds.cmake
-- Installing: /usr/local/lib/cmake/ITK-5.0/ITKConfig.cmake
-- Installing: /usr/local/lib/cmake/ITK-5.0/ITKConfigVersion.cmake
-- Installing: /usr/local/lib/cmake/ITK-5.0/ITKModuleAPI.cmake
-- Installing: /usr/local/lib/cmake/ITK-5.0/UseITK.cmake
-- Installing: /usr/local/lib/cmake/ITK-5.0/itkImageIOFactoryRegisterManager.h.in
-- Installing: /usr/local/lib/cmake/ITK-5.0/itkTransformIOFactoryRegisterManager.h.in
-- Installing: /usr/local/lib/cmake/ITK-5.0/itkMeshIOFactoryRegisterManager.h.in
-- Installing: /usr/local/lib/cmake/ITK-5.0/ITKTargets.cmake
-- Installing: /usr/local/lib/cmake/ITK-5.0/ITKTargets-release.cmake
-- Installing: /usr/local/share/doc/ITK-5.0/LICENSE
-- Installing: /usr/local/share/doc/ITK-5.0/NOTICE
-- Installing: /usr/local/share/doc/ITK-5.0/README.md

The Fisrt Example Based On ITK

CMakeLists.txt

cmake_minimum_required(VERSION 3.13)
project(mytest)

find_package(ITK REQUIRED)
include(${ITK_USE_FILE})

add_executable(${PROJECT_NAME} "main.cpp")
target_link_libraries(${PROJECT_NAME} ${ITK_LIBRARIES})

main.cpp

#include "itkImage.h"
#include "itkImageFileReader.h"
#include "QuickView.h"
#include <iostream>

int main()
{
    using PixelType = itk::RGBPixel<unsigned char>;
    using ImageType = itk::Image<PixelType, 2>;
    using ReaderType = itk::ImageFileReader<ImageType>;
    ReaderType::Pointer reader = ReaderType::New();
    const char *filePath = "/Users/weiyang/Desktop/Untitled.png";
    reader->SetFileName( filePath );
    reader->Update();

    QuickView viewer;
    viewer.AddImage( reader->GetOutput() );
    viewer.Visualize();

    return EXIT_SUCCESS;
}




0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

Content Summary
: Input your strings, the tool can get a brief summary of the content for you.

X
0
Would love your thoughts, please comment.x
()
x