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