NumCpp  2.6.2
A Templatized Header Only C++ Implementation of the Python NumPy Library
trimBoundary2d.hpp
Go to the documentation of this file.
1 
28 #pragma once
29 
30 #include "NumCpp/NdArray.hpp"
31 #include "NumCpp/Core/Shape.hpp"
32 #include "NumCpp/Core/Slice.hpp"
33 #include "NumCpp/Core/Types.hpp"
35 
36 namespace nc
37 {
38  namespace filter
39  {
40  namespace boundary
41  {
42  //============================================================================
43  // Method Description:
51  template<typename dtype>
52  NdArray<dtype> trimBoundary2d(const NdArray<dtype>& inImageWithBoundary, uint32 inSize)
53  {
55 
56  Shape inShape = inImageWithBoundary.shape();
57  uint32 boundarySize = inSize / 2;
58 
59  inShape.rows -= boundarySize * 2;
60  inShape.cols -= boundarySize * 2;
61 
62  return inImageWithBoundary(Slice(boundarySize, boundarySize + inShape.rows), Slice(boundarySize, boundarySize + inShape.cols));
63  }
64  }
65  }
66 }
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:72
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4483
A Shape Class for NdArrays.
Definition: Core/Shape.hpp:41
uint32 rows
Definition: Core/Shape.hpp:44
uint32 cols
Definition: Core/Shape.hpp:45
A Class for slicing into NdArrays.
Definition: Slice.hpp:44
NdArray< dtype > trimBoundary2d(const NdArray< dtype > &inImageWithBoundary, uint32 inSize)
Definition: trimBoundary2d.hpp:52
Definition: Coordinate.hpp:45
std::uint32_t uint32
Definition: Types.hpp:40