VisionCpp  0.0.1
OP_GaussianBlur3x3.hpp
Go to the documentation of this file.
1 // This file is part of VisionCpp, a lightweight C++ template library
2 // for computer vision and image processing.
3 //
4 // Copyright (C) 2016 Codeplay Software Limited. All Rights Reserved.
5 //
6 // Contact: visioncpp@codeplay.com
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 //
12 // http://www.apache.org/licenses/LICENSE-2.0
13 //
14 // Unless required by applicable law or agreed to in writing, software
15 // distributed under the License is distributed on an "AS IS" BASIS,
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 // See the License for the specific language governing permissions and
18 // limitations under the License.
19 
20 /// \file OP_GaussianBlur3x3.hpp
21 /// \brief this file apply the Gaussian blur 3x3
22 
23 namespace visioncpp {
24 /// \struct OP_GaussianBlur3x3
25 /// \brief applying the Gaussian blur 3x3
27  /// \param nbr
28  /// \return PIXEL
29  template <typename NeighbourT>
30  typename NeighbourT::PixelType operator()(NeighbourT &nbr) {
31  auto out = nbr.at(nbr.I_c - 1, nbr.I_r - 1) * 1.0f / 16.0f;
32  out += nbr.at(nbr.I_c - 1, nbr.I_r + 1) * 1.0f / 16.0f;
33  out += nbr.at(nbr.I_c + 1, nbr.I_r - 1) * 1.0f / 16.0f;
34  out += nbr.at(nbr.I_c + 1, nbr.I_r + 1) * 1.0f / 16.0f;
35  out += nbr.at(nbr.I_c, nbr.I_r - 1) * 2.0f / 16.0f;
36  out += nbr.at(nbr.I_c - 1, nbr.I_r) * 2.0f / 16.0f;
37  out += nbr.at(nbr.I_c, nbr.I_r + 1) * 2.0f / 16.0f;
38  out += nbr.at(nbr.I_c + 1, nbr.I_r) * 2.0f / 16.0f;
39  out += nbr.at(nbr.I_c, nbr.I_r) * 4.0f / 16.0f;
40  return out;
41  }
42 };
43 }
VisionCpp namespace.
Definition: sycl/device.hpp:24
applying the Gaussian blur 3x3
NeighbourT::PixelType operator()(NeighbourT &nbr)