NumCpp
2.4.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
"
34
#include "
NumCpp/Core/Internal/StaticAsserts.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
{
54
STATIC_ASSERT_ARITHMETIC
(dtype);
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
}
StaticAsserts.hpp
nc::NdArray::shape
Shape shape() const noexcept
Definition:
NdArrayCore.hpp:4356
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition:
StaticAsserts.hpp:37
nc::NdArray< dtype >
nc::uint32
std::uint32_t uint32
Definition:
Types.hpp:40
NdArray.hpp
nc::Shape
A Shape Class for NdArrays.
Definition:
Core/Shape.hpp:40
nc::Shape::cols
uint32 cols
Definition:
Core/Shape.hpp:45
nc::filter::boundary::trimBoundary2d
NdArray< dtype > trimBoundary2d(const NdArray< dtype > &inImageWithBoundary, uint32 inSize)
Definition:
trimBoundary2d.hpp:52
Shape.hpp
nc
Definition:
Coordinate.hpp:44
nc::Shape::rows
uint32 rows
Definition:
Core/Shape.hpp:44
Types.hpp
nc::Slice
A Class for slicing into NdArrays.
Definition:
Slice.hpp:43
Slice.hpp
include
NumCpp
Filter
Boundaries
Boundaries2d
trimBoundary2d.hpp
Generated by
1.8.17