NumCpp  2.4.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
addBoundary2d.hpp
Go to the documentation of this file.
1 #pragma once
29 
32 #include "NumCpp/Core/Types.hpp"
39 #include "NumCpp/NdArray.hpp"
40 
41 #include <string>
42 
43 namespace nc
44 {
45  namespace filter
46  {
47  namespace boundary
48  {
49  //============================================================================
50  // Method Description:
60  template<typename dtype>
61  NdArray<dtype> addBoundary2d(const NdArray<dtype>& inImage, Boundary inBoundaryType, uint32 inKernalSize, dtype inConstantValue = 0)
62  {
64 
65  if (inKernalSize % 2 == 0)
66  {
67  THROW_INVALID_ARGUMENT_ERROR("input kernal size must be an odd value.");
68  }
69 
70  const uint32 boundarySize = inKernalSize / 2; // integer division
71 
72  switch (inBoundaryType)
73  {
74  case Boundary::REFLECT:
75  {
76  return reflect2d(inImage, boundarySize);
77  }
78  case Boundary::CONSTANT:
79  {
80  return constant2d(inImage, boundarySize, inConstantValue);
81  }
82  case Boundary::NEAREST:
83  {
84  return nearest2d(inImage, boundarySize);
85  }
86  case Boundary::MIRROR:
87  {
88  return mirror2d(inImage, boundarySize);
89  }
90  case Boundary::WRAP:
91  {
92  return wrap2d(inImage, boundarySize);
93  }
94  default:
95  {
96  THROW_INVALID_ARGUMENT_ERROR("Unimplemented axis type.");
97  return {}; // get rid of compiler warning
98  }
99  }
100  }
101  } // namespace boundary
102  } // namespace filter
103 } // namespace nc
StaticAsserts.hpp
wrap2d.hpp
nc::filter::boundary::wrap2d
NdArray< dtype > wrap2d(const NdArray< dtype > &inImage, uint32 inBoundarySize)
Definition: wrap2d.hpp:53
Error.hpp
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
nc::filter::Boundary::NEAREST
@ NEAREST
nc::filter::Boundary::WRAP
@ WRAP
nc::NdArray< dtype >
nc::filter::boundary::constant2d
NdArray< dtype > constant2d(const NdArray< dtype > &inImage, uint32 inBoundarySize, dtype inConstantValue)
Definition: constant2d.hpp:54
reflect2d.hpp
nc::uint32
std::uint32_t uint32
Definition: Types.hpp:40
NdArray.hpp
Boundary.hpp
constant2d.hpp
nc::filter::boundary::addBoundary2d
NdArray< dtype > addBoundary2d(const NdArray< dtype > &inImage, Boundary inBoundaryType, uint32 inKernalSize, dtype inConstantValue=0)
Definition: addBoundary2d.hpp:61
nc::filter::Boundary::CONSTANT
@ CONSTANT
mirror2d.hpp
nc::filter::Boundary::REFLECT
@ REFLECT
nc
Definition: Coordinate.hpp:44
THROW_INVALID_ARGUMENT_ERROR
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
nc::filter::Boundary
Boundary
Boundary condition to apply to the image filter.
Definition: Boundary.hpp:37
nc::filter::boundary::mirror2d
NdArray< dtype > mirror2d(const NdArray< dtype > &inImage, uint32 inBoundarySize)
Definition: mirror2d.hpp:53
nc::filter::boundary::nearest2d
NdArray< dtype > nearest2d(const NdArray< dtype > &inImage, uint32 inBoundarySize)
Definition: nearest2d.hpp:53
Types.hpp
nc::filter::Boundary::MIRROR
@ MIRROR
nc::filter::boundary::reflect2d
NdArray< dtype > reflect2d(const NdArray< dtype > &inImage, uint32 inBoundarySize)
Definition: reflect2d.hpp:54
nearest2d.hpp