NumCpp  2.14.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
windowExceedances.hpp
Go to the documentation of this file.
1
28
29#pragma once
30
31#include <cmath>
32
33#include "NumCpp/Core/Shape.hpp"
34#include "NumCpp/Core/Types.hpp"
35#include "NumCpp/NdArray.hpp"
36
37namespace nc::imageProcessing
38{
39 //============================================================================
40 // Method Description:
48 {
49 // not the most efficient way to do things, but the easist...
51 const Shape inShape = xcds.shape();
52 for (uint8 border = 0; border < inBorderWidth; ++border)
53 {
54 for (int32 row = 0; row < static_cast<int32>(inShape.rows); ++row)
55 {
56 for (int32 col = 0; col < static_cast<int32>(inShape.cols); ++col)
57 {
58 if (inExceedances(row, col))
59 {
60 xcds(std::max(row - 1, 0), std::max(col - 1, 0)) = true;
61 xcds(std::max(row - 1, 0), col) = true;
62 xcds(std::max(row - 1, 0), std::min<int32>(col + 1, inShape.cols - 1)) = true;
63
64 xcds(row, std::max<int32>(col - 1, 0)) = true;
65 xcds(row, std::min<int32>(col + 1, inShape.cols - 1)) = true;
66
67 xcds(std::min<int32>(row + 1, inShape.rows - 1), std::max(col - 1, 0)) = true;
68 xcds(std::min<int32>(row + 1, inShape.rows - 1), col) = true;
69 xcds(std::min<int32>(row + 1, inShape.rows - 1), std::min<int32>(col + 1, inShape.cols - 1)) =
70 true;
71 }
72 }
73 }
74 }
75
76 return xcds;
77 }
78} // namespace nc::imageProcessing
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:139
A Shape Class for NdArrays.
Definition Core/shape.hpp:41
Definition applyThreshold.hpp:34
NdArray< bool > windowExceedances(const NdArray< bool > &inExceedances, uint8 inBorderWidth) noexcept
Definition windowExceedances.hpp:47
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition arange.hpp:59
std::int32_t int32
Definition Types.hpp:36
std::uint8_t uint8
Definition Types.hpp:42