37 uint8_t constant_border_value)
46 const int sq_mask_size = mask_size * mask_size;
47 const int half_mask_size = mask_size / 2;
48 std::vector<intermediate_type> vals(sq_mask_size);
49 intermediate_type current_value = 0;
54 for(uint32_t element_idx = 0, count = 0, index = 0; element_idx < num_elements; ++element_idx, count = 0, index = 0)
61 for(
int y = idy - half_mask_size; y <= idy + half_mask_size; ++y)
63 for(
int x = idx - half_mask_size; x <= idx + half_mask_size; ++x, ++index)
67 current_value =
tensor_elem_at(src,
id, border_mode, constant_border_value);
69 if(mask[index] == 255)
71 vals[count] =
static_cast<intermediate_type
>(current_value);
76 std::sort(vals.begin(), vals.begin() + count);
101 BorderMode border_mode, uint8_t constant_border_value);
BorderMode
Methods available to handle borders.
T tensor_elem_at(const SimpleTensor< T > &src, Coordinates coord, BorderMode border_mode, T constant_border_value)
Container for 2D border size.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
DataType data_type() const override
Data type of the tensor.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
TensorShape shape() const override
Shape of the tensor.
const ValidRegion valid_region
SimpleTensor< float > src
Copyright (c) 2017-2021 Arm Limited.
T x() const
Alias to access the size of the first dimension.
bool is_in_valid_region(const ValidRegion &valid_region, Coordinates coord)
Check if a coordinate is within a valid region.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
SimpleTensor< T > non_linear_filter(const SimpleTensor< T > &src, NonLinearFilterFunction function, unsigned int mask_size, MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, uint8_t constant_border_value)
Coordinates index2coord(const TensorShape &shape, int index)
Convert a linear index into n-dimensional coordinates.
Simple tensor object that stores elements in a consecutive chunk of memory.
Borders are left undefined.
T saturate_cast(T val)
Saturate a value of type T against the numeric limits of type U.
int num_elements() const override
Number of elements of the tensor.
Container for valid region of a window.
MatrixPattern
Available matrix patterns.
Any other matrix pattern.
NonLinearFilterFunction
Available non linear functions.
ValidRegion shape_to_valid_region(const TensorShape &a_shape, bool border_undefined=false, BorderSize border_size=BorderSize(0))
Create a valid region based on tensor shape, border mode and border size.
Non linear median filter.