Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
Medical Imaging Interaction Toolkit
mitkDataCollectionVectorImageIterator.cxx
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 
15 #include "itkImageRegionConstIterator.h"
16 
17 #include "itkComposeImageFilter.h"
18 
19 template<typename TDataType, int ImageDimension>
20 inline
22  DataCollection::Pointer collection, std::vector<std::string> featureNames) :
23  m_Collection(collection)
24  {
25  for(std::vector<std::string>::iterator featureNameIterator = featureNames.begin();
26  featureNameIterator != featureNames.end();
27  ++featureNameIterator)
28  {
29  SingleImageIterator featureIterator(collection, *featureNameIterator);
30  m_FeatureIterators.push_back(featureIterator);
31  }
32  }
33 
34 template<typename TDataType, int ImageDimension>
35 inline void
37 {
38  for(typename DataCollectionSingleImageIterators::iterator it = m_FeatureIterators.begin();
39  it != m_FeatureIterators.end();
40  ++it)
41  {
42  it->ToBegin();
43  }
44 }
45 
46 template<typename TDataType, int ImageDimension>
47 inline bool
49 {
50  return m_FeatureIterators.at(0).IsAtEnd();
51 }
52 
53 template<typename TDataType, int ImageDimension>
56 {
57  for(typename DataCollectionSingleImageIterators::iterator it = m_FeatureIterators.begin();
58  it != m_FeatureIterators.end();
59  ++it)
60  {
61  ++(*it);
62  }
63  return *this;
64 }
65 
66 template<typename TDataType, int ImageDimension>
69 {
71  ++result;
72  return result;
73 }
74 
75 
76 
77 template<typename TDataType, int ImageDimension>
80 {
81  typedef typename itk::Image<TDataType, ImageDimension> ImageType;
82 
83  typename itk::ComposeImageFilter<ImageType, VectorImageType>::Pointer composeImageFilter =
84  itk::ComposeImageFilter<ImageType, VectorImageType>::New();
85 
86  // create image iterators from collection iterators
87  for (unsigned i = 0; i < m_FeatureIterators.size(); i++)
88  {
89  composeImageFilter->SetInput(i, m_FeatureIterators.at(i).GetImage());
90  }
91 
92  composeImageFilter->Update();
93 
94  composeImageFilter->GetOutput()->SetRequestedRegionToLargestPossibleRegion();
95 
96  return composeImageFilter->GetOutput();
97 }
98 
99 template<typename TDataType, int ImageDimension>
100 inline void
102  typename itk::Image<TDataType, ImageDimension>::Pointer image, std::string name)
103  {
104  m_FeatureIterators.at(m_FeatureIterators.size()-1).AddImage(image, name);
105  }
itk::Image< unsigned char, 3 > ImageType
void AddImage(typename itk::Image< TDataType, ImageDimension >::Pointer image, std::string name)
mitk::Image::Pointer image
DataCollectionVectorImageIterator(DataCollection::Pointer collection, std::vector< std::string > featureNames)