SimpleITK  1.0.1
sitkCreateKernel.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 sitkCreateKernel_h
19 #define sitkCreateKernel_h
20 
21 
22 #include "sitkKernel.h"
24 
25 namespace itk
26 {
27 
28 namespace simple
29 {
30 
31 #define sitkKernelPolygonCreateMacro(n) \
32  case sitkPolygon##n: return ITKKernelType::Polygon( radius, n )
33 
34 template< unsigned int VImageDimension >
36 CreateKernel( KernelEnum kernelType, const std::vector<uint32_t> &size )
37 {
38  typedef typename itk::FlatStructuringElement< VImageDimension > ITKKernelType;
39 
40  typename ITKKernelType::SizeType radius = sitkSTLVectorToITK<typename ITKKernelType::SizeType>( size );
41 
42  switch (kernelType)
43  {
44  case sitkAnnulus:
45  return ITKKernelType::Annulus( radius, 1, false );
46  case sitkBall:
47  return ITKKernelType::Ball( radius );
48  case sitkBox:
49  return ITKKernelType::Box( radius );
50  case sitkCross:
51  return ITKKernelType::Cross( radius );
59  default:
60  sitkExceptionMacro( "Logic Error: Unknown Kernel Type" );
61  }
62 
63 #undef sitkKernelPolygonCreateMacro
64 
65 
66 }
67 
68 
69 } // end namespace simple
70 } // end namespace itk
71 
72 
73 #endif // sitkCreateKernel_h
itk::FlatStructuringElement< VImageDimension > CreateKernel(KernelEnum kernelType, const std::vector< uint32_t > &size)
#define sitkKernelPolygonCreateMacro(n)
#define sitkExceptionMacro(x)
Definition: sitkMacro.h:89