VisionCpp  0.0.1
OP_HSVToU8C3.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_HSVToU8C3.hpp
21 /// \brief it converts HSV pixel to U8C3 pixel
22 
23 namespace visioncpp {
24 /// \brief This functor allows displaying HSV.
25 /// the formula followed for unsigned char: 255S, 255V, 128H
26 struct OP_HSVToU8C3 {
27  /// \param in
28  /// \return U8C3
30  const float FLOAT_TO_BYTE = 255.0f;
31 
32  // Convert from floats to 8-bit integers
33  // let follow OpenCV convention of
34  // V <- 255V, S <- 255S, H <- H/2(to fit 0 to 255)
35  float bH = (float)(in[0] * 180.0f);
36  float bS = (float)(in[1] * FLOAT_TO_BYTE);
37  float bV = (float)(in[2] * FLOAT_TO_BYTE);
38 
39  return visioncpp::pixel::U8C3(static_cast<unsigned char>(bH),
40  static_cast<unsigned char>(bS),
41  static_cast<unsigned char>(bV));
42  }
43 };
44 }
Storage< unsigned char, 3 > U8C3
Definition: pixel.hpp:136
VisionCpp namespace.
Definition: sycl/device.hpp:24
This functor allows displaying HSV.
visioncpp::pixel::U8C3 operator()(visioncpp::pixel::F32C3 in)