 |
AliceVision
Photogrammetric Computer Vision Framework
|
10 #include "aliceVision/numeric/numeric.hpp"
20 class Rgb :
public Eigen::Matrix<T, 3, 1, 0, 3, 1>
22 using Base = Eigen::Matrix<T, 3, 1, 0, 3, 1>;
34 inline Rgb(T red, T green, T blue)
35 : Base(red, green, blue)
42 explicit inline Rgb(
const Base& val)
51 explicit inline Rgb(
const T val = 0)
63 inline const T&
r()
const {
return (*
this)(0); }
69 inline T&
r() {
return (*
this)(0); }
75 inline const T&
g()
const {
return (*
this)(1); }
81 inline T&
g() {
return (*
this)(1); }
87 inline const T&
b()
const {
return (*
this)(2); }
93 inline T&
b() {
return (*
this)(2); }
99 inline operator T()
const {
return T(0.299 *
r() + 0.587 *
g() + 0.114 *
b()); }
113 for (
int i = 0; i < 2; ++i)
117 os << col(2) <<
"} ";
127 inline Rgb operator-(
const Rgb& other)
const {
return Rgb(((*
this)(0) - other(0)), ((*
this)(1) - other(1)), ((*
this)(2) - other(2))); }
135 inline Rgb operator+(
const Rgb& other)
const {
return Rgb(((*
this)(0) + other(0)), ((*
this)(1) + other(1)), ((*
this)(2) + other(2))); }
143 inline Rgb operator*(
const Rgb& other)
const {
return Rgb(((*
this)(0) * other(0)), ((*
this)(1) * other(1)), ((*
this)(2) * other(2))); }
154 return Rgb(T((Z)((*
this)(0)) / val), T((Z)((*
this)(1)) / val), T((Z)((*
this)(2)) / val));
166 return Rgb(T((Z)(*
this)(0) * val), T((Z)(*
this)(1) * val), T((Z)(*
this)(2) * val));
179 class Rgba :
public Eigen::Matrix<T, 4, 1, 0, 4, 1>
181 using Base = Eigen::Matrix<T, 4, 1, 0, 4, 1>;
193 inline Rgba(
const T red,
const T green,
const T blue,
const T alpha = T(1))
194 : Base(red, green, blue, alpha)
201 explicit inline Rgba(
const Base& val)
210 explicit inline Rgba(
const T val)
211 : Base(val, val, val, T(1))
221 : Base(T(0), T(0), T(0), T(0))
229 : Base(val.
r(), val.
g(), val.
b(), alpha)
241 inline const T&
r()
const {
return (*
this)(0); }
246 inline T&
r() {
return (*
this)(0); }
251 inline const T&
g()
const {
return (*
this)(1); }
256 inline T&
g() {
return (*
this)(1); }
261 inline const T&
b()
const {
return (*
this)(2); }
266 inline T&
b() {
return (*
this)(2); }
271 inline const T&
a()
const {
return (*
this)(3); }
276 inline T&
a() {
return (*
this)(3); }
282 inline operator T()
const {
return T(0.299 *
r() + 0.587 *
g() + 0.114 *
b()); }
294 for (
int i = 0; i < 3; ++i)
298 os << col(3) <<
"} ";
311 return Rgba(T((Z)(*
this)(0) / val), T((Z)(*
this)(1) / val), T((Z)(*
this)(2) / val), T((Z)(*
this)(3) / val));
323 return Rgba(T((Z)(*
this)(0) * val), T((Z)(*
this)(1) * val), T((Z)(*
this)(2) * val), T((Z)(*
this)(3) * val));
334 return Rgba(((*
this)(0) + other(0)), ((*
this)(1) + other(1)), ((*
this)(2) + other(2)), ((*
this)(3) + other(3)));
346 const RGBColor WHITE(255, 255, 255);
353 const RGBColor MAGENTA(255, 0, 255);
355 const RGBfColor FWHITE(1.0f, 1.0f, 1.0f);
368 static const int size = 1;
373 static const int size = 1;
378 static const int size = 3;
383 static const int size = 3;
388 static const int size = 4;
393 static const int size = 4;
Rgba operator*(const Z &val) const
scalar multiplication
Definition: pixelTypes.hpp:321
const T & b() const
Get readonly Blue channel value.
Definition: pixelTypes.hpp:87
const T & g() const
Get readonly Green channel value.
Definition: pixelTypes.hpp:75
Rgba operator/(const Z &val) const
scalar division
Definition: pixelTypes.hpp:309
Rgb operator*(const Z &val) const
scalar multiplication
Definition: pixelTypes.hpp:164
const T & a() const
Get readonly Alpha channel value.
Definition: pixelTypes.hpp:271
RGBA templated pixel type.
Definition: pixelTypes.hpp:179
Rgb(const T val=0)
Single value construction.
Definition: pixelTypes.hpp:51
T & g()
Get rw Green channel value.
Definition: pixelTypes.hpp:256
friend std::ostream & operator<<(std::ostream &os, const Rgb &col)
stream operator
Definition: pixelTypes.hpp:110
Definition: checkerDetector.cpp:32
const T & g() const
Get readonly Green channel value.
Definition: pixelTypes.hpp:251
Rgb(T red, T green, T blue)
Full constructor.
Definition: pixelTypes.hpp:34
T & g()
Get rw Green channel value.
Definition: pixelTypes.hpp:81
T & r()
Get rw Red channel value.
Definition: pixelTypes.hpp:69
const T & r() const
Get readonly Red channel value.
Definition: pixelTypes.hpp:241
Rgb operator*(const Rgb &other) const
Elementwise multiplication.
Definition: pixelTypes.hpp:143
Rgb(const Base &val)
Copy constructor.
Definition: pixelTypes.hpp:42
Rgba(const T val)
RGBA constructor with default alpha value to 1.
Definition: pixelTypes.hpp:210
Definition: pixelTypes.hpp:359
Rgb operator+(const Rgb &other) const
Elementwise addition.
Definition: pixelTypes.hpp:135
Rgba(const T red, const T green, const T blue, const T alpha=T(1))
Full constructor.
Definition: pixelTypes.hpp:193
Rgb operator/(const Z &val) const
scalar division
Definition: pixelTypes.hpp:152
friend std::ostream & operator<<(std::ostream &os, const Rgba &col)
stream operator
Definition: pixelTypes.hpp:291
T & a()
Get rw Alpha channel value.
Definition: pixelTypes.hpp:276
T & r()
Get rw Red channel value.
Definition: pixelTypes.hpp:246
T & b()
Get rw Blue channel value.
Definition: pixelTypes.hpp:93
Rgba()
Default RGBA constructor set all channels to zero (including the alpha channel)
Definition: pixelTypes.hpp:220
const T & r() const
Get readonly Red channel value.
Definition: pixelTypes.hpp:63
Definition: pixelTypes.hpp:20
Rgba(const RGBColor &val, const T alpha)
Copy constructor.
Definition: pixelTypes.hpp:228
Rgba operator+(const Rgba &other) const
Elementwise addition.
Definition: pixelTypes.hpp:332
T & b()
Get rw Blue channel value.
Definition: pixelTypes.hpp:266
const T & b() const
Get readonly Blue channel value.
Definition: pixelTypes.hpp:261
Rgba(const Base &val)
Copy constructor from internal data.
Definition: pixelTypes.hpp:201
Rgb operator-(const Rgb &other) const
Elementwise substraction.
Definition: pixelTypes.hpp:127