NumCpp  2.18.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Loading...
Searching...
No Matches
addBoundary1d.hpp
Go to the documentation of this file.
1
28#pragma once
29
32#include "NumCpp/Core/Types.hpp"
39#include "NumCpp/NdArray.hpp"
40
42{
43 //============================================================================
44 // Method Description:
53 template<typename dtype>
55 Boundary inBoundaryType,
56 uint32 inKernalSize,
57 dtype inConstantValue = 0)
58 {
60
61 if (inKernalSize % 2 == 0)
62 {
63 THROW_INVALID_ARGUMENT_ERROR("input kernal size must be an odd value.");
64 }
65
66 const uint32 boundarySize = inKernalSize / 2; // integer division
67
68 switch (inBoundaryType)
69 {
71 {
72 return reflect1d(inImage, boundarySize);
73 }
75 {
76 return constant1d(inImage, boundarySize, inConstantValue);
77 }
79 {
80 return nearest1d(inImage, boundarySize);
81 }
83 {
84 return mirror1d(inImage, boundarySize);
85 }
86 case Boundary::WRAP:
87 {
88 return wrap1d(inImage, boundarySize);
89 }
90 default:
91 {
92 // This can't actually happen but just adding to get rid of compiler warning
94 }
95 }
96
97 return NdArray<dtype>(); // get rid of compiler warning
98 }
99} // namespace nc::filter::boundary
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition Error.hpp:37
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition StaticAsserts.hpp:39
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:135
Definition addBoundary1d.hpp:42
NdArray< dtype > reflect1d(const NdArray< dtype > &inImage, uint32 inBoundarySize)
Definition reflect1d.hpp:48
NdArray< dtype > mirror1d(const NdArray< dtype > &inImage, uint32 inBoundarySize)
Definition mirror1d.hpp:47
NdArray< dtype > wrap1d(const NdArray< dtype > &inImage, uint32 inBoundarySize)
Definition wrap1d.hpp:46
NdArray< dtype > constant1d(const NdArray< dtype > &inImage, uint32 inBoundarySize, dtype inConstantValue)
Definition constant1d.hpp:47
NdArray< dtype > addBoundary1d(const NdArray< dtype > &inImage, Boundary inBoundaryType, uint32 inKernalSize, dtype inConstantValue=0)
Definition addBoundary1d.hpp:54
NdArray< dtype > nearest1d(const NdArray< dtype > &inImage, uint32 inBoundarySize)
Definition nearest1d.hpp:45
Boundary
Boundary condition to apply to the image filter.
Definition Boundary.hpp:36
@ MIRROR
Definition Boundary.hpp:40
@ CONSTANT
Definition Boundary.hpp:38
@ NEAREST
Definition Boundary.hpp:39
@ WRAP
Definition Boundary.hpp:41
@ REFLECT
Definition Boundary.hpp:37
std::uint32_t uint32
Definition Types.hpp:40