ITK  4.8.0
Insight Segmentation and Registration Toolkit
itkExtractImageFilterRegionCopier.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 /*=========================================================================
19  *
20  * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21  *
22  * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23  *
24  * For complete copyright, license and disclaimer of warranty information
25  * please refer to the NOTICE file at the top of the ITK source tree.
26  *
27  *=========================================================================*/
28 #ifndef itkExtractImageFilterRegionCopier_h
29 #define itkExtractImageFilterRegionCopier_h
30 
32 
33 namespace itk
34 {
35 namespace ImageToImageFilterDetail
36 {
40 template< unsigned int T1, unsigned int T2 >
41 void ExtractImageFilterCopyRegion(const typename
43  ImageRegion< T1 > & destRegion,
44  const ImageRegion< T2 > & srcRegion,
45  const ImageRegion< T1 > &)
46 {
47  ImageToImageFilterDefaultCopyRegion< T1, T2 >(firstEqualsSecond, destRegion, srcRegion);
48 }
49 
53 template< unsigned int T1, unsigned int T2 >
54 void ExtractImageFilterCopyRegion(const typename
56  ImageRegion< T1 > & destRegion,
57  const ImageRegion< T2 > & srcRegion,
58  const ImageRegion< T1 > & totalInputExtractionRegion)
59 {
60  (void) totalInputExtractionRegion;
61  ImageToImageFilterDefaultCopyRegion< T1, T2 >(firstLessThanSecond, destRegion, srcRegion);
62 }
64 
81 template< unsigned int T1, unsigned int T2 >
82 void ExtractImageFilterCopyRegion(const typename
84  ImageRegion< T1 > & destRegion,
85  const ImageRegion< T2 > & srcRegion,
86  const ImageRegion< T1 > & totalInputExtractionRegion)
87 {
88  // Source dimension is less than the destination dimension, so look
89  // at the m_TotalExtractionRegion and see what values in size are 0.
90  // With these values, lock the destRegion.Index to the corresponding index
91  unsigned int dim;
92 
93  Index< T1 > destIndex;
94  Size< T1 > destSize;
95  const Index< T2 > & srcIndex = srcRegion.GetIndex();
96  const Size< T2 > & srcSize = srcRegion.GetSize();
97  int count = 0;
98  for ( dim = 0; dim < T1; ++dim )
99  {
100  //for dimensions to be removed
101  if ( !totalInputExtractionRegion.GetSize()[dim] )
102  {
103  destIndex[dim] = totalInputExtractionRegion.GetIndex()[dim];
104  destSize[dim] = 1;
105  }
106  //for all other dimension
107  else
108  {
109  destIndex[dim] = srcIndex[count];
110  destSize[dim] = srcSize[count];
111  count++;
112  }
113  }
114  destRegion.SetIndex(destIndex);
115  destRegion.SetSize(destSize);
116 }
117 
139 template< unsigned int T1, unsigned int T2 >
141  public ImageRegionCopier< T1, T2 >
142 {
143 public:
144  virtual void operator()(ImageRegion< T1 > & destRegion,
145  const ImageRegion< T2 > & srcRegion,
146  const ImageRegion< T1 > & totalInputExtractionRegion) const
147  {
148  typedef typename BinaryUnsignedIntDispatch< T1, T2 >::ComparisonType ComparisonType;
149  ExtractImageFilterCopyRegion< T1, T2 >(ComparisonType(),
150  destRegion, srcRegion, totalInputExtractionRegion);
151  }
152 
154  virtual void operator()(ImageRegion< T1 > & destRegion,
155  const ImageRegion< T2 > & srcRegion) const
156  {
157  ImageRegionCopier< T1, T2 >::operator()(destRegion, srcRegion);
158  }
159 };
160 } //end namespace ImageToImageFilterDetail
161 } //end namespace itk
163 
164 #endif
void SetSize(const SizeType &size)
virtual void operator()(ImageRegion< T1 > &destRegion, const ImageRegion< T2 > &srcRegion) const
const IndexType & GetIndex() const
A special variation of ImageRegionCopier for when the output image has fewer dimensions than the inpu...
A Function object used to dispatching to a routine to copy a region (start index and size)...
Represent the size (bounds) of a n-dimensional image.
Definition: itkSize.h:52
virtual void operator()(ImageRegion< D1 > &destRegion, const ImageRegion< D2 > &srcRegion) const
An image region represents a structured region of data.
void ExtractImageFilterCopyRegion(const typename BinaryUnsignedIntDispatch< T1, T2 >::FirstEqualsSecondType &firstEqualsSecond, ImageRegion< T1 > &destRegion, const ImageRegion< T2 > &srcRegion, const ImageRegion< T1 > &)
const SizeType & GetSize() const
virtual void operator()(ImageRegion< T1 > &destRegion, const ImageRegion< T2 > &srcRegion, const ImageRegion< T1 > &totalInputExtractionRegion) const
Templated class to produce a unique type for each integer.
Represent a n-dimensional index in a n-dimensional image.
Definition: itkIndex.h:71
void SetIndex(const IndexType &index)