NumCpp  2.7.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
trimBoundary2d.hpp
Go to the documentation of this file.
1 #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:
50  template<typename dtype>
51  NdArray<dtype> trimBoundary2d(const NdArray<dtype>& inImageWithBoundary, uint32 inSize)
52  {
54 
55  Shape inShape = inImageWithBoundary.shape();
56  uint32 boundarySize = inSize / 2;
57 
58  inShape.rows -= boundarySize * 2;
59  inShape.cols -= boundarySize * 2;
60 
61  return inImageWithBoundary(Slice(boundarySize, boundarySize + inShape.rows), Slice(boundarySize, boundarySize + inShape.cols));
62  }
63  }
64  }
65 }
#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:4283
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:51
Definition: Coordinate.hpp:45
std::uint32_t uint32
Definition: Types.hpp:40