Path: blob/master/3rdparty/openexr/IlmImf/ImfChromaticities.h
16337 views
///////////////////////////////////////////////////////////////////////////1//2// Copyright (c) 2003, Industrial Light & Magic, a division of Lucas3// Digital Ltd. LLC4//5// All rights reserved.6//7// Redistribution and use in source and binary forms, with or without8// modification, are permitted provided that the following conditions are9// met:10// * Redistributions of source code must retain the above copyright11// notice, this list of conditions and the following disclaimer.12// * Redistributions in binary form must reproduce the above13// copyright notice, this list of conditions and the following disclaimer14// in the documentation and/or other materials provided with the15// distribution.16// * Neither the name of Industrial Light & Magic nor the names of17// its contributors may be used to endorse or promote products derived18// from this software without specific prior written permission.19//20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS21// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT22// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR23// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT24// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,25// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT26// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,27// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY28// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT29// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE30// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.31//32///////////////////////////////////////////////////////////////////////////333435#ifndef INCLUDED_IMF_CHROMATICITIES_H36#define INCLUDED_IMF_CHROMATICITIES_H3738//-----------------------------------------------------------------------------39//40// CIE (x,y) chromaticities, and conversions between41// RGB tiples and CIE XYZ tristimulus values.42//43//-----------------------------------------------------------------------------4445#include "ImathVec.h"46#include "ImathMatrix.h"4748namespace Imf {495051struct Chromaticities52{53//-----------------------------------------------54// The CIE x and y coordinates of the RGB triples55// (1,0,0), (0,1,0), (0,0,1) and (1,1,1).56//-----------------------------------------------5758Imath::V2f red;59Imath::V2f green;60Imath::V2f blue;61Imath::V2f white;6263//--------------------------------------------64// Default constructor produces chromaticities65// according to Rec. ITU-R BT.709-366//--------------------------------------------6768Chromaticities (const Imath::V2f &red = Imath::V2f (0.6400f, 0.3300f),69const Imath::V2f &green = Imath::V2f (0.3000f, 0.6000f),70const Imath::V2f &blue = Imath::V2f (0.1500f, 0.0600f),71const Imath::V2f &white = Imath::V2f (0.3127f, 0.3290f));72};737475//76// Conversions between RGB and CIE XYZ77//78// RGB to XYZ:79//80// Given a set of chromaticities, c, and the luminance, Y, of the RGB81// triple (1,1,1), or "white", RGBtoXYZ(c,Y) computes a matrix, M, so82// that multiplying an RGB value, v, with M produces an equivalent83// XYZ value, w. (w == v * M)84//85// If we define that86//87// (Xr, Yr, Zr) == (1, 0, 0) * M88// (Xg, Yg, Zg) == (0, 1, 0) * M89// (Xb, Yb, Zb) == (0, 0, 1) * M90// (Xw, Yw, Zw) == (1, 1, 1) * M,91//92// then the following statements are true:93//94// Xr / (Xr + Yr + Zr) == c.red.x95// Yr / (Xr + Yr + Zr) == c.red.y96//97// Xg / (Xg + Yg + Zg) == c.red.x98// Yg / (Xg + Yg + Zg) == c.red.y99//100// Xb / (Xb + Yb + Zb) == c.red.x101// Yb / (Xb + Yb + Zb) == c.red.y102//103// Xw / (Xw + Yw + Zw) == c.red.x104// Yw / (Xw + Yw + Zw) == c.red.y105//106// Yw == Y.107//108// XYZ to RGB:109//110// YYZtoRGB(c,Y) returns RGBtoXYZ(c,Y).inverse().111//112113Imath::M44f RGBtoXYZ (const Chromaticities chroma, float Y);114Imath::M44f XYZtoRGB (const Chromaticities chroma, float Y);115116117} // namespace Imf118119#endif120121122