ITK/Examples/IO/ReadUnknownImageType: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
Update: first error was taken care of by adding ::Pointer to the argument list of the explicit instantiations.
14: error: no matching function for call to ‘WriteFile(itk::SmartPointer<itk::Image<itk::CovariantVector<double, 4u>, 2u> >&, std::string)’
14: error: no matching function for call to ‘WriteFile(itk::SmartPointer<itk::Image<itk::CovariantVector<double, 4u>, 2u> >&, std::string)’



Revision as of 15:29, 1 December 2010

Update: first error was taken care of by adding ::Pointer to the argument list of the explicit instantiations.

14: error: no matching function for call to ‘WriteFile(itk::SmartPointer<itk::Image<itk::CovariantVector<double, 4u>, 2u> >&, std::string)’

CreateImages.cxx

<source lang="cpp">

  1. include "itkImage.h"
  2. include "itkImageFileWriter.h"
  3. include <itkCovariantVector.h>
  1. include <string>

template<typename TImageType> void WriteFile(typename TImageType::Pointer image, std::string filename);

int main(int, char *[]) {

 typedef itk::Image< itk::CovariantVector<double, 4> , 2>  ImageType4;
 ImageType4::Pointer image4 = ImageType4::New();
 WriteFile(image4, std::string("image4.mhd"));
 typedef itk::Image< itk::CovariantVector<double, 5> , 2>  ImageType5;
 ImageType5::Pointer image5 = ImageType5::New();
 WriteFile(image5, std::string("image5.mhd"));
 return EXIT_SUCCESS;

}

template<typename TImageType> void WriteFile(typename TImageType::Pointer image, std::string filename) {

 // Create image
 typename TImageType::IndexType start;
 start[0] = 0;
 start[1] = 0;
 typename TImageType::SizeType size;
 size[0] = 20;
 size[1] = 30;
 typename TImageType::RegionType region;
 region.SetSize(size);
 region.SetIndex(start);
 image->SetRegions(region);
 image->Allocate();
 /*
 typedef itk::ImageFileReader<TImageType> ReaderType;
 typename ReaderType::Pointer reader = ReaderType::New();
 reader->SetInput(image);
 reader->SetFileName(filename);
 reader->Update();
 */

}

template void WriteFile<itk::Image< itk::CovariantVector<double, 4> , 2> >(itk::Image< itk::CovariantVector<double, 4> , 2>::Pointer, std::string); template void WriteFile<itk::Image< itk::CovariantVector<double, 5> , 2> >(itk::Image< itk::CovariantVector<double, 5> , 2>::Pointer, std::string); </source>

CMakeLists.txt

<source lang="cmake"> cmake_minimum_required(VERSION 2.6)

PROJECT(CreateImages)

FIND_PACKAGE(ITK REQUIRED) INCLUDE(${ITK_USE_FILE})

ADD_EXECUTABLE(CreateImages CreateImages.cxx) TARGET_LINK_LIBRARIES(CreateImages ITKIO ITKBasicFilters ITKCommon ) </source>