ITK/Examples/IO/ReadUnknownImageType: Difference between revisions
Daviddoria (talk | contribs) (Created page with " /media/portable/Examples/c++/src/ITK/IO/ReadUnknownImageType/CreateImages.cxx:14: error: no matching function for call to ‘WriteFile(itk::SmartPointer<itk::Image<itk::Covarian...") |
Daviddoria (talk | contribs) mNo edit summary |
||
Line 1: | Line 1: | ||
14: error: no matching function for call to ‘WriteFile(itk::SmartPointer<itk::Image<itk::CovariantVector<double, 4u>, 2u> >&, std::string)’ | |||
50: error: template-id ‘WriteFile<itk::Image<itk::CovariantVector<double, 4u>, 2u> >’ for ‘void WriteFile(itk::Image<itk::CovariantVector<double, 4u>, 2u>, std::string)’ does not match any template declaration | |||
==CreateImages.cxx== | ==CreateImages.cxx== |
Revision as of 14:55, 1 December 2010
14: error: no matching function for call to ‘WriteFile(itk::SmartPointer<itk::Image<itk::CovariantVector<double, 4u>, 2u> >&, std::string)’
50: error: template-id ‘WriteFile<itk::Image<itk::CovariantVector<double, 4u>, 2u> >’ for ‘void WriteFile(itk::Image<itk::CovariantVector<double, 4u>, 2u>, std::string)’ does not match any template declaration
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>, std::string); template void WriteFile<itk::Image< itk::CovariantVector<double, 5> , 2> >(itk::Image< itk::CovariantVector<double, 5> , 2>, 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>