NumCpp  1.0
A C++ implementation of the Python Numpy library
mirror1d.hpp
Go to the documentation of this file.
1 #pragma once
30 
31 #include "NumCpp/NdArray.hpp"
32 #include "NumCpp/Core/Slice.hpp"
33 #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> mirror1d(const NdArray<dtype>& inImage, uint32 inBoundarySize)
54  {
56 
57  const uint32 outSize = inImage.size() + inBoundarySize * 2;
58 
59  NdArray<dtype> outArray(1, outSize);
60  outArray.put(Slice(inBoundarySize, inBoundarySize + inImage.size()), inImage);
61 
62  // left
63  outArray.put(Slice(0, inBoundarySize), fliplr(inImage[Slice(1, inBoundarySize + 1)]));
64 
65  // right
66  outArray.put(Slice(inImage.size() + inBoundarySize, outSize),
67  fliplr(inImage[Slice(-static_cast<int32>(inBoundarySize) - 1, -1)]));
68 
69  return outArray;
70  }
71  }
72  }
73 }
StaticAsserts.hpp
nc::int32
std::int32_t int32
Definition: Types.hpp:37
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:38
fliplr.hpp
nc::NdArray< dtype >
nc::uint32
std::uint32_t uint32
Definition: Types.hpp:41
NdArray.hpp
nc::NdArray::put
NdArray< dtype > & put(int32 inIndex, value_type inValue)
Definition: NdArrayCore.hpp:3667
nc::NdArray::size
size_type size() const noexcept
Definition: NdArrayCore.hpp:4310
nc
Definition: Coordinate.hpp:45
Types.hpp
nc::filter::boundary::mirror1d
NdArray< dtype > mirror1d(const NdArray< dtype > &inImage, uint32 inBoundarySize)
Definition: mirror1d.hpp:53
nc::Slice
A Class for slicing into NdArrays.
Definition: Slice.hpp:44
Slice.hpp
nc::fliplr
NdArray< dtype > fliplr(const NdArray< dtype > &inArray)
Definition: fliplr.hpp:49