Orfeo Toolbox  4.0
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 }
63 
80 template< unsigned int T1, unsigned int T2 >
81 void ExtractImageFilterCopyRegion(const typename
83  ImageRegion< T1 > & destRegion,
84  const ImageRegion< T2 > & srcRegion,
85  const ImageRegion< T1 > & totalInputExtractionRegion)
86 {
87  // Source dimension is less than the destination dimension, so look
88  // at the m_TotalExtractionRegion and see what values in size are 0.
89  // With these values, lock the destRegion.Index to the corresponding index
90  unsigned int dim;
91 
92  Index< T1 > destIndex;
93  Size< T1 > destSize;
94  const Index< T2 > & srcIndex = srcRegion.GetIndex();
95  const Size< T2 > & srcSize = srcRegion.GetSize();
96  int count = 0;
97  for ( dim = 0; dim < T1; ++dim )
98  {
99  //for dimensions to be removed
100  if ( !totalInputExtractionRegion.GetSize()[dim] )
101  {
102  destIndex[dim] = totalInputExtractionRegion.GetIndex()[dim];
103  destSize[dim] = 1;
104  }
105  //for all other dimension
106  else
107  {
108  destIndex[dim] = srcIndex[count];
109  destSize[dim] = srcSize[count];
110  count++;
111  }
112  }
113  destRegion.SetIndex(destIndex);
114  destRegion.SetSize(destSize);
115 }
116 
138 template< unsigned int T1, unsigned int T2 >
140  public ImageRegionCopier< T1, T2 >
141 {
142 public:
143  virtual void operator()(ImageRegion< T1 > & destRegion,
144  const ImageRegion< T2 > & srcRegion,
145  const ImageRegion< T1 > & totalInputExtractionRegion) const
146  {
147  typedef typename BinaryUnsignedIntDispatch< T1, T2 >::ComparisonType ComparisonType;
148  ExtractImageFilterCopyRegion< T1, T2 >(ComparisonType(),
149  destRegion, srcRegion, totalInputExtractionRegion);
150  }
151 
153  virtual void operator()(ImageRegion< T1 > & destRegion,
154  const ImageRegion< T2 > & srcRegion) const
155  {
156  ImageRegionCopier< T1, T2 >::operator()(destRegion, srcRegion);
157  }
158 };
159 } //end namespace ImageToImageFilterDetail
160 } //end namespace itk
161 
162 #endif

Generated at Sat Mar 8 2014 14:35:48 for Orfeo Toolbox with doxygen 1.8.3.1