NumCpp  2.1.0
A C++ implementation of the Python Numpy library
nearest1d.hpp
Go to the documentation of this file.
1 #pragma once
30 
32 #include "NumCpp/Core/Slice.hpp"
33 #include "NumCpp/NdArray.hpp"
34 
35 namespace nc
36 {
37  namespace filter
38  {
39  namespace boundary
40  {
41  //============================================================================
42  // Method Description:
50  template<typename dtype>
51  NdArray<dtype> nearest1d(const NdArray<dtype>& inImage, uint32 inBoundarySize)
52  {
54 
55  const uint32 outSize = inImage.size() + inBoundarySize * 2;
56 
57  NdArray<dtype> outArray(1, outSize);
58  outArray.put(Slice(inBoundarySize, inBoundarySize + inImage.size()), inImage);
59 
60  // left
61  outArray.put(Slice(0, inBoundarySize), inImage.front());
62 
63  // right
64  outArray.put(Slice(inImage.size() + inBoundarySize, outSize), inImage.back());
65 
66  return outArray;
67  }
68  } // namespace boundary
69  } // namespace filter
70 } // namespace nc
StaticAsserts.hpp
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:38
nc::NdArray< dtype >
nc::NdArray::front
value_type front() const noexcept
Definition: NdArrayCore.hpp:2789
nc::NdArray::back
value_type back() const noexcept
Definition: NdArrayCore.hpp:2221
nc::uint32
std::uint32_t uint32
Definition: Types.hpp:41
NdArray.hpp
nc::filter::boundary::nearest1d
NdArray< dtype > nearest1d(const NdArray< dtype > &inImage, uint32 inBoundarySize)
Definition: nearest1d.hpp:51
nc::NdArray::put
NdArray< dtype > & put(int32 inIndex, value_type inValue)
Definition: NdArrayCore.hpp:3685
nc::NdArray::size
size_type size() const noexcept
Definition: NdArrayCore.hpp:4326
nc
Definition: Coordinate.hpp:45
nc::Slice
A Class for slicing into NdArrays.
Definition: Slice.hpp:44
Slice.hpp