NumCpp  2.14.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fillCorners.hpp
Go to the documentation of this file.
1
28#pragma once
29
31#include "NumCpp/Core/Shape.hpp"
32#include "NumCpp/Core/Slice.hpp"
33#include "NumCpp/Core/Types.hpp"
34#include "NumCpp/NdArray.hpp"
35
37{
38 //============================================================================
39 // Method Description:
45 template<typename dtype>
47 {
49
50 const Shape inShape = inArray.shape();
51 const auto numRows = static_cast<int32>(inShape.rows);
52 const auto numCols = static_cast<int32>(inShape.cols);
53
54 // top left
56
57 // top right
59 Slice(numCols - inBorderWidth, numCols),
60 inArray(inBorderWidth, numCols - inBorderWidth - 1));
61
62 // bottom left
63 inArray.put(Slice(numRows - inBorderWidth, numRows),
65 inArray(numRows - inBorderWidth - 1, inBorderWidth));
66
67 // bottom right
68 inArray.put(Slice(numRows - inBorderWidth, numRows),
69 Slice(numCols - inBorderWidth, numCols),
70 inArray(numRows - inBorderWidth - 1, numCols - inBorderWidth - 1));
71 }
72
73 //============================================================================
74 // Method Description:
81 template<typename dtype>
83 {
85
86 const Shape inShape = inArray.shape();
87 const auto numRows = static_cast<int32>(inShape.rows);
88 const auto numCols = static_cast<int32>(inShape.cols);
89
90 // top left
92
93 // top right
94 inArray.put(Slice(0, inBorderWidth), Slice(numCols - inBorderWidth, numCols), inFillValue);
95
96 // bottom left
97 inArray.put(Slice(numRows - inBorderWidth, numRows), Slice(0, inBorderWidth), inFillValue);
98
99 // bottom right
100 inArray.put(Slice(numRows - inBorderWidth, numRows), Slice(numCols - inBorderWidth, numCols), inFillValue);
101 }
102} // namespace nc::filter::boundary
#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:139
A Shape Class for NdArrays.
Definition Core/shape.hpp:41
A Class for slicing into NdArrays.
Definition Slice.hpp:45
Definition addBoundary1d.hpp:44
void fillCorners(NdArray< dtype > &inArray, uint32 inBorderWidth)
Definition fillCorners.hpp:46
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition arange.hpp:59
std::int32_t int32
Definition Types.hpp:36
std::uint32_t uint32
Definition Types.hpp:40