diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-04-22 13:58:16 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-04-22 13:58:16 +0100 |
| commit | 86bfdeb77f55b379302a65b22f57fc0583ec6b3c (patch) | |
| tree | 66ed8eb0e4855c520b1b1a0d9dae052a0ad5bfe6 /src/colour_conversion.h | |
| parent | 3c88524c9a2418d6d2d8b8eac29737c95b9a7411 (diff) | |
Express colour conversions as chromaticities and adjust so that
everything is specified as something_to_xyz and then you can get
an inverse LUT if you want one.
Diffstat (limited to 'src/colour_conversion.h')
| -rw-r--r-- | src/colour_conversion.h | 84 |
1 files changed, 75 insertions, 9 deletions
diff --git a/src/colour_conversion.h b/src/colour_conversion.h index cf19d447..e1ee1b11 100644 --- a/src/colour_conversion.h +++ b/src/colour_conversion.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,23 +17,35 @@ */ +#include "chromaticity.h" #include <boost/shared_ptr.hpp> #include <boost/numeric/ublas/matrix.hpp> +#include <boost/optional.hpp> namespace dcp { class TransferFunction; +enum YUVToRGB { + YUV_TO_RGB_REC601, + YUV_TO_RGB_REC709, + YUV_TO_RGB_COUNT +}; + class ColourConversion { public: ColourConversion () - : _matrix (3, 3) {} ColourConversion ( boost::shared_ptr<const TransferFunction> in, - double const matrix[3][3], + YUVToRGB yuv_to_rgb, + Chromaticity red, + Chromaticity green, + Chromaticity blue, + Chromaticity white, + boost::optional<Chromaticity> adjusted_white, boost::shared_ptr<const TransferFunction> out ); @@ -41,10 +53,30 @@ public: return _in; } - boost::numeric::ublas::matrix<double> matrix () const { - return _matrix; + YUVToRGB yuv_to_rgb () const { + return _yuv_to_rgb; + } + + Chromaticity red () const { + return _red; } + Chromaticity green () const { + return _green; + } + + Chromaticity blue () const { + return _blue; + } + + Chromaticity white () const { + return _white; + } + + boost::optional<Chromaticity> adjusted_white () const { + return _adjusted_white; + } + boost::shared_ptr<const TransferFunction> out () const { return _out; } @@ -53,23 +85,57 @@ public: _in = f; } - void set_matrix (boost::numeric::ublas::matrix<double> m) { - _matrix = m; + void set_yuv_to_rgb (YUVToRGB y) { + _yuv_to_rgb = y; } + void set_red (Chromaticity red) { + _red = red; + } + + void set_green (Chromaticity green) { + _green = green; + } + + void set_blue (Chromaticity blue) { + _blue = blue; + } + + void set_white (Chromaticity white) { + _white = white; + } + + void set_adjusted_white (Chromaticity adjusted_white) { + _adjusted_white = adjusted_white; + } + + void unset_adjusted_white () { + _adjusted_white = boost::optional<Chromaticity> (); + } + void set_out (boost::shared_ptr<const TransferFunction> f) { _out = f; } bool about_equal (ColourConversion const & other, float epsilon) const; + boost::numeric::ublas::matrix<double> rgb_to_xyz () const; + boost::numeric::ublas::matrix<double> xyz_to_rgb () const; + boost::numeric::ublas::matrix<double> bradford () const; + static ColourConversion const & srgb_to_xyz (); - static ColourConversion const & xyz_to_srgb (); + static ColourConversion const & rec601_to_xyz (); static ColourConversion const & rec709_to_xyz (); protected: boost::shared_ptr<const TransferFunction> _in; - boost::numeric::ublas::matrix<double> _matrix; + YUVToRGB _yuv_to_rgb; + Chromaticity _red; + Chromaticity _green; + Chromaticity _blue; + Chromaticity _white; + /** White point that we are adjusting to using a Bradford matrix */ + boost::optional<Chromaticity> _adjusted_white; boost::shared_ptr<const TransferFunction> _out; }; |
