ITK  4.3.0
Insight Segmentation and Registration Toolkit
itkBSplineControlPointImageFilter.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 __itkBSplineControlPointImageFilter_h
19 #define __itkBSplineControlPointImageFilter_h
20 
21 #include "itkImageToImageFilter.h"
24 #include "itkFixedArray.h"
25 #include "itkPointSet.h"
26 #include "itkVariableSizeMatrix.h"
27 #include "itkVector.h"
28 #include "itkVectorContainer.h"
29 
30 #include "vnl/vnl_matrix.h"
31 #include "vnl/vnl_vector.h"
32 
33 namespace itk
34 {
35 
59 template <class TInputImage, class TOutputImage = TInputImage>
61  : public ImageToImageFilter<TInputImage, TOutputImage>
62 {
63 public:
68 
70  itkNewMacro(Self);
71 
73  itkStaticConstMacro( ImageDimension, unsigned int,
74  TInputImage::ImageDimension );
75 
76  typedef TInputImage ControlPointLatticeType;
77  typedef TOutputImage OutputImageType;
78 
80  typedef typename OutputImageType::PixelType PixelType;
81  typedef typename OutputImageType::RegionType RegionType;
82  typedef typename OutputImageType::IndexType IndexType;
83  typedef typename OutputImageType::PointType PointType;
84  typedef typename OutputImageType::RegionType OutputImageRegionType;
85 
86  typedef typename OutputImageType::SpacingType SpacingType;
87  typedef typename OutputImageType::PointType OriginType;
88  typedef typename OutputImageType::SizeType SizeType;
89  typedef typename OutputImageType::DirectionType DirectionType;
90 
92  typedef float RealType;
93  typedef Image<RealType,
94  itkGetStaticConstMacro( ImageDimension )> RealImageType;
96 
97  typedef FixedArray<unsigned,
98  itkGetStaticConstMacro( ImageDimension )> ArrayType;
99 
101  typedef PointSet<PixelType,
102  itkGetStaticConstMacro( ImageDimension )> PointSetType;
105  typedef Image<PointDataType,
106  itkGetStaticConstMacro( ImageDimension )> PointDataImageType;
109 
116 
121  void SetSplineOrder( unsigned int );
122 
127  void SetSplineOrder( ArrayType );
128 
132  itkGetConstReferenceMacro( SplineOrder, ArrayType );
133 
150  itkSetMacro( CloseDimension, ArrayType );
151 
155  itkGetConstReferenceMacro( CloseDimension, ArrayType );
156 
160  itkSetMacro( Spacing, SpacingType );
161 
165  itkGetConstMacro( Spacing, SpacingType );
166 
170  itkSetMacro( Origin, OriginType );
171 
175  itkGetConstMacro( Origin, OriginType );
176 
180  itkSetMacro( Size, SizeType );
181 
185  itkGetConstMacro( Size, SizeType );
186 
201  itkSetMacro( Direction, DirectionType );
202 
206  itkGetConstMacro( Direction, DirectionType );
207 
215  typename ControlPointLatticeType::Pointer
217 
218 protected:
221  void PrintSelf( std::ostream& os, Indent indent ) const;
222 
227 
228 private:
229  BSplineControlPointImageFilter( const Self& ); //purposely not implemented
230  void operator=( const Self& ); //purposely not implemented
231 
232 
238 
243  unsigned int SplitRequestedRegion( unsigned int, unsigned int, OutputImageRegionType & );
244 
250  const RealType, const unsigned int );
251 
256 
262 
266  unsigned int m_CurrentLevel;
271 
273 
279 
281 
282  inline typename RealImageType::IndexType
283  NumberToIndex( unsigned int number, typename RealImageType::SizeType size )
284  {
285  typename RealImageType::IndexType k;
286  k[0] = 1;
287 
288  for ( unsigned int i = 1; i < ImageDimension; i++ )
289  {
290  k[i] = size[ImageDimension-i-1]*k[i-1];
291  }
292  typename RealImageType::IndexType index;
293  for ( unsigned int i = 0; i < ImageDimension; i++ )
294  {
295  index[ImageDimension-i-1]
296  = static_cast<unsigned int>( number/k[ImageDimension-i-1] );
297  number %= k[ImageDimension-i-1];
298  }
299  return index;
300  }
301 
302 };
303 
304 } // end namespace itk
305 
306 #ifndef ITK_MANUAL_INSTANTIATION
307 #include "itkBSplineControlPointImageFilter.hxx"
308 #endif
309 
310 #endif
311