|
|
(7 intermediate revisions by 3 users not shown) |
Line 1: |
Line 1: |
| Update: first error was taken care of by adding ::Pointer to the argument list of the explicit instantiations.
| | {{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 releases. In many cases, the examples on this page no longer conform to the best practices for modern ITK versions. |
| | }} |
|
| |
|
| 14: error: no matching function for call to ‘WriteFile(itk::SmartPointer<itk::Image<itk::CovariantVector<double, 4u>, 2u> >&, std::string)’
| | [https://itk.org/ITKExamples[ITK Sphinx Examples]] |
| | |
| ==CreateImages.cxx==
| |
| <source lang="cpp">
| |
| #include "itkImage.h"
| |
| #include "itkImageFileWriter.h"
| |
| #include <itkCovariantVector.h>
| |
| | |
| #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>
| |