NumCpp  2.1.0
A C++ implementation of the Python Numpy library
addBoundary1d.hpp
Go to the documentation of this file.
1 #pragma once
30 
33 #include "NumCpp/Core/Types.hpp"
40 #include "NumCpp/NdArray.hpp"
41 
42 #include <string>
43 
44 namespace nc
45 {
46  namespace filter
47  {
48  namespace boundary
49  {
50  //============================================================================
51  // Method Description:
61  template<typename dtype>
62  NdArray<dtype> addBoundary1d(const NdArray<dtype>& inImage, Boundary inBoundaryType, uint32 inKernalSize, dtype inConstantValue = 0)
63  {
65 
66  if (inKernalSize % 2 == 0)
67  {
68  THROW_INVALID_ARGUMENT_ERROR("input kernal size must be an odd value.");
69  }
70 
71  const uint32 boundarySize = inKernalSize / 2; // integer division
72 
73  switch (inBoundaryType)
74  {
75  case Boundary::REFLECT:
76  {
77  return reflect1d(inImage, boundarySize);
78  }
79  case Boundary::CONSTANT:
80  {
81  return constant1d(inImage, boundarySize, inConstantValue);
82  }
83  case Boundary::NEAREST:
84  {
85  return nearest1d(inImage, boundarySize);
86  }
87  case Boundary::MIRROR:
88  {
89  return mirror1d(inImage, boundarySize);
90  }
91  case Boundary::WRAP:
92  {
93  return wrap1d(inImage, boundarySize);
94  }
95  default:
96  {
97  // This can't actually happen but just adding to get rid of compiler warning
99  }
100  }
101 
102  return NdArray<dtype>(); // get rid of compiler warning
103  }
104  } // namespace boundary
105  } // namespace filter
106 } // namespace nc
StaticAsserts.hpp
nc::filter::boundary::wrap1d
NdArray< dtype > wrap1d(const NdArray< dtype > &inImage, uint32 inBoundarySize)
Definition: wrap1d.hpp:52
Error.hpp
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:38
nc::filter::Boundary::NEAREST
@ NEAREST
nc::filter::Boundary::WRAP
@ WRAP
nc::filter::boundary::addBoundary1d
NdArray< dtype > addBoundary1d(const NdArray< dtype > &inImage, Boundary inBoundaryType, uint32 inKernalSize, dtype inConstantValue=0)
Definition: addBoundary1d.hpp:62
nc::filter::boundary::reflect1d
NdArray< dtype > reflect1d(const NdArray< dtype > &inImage, uint32 inBoundarySize)
Definition: reflect1d.hpp:53
mirror1d.hpp
nc::NdArray< dtype >
nc::uint32
std::uint32_t uint32
Definition: Types.hpp:41
nearest1d.hpp
NdArray.hpp
nc::filter::boundary::nearest1d
NdArray< dtype > nearest1d(const NdArray< dtype > &inImage, uint32 inBoundarySize)
Definition: nearest1d.hpp:51
Boundary.hpp
wrap1d.hpp
nc::filter::Boundary::CONSTANT
@ CONSTANT
nc::filter::Boundary::REFLECT
@ REFLECT
nc
Definition: Coordinate.hpp:45
nc::filter::boundary::constant1d
NdArray< dtype > constant1d(const NdArray< dtype > &inImage, uint32 inBoundarySize, dtype inConstantValue)
Definition: constant1d.hpp:53
reflect1d.hpp
constant1d.hpp
THROW_INVALID_ARGUMENT_ERROR
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:37
nc::filter::Boundary
Boundary
Boundary condition to apply to the image filter.
Definition: Boundary.hpp:38
Types.hpp
nc::filter::boundary::mirror1d
NdArray< dtype > mirror1d(const NdArray< dtype > &inImage, uint32 inBoundarySize)
Definition: mirror1d.hpp:53
nc::filter::Boundary::MIRROR
@ MIRROR