fork(1) download
  1. #include "itkCovariantVector.h"
  2. #include "itkImage.h"
  3. #include "itkImageRegionIterator.h"
  4. #include "itkNthElementImageAdaptor.h"
  5. #include "itkVectorImage.h"
  6. #include "itkVectorImageToImageAdaptor.h"
  7.  
  8. static void VectorImage();
  9. static void ImageCovariantVector();
  10. static void VectorImageDoesNotWork();
  11. static void ImageCovariantVectorDoesNotWork();
  12.  
  13. int main(int, char* [] )
  14. {
  15.  
  16. return 0;
  17. }
  18.  
  19. void ImageCovariantVector()
  20. {
  21. typedef itk::Image<itk::CovariantVector<unsigned char, 3>, 2> VectorImageType;
  22. VectorImageType::Pointer image = VectorImageType::New();
  23. itk::Index<2> corner = {{0,0}};
  24. itk::Size<2> size = {{500,500}};
  25. itk::ImageRegion<2> fullRegion(corner, size);
  26. image->SetRegions(fullRegion);
  27. image->Allocate();
  28.  
  29. typedef itk::Image<unsigned char, 2> ScalarImageType;
  30.  
  31. typedef itk::NthElementImageAdaptor<VectorImageType, ScalarImageType::PixelType> ImageAdaptorType;
  32. typename ImageAdaptorType::Pointer adaptor = ImageAdaptorType::New();
  33. adaptor->SelectNthElement(0);
  34. adaptor->SetImage(image.GetPointer());
  35.  
  36. itk::ImageRegionIterator<ImageAdaptorType> imageIterator(adaptor, adaptor->GetLargestPossibleRegion());
  37.  
  38. while(!imageIterator.IsAtEnd())
  39. {
  40.  
  41. ++imageIterator;
  42. }
  43. }
  44.  
  45. void VectorImage()
  46. {
  47. typedef itk::VectorImage<unsigned char, 2> VectorImageType;
  48. VectorImageType::Pointer image = VectorImageType::New();
  49. itk::Index<2> corner = {{0,0}};
  50. itk::Size<2> size = {{500,500}};
  51. itk::ImageRegion<2> fullRegion(corner, size);
  52. image->SetRegions(fullRegion);
  53. image->SetNumberOfComponentsPerPixel(3);
  54. image->Allocate();
  55.  
  56. typedef itk::Image<unsigned char, 2> ScalarImageType;
  57.  
  58. typedef itk::VectorImageToImageAdaptor<ScalarImageType::PixelType, 2> ImageAdaptorType;
  59. typename ImageAdaptorType::Pointer adaptor = ImageAdaptorType::New();
  60. adaptor->SetExtractComponentIndex(0);
  61. adaptor->SetImage(image.GetPointer());
  62.  
  63. itk::ImageRegionIterator<ImageAdaptorType> imageIterator(adaptor, adaptor->GetLargestPossibleRegion());
  64.  
  65. while(!imageIterator.IsAtEnd())
  66. {
  67.  
  68. ++imageIterator;
  69. }
  70.  
  71. }
  72.  
  73.  
  74. void VectorImageDoesNotWork()
  75. {
  76. // typedef itk::VectorImage<unsigned char, 2> VectorImageType;
  77. // VectorImageType::Pointer image = VectorImageType::New();
  78. // itk::Index<2> corner = {{0,0}};
  79. // itk::Size<2> size = {{500,500}};
  80. // itk::ImageRegion<2> fullRegion(corner, size);
  81. // image->SetRegions(fullRegion);
  82. // image->SetNumberOfComponentsPerPixel(3);
  83. // image->Allocate();
  84. //
  85. // typedef itk::Image<unsigned char, 2> ScalarImageType;
  86. //
  87. // typedef itk::NthElementImageAdaptor<VectorImageType, ScalarImageType::PixelType> ImageAdaptorType;
  88. // typename ImageAdaptorType::Pointer adaptor = ImageAdaptorType::New();
  89. // adaptor->SelectNthElement(0);
  90. // adaptor->SetImage(image.GetPointer());
  91. //
  92. // itk::ImageRegionIterator<ImageAdaptorType> imageIterator(adaptor, adaptor->GetLargestPossibleRegion());
  93. //
  94. // while(!imageIterator.IsAtEnd())
  95. // {
  96. //
  97. // ++imageIterator;
  98. // }
  99.  
  100. }
  101.  
  102.  
  103. void ImageCovariantVectorDoesNotWork()
  104. {
  105. // typedef itk::Image<itk::CovariantVector<unsigned char, 3>, 2> VectorImageType;
  106. // VectorImageType::Pointer image = VectorImageType::New();
  107. // itk::Index<2> corner = {{0,0}};
  108. // itk::Size<2> size = {{500,500}};
  109. // itk::ImageRegion<2> fullRegion(corner, size);
  110. // image->SetRegions(fullRegion);
  111. // image->Allocate();
  112. //
  113. // typedef itk::Image<unsigned char, 2> ScalarImageType;
  114. //
  115. // typedef itk::VectorImageToImageAdaptor<ScalarImageType::PixelType, 2> ImageAdaptorType;
  116. // typename ImageAdaptorType::Pointer adaptor = ImageAdaptorType::New();
  117. // adaptor->SetExtractComponentIndex(0);
  118. // adaptor->SetImage(image.GetPointer());
  119. //
  120. // itk::ImageRegionIterator<ImageAdaptorType> imageIterator(adaptor, adaptor->GetLargestPossibleRegion());
  121. //
  122. // while(!imageIterator.IsAtEnd())
  123. // {
  124. //
  125. // ++imageIterator;
  126. // }
  127.  
  128. }
  129.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty