SimpleITK  2.0.0
sitkCreateKernel.h
Go to the documentation of this file.
1 /*=========================================================================
2 *
3 * Copyright NumFOCUS
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  using ITKKernelType = typename itk::FlatStructuringElement< VImageDimension >;
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::simple::sitkBox
@ sitkBox
Definition: sitkKernel.h:32
itk::FlatStructuringElement
sitkKernelPolygonCreateMacro
#define sitkKernelPolygonCreateMacro(n)
Definition: sitkCreateKernel.h:31
itk::simple::sitkBall
@ sitkBall
Definition: sitkKernel.h:31
itk::simple::sitkAnnulus
@ sitkAnnulus
Definition: sitkKernel.h:30
itk::simple::KernelEnum
KernelEnum
Definition: sitkKernel.h:29
itk::simple::sitkCross
@ sitkCross
Definition: sitkKernel.h:33
itkFlatStructuringElement.h
itk
sitkKernel.h
itk::simple::CreateKernel
itk::FlatStructuringElement< VImageDimension > CreateKernel(KernelEnum kernelType, const std::vector< uint32_t > &size)
Definition: sitkCreateKernel.h:36
sitkExceptionMacro
#define sitkExceptionMacro(x)
Definition: sitkMacro.h:71