Difference between revisions of "ITK/Examples/ImageProcessing/TileImageFilter CreateVolume"

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
(Deprecated content that is moved to sphinx)
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
==TileImageFilter.cxx==
{{warning|1=The media wiki content on this page is no longer maintained. The examples presented on the https://itk.org/Wiki/pages likely require ITK version 4.13 or earlier releasesIn many cases, the examples on this page no longer conform to the best practices for modern ITK versions.
<source lang="cpp">
}}
#include "itkTileImageFilter.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkImage.h"
 
int main(int argc, char *argv[] )
{
 
  typedef unsigned char PixelType;
  const unsigned int InputImageDimension = 2;
  const unsigned int OutputImageDimension = 3;
 
  typedef itk::Image< PixelType, InputImageDimension  >  InputImageType;
  typedef itk::Image< PixelType, OutputImageDimension >  OutputImageType;
 
  typedef itk::ImageFileReader< InputImageType > ImageReaderType ;
 
  typedef itk::TileImageFilter< InputImageType, OutputImageType > TilerType;
 
  typedef itk::ImageFileWriter< OutputImageType > WriterType;
 
  if (argc < 4)
    {
    std::cerr << "Usage: " << std::endl;
    std::cerr << argv[0] << "input1 input2 ... inputn output" << std::endl;
    return EXIT_FAILURE;
    }
 
   TilerType::Pointer tiler = TilerType::New();
 
  itk::FixedArray< unsigned int, OutputImageDimension > layout;
 
  layout[0] = 1;
  layout[1] = 1;
  layout[2] = 0;
 
  tiler->SetLayout( layout );
 
  unsigned int inputImageNumber = 0;
 
  ImageReaderType::Pointer reader = ImageReaderType::New();
 
  InputImageType::Pointer inputImageTile;
 
  for (int i = 1; i < argc - 1; i++)
    {
    reader->SetFileName( argv[i] );
    reader->UpdateLargestPossibleRegion();
    inputImageTile = reader->GetOutput();
    inputImageTile->DisconnectPipeline();
    tiler->SetInput( inputImageNumber++, inputImageTile );
    }
 
  PixelType filler = 128;
 
  tiler->SetDefaultPixelValue( filler );
 
  tiler->Update();
 
  WriterType::Pointer writer = WriterType::New();
 
  writer->SetInput( tiler->GetOutput() );
 
  writer->SetFileName( argv[argc-1] );
 
  try
    {
    writer->Update();
    }
  catch( itk::ExceptionObject & excp )
    {
    std::cerr << excp << std::endl;
    return EXIT_FAILURE;
    }
 
  return EXIT_SUCCESS;
}
</source>
 
==CMakeLists.txt==
<source lang="cmake">
cmake_minimum_required(VERSION 2.8)
if(COMMAND CMAKE_POLICY)
  cmake_policy(SET CMP0003 NEW)
endif(COMMAND CMAKE_POLICY)
 
project(TileImageFilter)
 
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})
 
add_executable(TileImageFilter TileImageFilter.cxx )
 
target_link_libraries(TileImageFilter ${ITK_LIBRARIES})
</source>

Latest revision as of 20:19, 5 June 2019

Warning: The media wiki content on this page is no longer maintained. The examples presented on the https://itk.org/Wiki/* pages likely require ITK version 4.13 or earlier releases. In many cases, the examples on this page no longer conform to the best practices for modern ITK versions.