SimpleITK  
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::simple
26 {
27 
28 #define sitkKernelPolygonCreateMacro(n) \
29  case sitkPolygon##n: return ITKKernelType::Polygon( radius, n )
30 
31 template< unsigned int VImageDimension >
33 CreateKernel( KernelEnum kernelType, const std::vector<uint32_t> &size )
34 {
35  using ITKKernelType = typename itk::FlatStructuringElement< VImageDimension >;
36 
37  typename ITKKernelType::SizeType radius = sitkSTLVectorToITK<typename ITKKernelType::SizeType>( size );
38 
39  switch (kernelType)
40  {
41  case sitkAnnulus:
42  return ITKKernelType::Annulus( radius, 1, false );
43  case sitkBall:
44  return ITKKernelType::Ball( radius );
45  case sitkBox:
46  return ITKKernelType::Box( radius );
47  case sitkCross:
48  return ITKKernelType::Cross( radius );
56  default:
57  sitkExceptionMacro( "Logic Error: Unknown Kernel Type" );
58  }
59 
60 #undef sitkKernelPolygonCreateMacro
61 
62 
63 }
64 
65 
66 }
67 
68 
69 #endif // sitkCreateKernel_h
itk::simple::sitkBox
@ sitkBox
Box shaped structuring element.
Definition: sitkKernel.h:36
itk::FlatStructuringElement
sitkKernelPolygonCreateMacro
#define sitkKernelPolygonCreateMacro(n)
Definition: sitkCreateKernel.h:28
itk::simple::sitkBall
@ sitkBall
Ball (sphere in 3D, circle in 2D) shaped structuring element.
Definition: sitkKernel.h:33
itk::simple::sitkAnnulus
@ sitkAnnulus
Annulus, ring, shaped structuring element.
Definition: sitkKernel.h:30
itk::simple::KernelEnum
KernelEnum
Definition: sitkKernel.h:27
itk::simple::sitkCross
@ sitkCross
Cross shaped structuring element.
Definition: sitkKernel.h:39
itkFlatStructuringElement.h
sitkKernel.h
itk::simple::CreateKernel
itk::FlatStructuringElement< VImageDimension > CreateKernel(KernelEnum kernelType, const std::vector< uint32_t > &size)
Definition: sitkCreateKernel.h:33
itk::simple
Definition: sitkAdditionalProcedures.h:28
sitkExceptionMacro
#define sitkExceptionMacro(x)
Definition: sitkMacro.h:69