NumCpp  2.1.0
A C++ implementation of the Python Numpy library
trimBoundary2d.hpp
Go to the documentation of this file.
1 #pragma once
30 
31 #include "NumCpp/NdArray.hpp"
32 #include "NumCpp/Core/Shape.hpp"
33 #include "NumCpp/Core/Slice.hpp"
34 #include "NumCpp/Core/Types.hpp"
36 
37 namespace nc
38 {
39  namespace filter
40  {
41  namespace boundary
42  {
43  //============================================================================
44  // Method Description:
52  template<typename dtype>
53  NdArray<dtype> trimBoundary2d(const NdArray<dtype>& inImageWithBoundary, uint32 inSize)
54  {
56 
57  Shape inShape = inImageWithBoundary.shape();
58  uint32 boundarySize = inSize / 2;
59 
60  inShape.rows -= boundarySize * 2;
61  inShape.cols -= boundarySize * 2;
62 
63  return inImageWithBoundary(Slice(boundarySize, boundarySize + inShape.rows), Slice(boundarySize, boundarySize + inShape.cols));
64  }
65  }
66  }
67 }
StaticAsserts.hpp
nc::NdArray::shape
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4312
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:38
nc::NdArray< dtype >
nc::uint32
std::uint32_t uint32
Definition: Types.hpp:41
NdArray.hpp
nc::Shape
A Shape Class for NdArrays.
Definition: Core/Shape.hpp:41
nc::Shape::cols
uint32 cols
Definition: Core/Shape.hpp:46
nc::filter::boundary::trimBoundary2d
NdArray< dtype > trimBoundary2d(const NdArray< dtype > &inImageWithBoundary, uint32 inSize)
Definition: trimBoundary2d.hpp:53
Shape.hpp
nc
Definition: Coordinate.hpp:45
nc::Shape::rows
uint32 rows
Definition: Core/Shape.hpp:45
Types.hpp
nc::Slice
A Class for slicing into NdArrays.
Definition: Slice.hpp:44
Slice.hpp