ITK/Examples/ImageProcessing/ClampImageFilter
From KitwarePublic
ClampImageFilter.cxx
#include "itkImage.h" #include "itkImageFileReader.h" #include "itkClampImageFilter.h" int main(int argc, char *argv[]) { if(argc < 2) { std::cerr << "Required: filename" << std::endl; return EXIT_FAILURE; } typedef itk::Image<unsigned char, 2> UnsignedCharImageType; typedef itk::Image<float, 2> FloatImageType; typedef itk::ImageFileReader<FloatImageType> ReaderType; ReaderType::Pointer reader = ReaderType::New(); reader->SetFileName(argv[1]); typedef itk::ClampImageFilter< FloatImageType, UnsignedCharImageType > ClampFilterType; ClampFilterType::Pointer clampFilter = ClampFilterType::New(); clampFilter->SetInput(reader->GetOutput()); clampFilter->Update(); return EXIT_SUCCESS; }
CMakeLists.txt
cmake_minimum_required(VERSION 2.6) project(ClampImageFilter) find_package(ItkVtkGlue REQUIRED) include(${ItkVtkGlue_USE_FILE}) add_executable(ClampImageFilter ClampImageFilter.cxx) target_link_libraries(ClampImageFilter ItkVtkGlue ${VTK_LIBRARIES} ${ITK_LIBRARIES})
ItkVtkGlue
If you download the entire ITK Wiki Examples Collection, the ItkVtkGlue directory will be included and configured. If you wish to just build a few examples, then you will need to download ItkVtkGlue and build it. When you run cmake it will ask you to specify the location of the ItkVtkGlue binary directory.