NumCpp  2.12.1
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
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:
46 template<typename dtype>
47 NdArray<dtype> trimBoundary2d(const NdArray<dtype>& inImageWithBoundary, uint32 inSize)
48 {
50
51 Shape inShape = inImageWithBoundary.shape();
52 uint32 boundarySize = inSize / 2;
53
54 inShape.rows -= boundarySize * 2;
55 inShape.cols -= boundarySize * 2;
56
57 return inImageWithBoundary(Slice(boundarySize, boundarySize + inShape.rows),
58 Slice(boundarySize, boundarySize + inShape.cols));
59 }
60} // 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
const Shape & shape() const noexcept
Definition: NdArrayCore.hpp:4511
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:45
Definition: addBoundary1d.hpp:44
NdArray< dtype > trimBoundary2d(const NdArray< dtype > &inImageWithBoundary, uint32 inSize)
Definition: trimBoundary2d.hpp:47
std::uint32_t uint32
Definition: Types.hpp:40