SimpleITK  1.0.1
sitkImageFilter.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 #ifndef sitkImageFilter_h
19 #define sitkImageFilter_h
20 
21 #include "sitkMacro.h"
23 #include "sitkBasicFilters.h"
24 #include "sitkProcessObject.h"
25 
26 namespace itk {
27 
28  namespace simple {
29 
36  template < unsigned int N>
38  public ProcessObject
39  {
40  public:
41  typedef ImageFilter Self;
42 
43  //
44  // Type List Setup
45  //
46 
47  //
48  // Filter Setup
49  //
50 
55  ImageFilter();
56 
60  virtual ~ImageFilter() = 0;
61 
62  protected:
63 
64  // Simple ITK must use a zero based index
65  template< class TImageType>
66  static void FixNonZeroIndex( TImageType * img )
67  {
68  assert( img != NULL );
69 
70  typename TImageType::RegionType r = img->GetLargestPossibleRegion();
71  typename TImageType::IndexType idx = r.GetIndex();
72 
73  for( unsigned int i = 0; i < TImageType::ImageDimension; ++i )
74  {
75 
76  if ( idx[i] != 0 )
77  {
78  // if any of the indcies are non-zero, then just fix it
79  typename TImageType::PointType o;
80  img->TransformIndexToPhysicalPoint( idx, o );
81  img->SetOrigin( o );
82 
83  idx.Fill( 0 );
84  r.SetIndex( idx );
85 
86  // Need to set the buffered region to match largest
87  img->SetRegions( r );
88 
89  return;
90  }
91  }
92 
93  }
94 
95  };
96 
97 
98  }
99 }
100 #endif
static void FixNonZeroIndex(TImageType *img)
#define SITKBasicFilters0_EXPORT
Base class for SimpleITK classes based on ProcessObject.
The base interface for SimpleITK filters that take one input image.