00001 /*
00002 File: ColourSystem.h
00003
00004 Function: Provides a class to help with colour space conversions to
00005 and from three-primary display devices.
00006
00007 Author: Andrew Willmott
00008
00009 Copyright: (c) 1999-2000, Andrew Willmott
00010 */
00011
00012 #ifndef __ColourSystem__
00013 #define __ColourSystem__
00014
00015 #include "Colour.h"
00016 #include "Geometry.h"
00017 #include "VecUtil.h"
00018
00019 typedef Vec2f Chroma;
00020
00021 class ColourSystem
00022 {
00023 public:
00024 ColourSystem(
00025 Chroma primary1,
00026 Chroma primary2,
00027 Chroma primary3,
00028 Chroma whitePoint,
00029 ClrReal whiteLum = 1.0
00030 );
00031
00032 // transforming to and from CIE XYZ colour space.
00033
00034 Colour GamutToXYZ(const Colour &csClr)
00036 { return(toXYZ * csClr); };
00037 Bool XYZIsOutOfGamut(const Colour &cieXYZ);
00041 Colour XYZToGamut(const Colour &cieXYZ);
00044 Colour XYZToGamutClip(const Colour &cieXYZ);
00046
00047 Bool ChromaIsOutOfGamut(const Chroma &cieChroma);
00050 Colour ChromaToGamut(const Chroma &cieChroma);
00055 ClrReal Luminance(const Colour &csClr)
00057 { return(dot(toXYZ[1], csClr)); };
00058
00059
00060 // colour conversion matrices
00061 ClrMat toXYZ;
00062 ClrMat fromXYZ;
00063
00064 // chromaticities of the three primaries & the chroma/luminance of the
00065 // white point
00066 Chroma prim0;
00067 Chroma prim1;
00068 Chroma prim2;
00069 Chroma white;
00070 ClrReal whiteLum;;
00071 };
00072
00073 // current colour system for display output. defaults to csEBU, but
00074 // might be necessary to set it to something more appropriate.
00075
00076 extern ColourSystem &csDisplay;
00077
00078 // chromaticities of standard illuminants
00079 extern const Chroma csIllumA; // Incandescent light
00080 extern const Chroma csIllumB; // Solar light
00081 extern const Chroma csIllumC; // For NTSC television
00082 extern const Chroma csIllumD55; // Photography
00083 extern const Chroma csIllumD65; // Overcast Daylight
00084 extern const Chroma csIllumD75;
00085 extern const Chroma csIllumE; // Uniform illuminant
00086
00087 // luminances of standard illuminants, in candela/watt
00088
00089 extern const ClrReal csMaxLum;
00090 extern const ClrReal csWhiteLum;
00091 extern const ClrReal csD65Lum;
00092 extern const ClrReal csALum;
00093 extern const ClrReal csBLum;
00094
00095
00096 // Colour systems!
00097 extern ColourSystem csNTSC;
00098 extern ColourSystem csPAL_SECAM;
00099 extern ColourSystem csEBU; // same as CCIR709
00100 extern ColourSystem csSMPTE;
00101 extern ColourSystem csShortPersistencePhosphors;
00102 extern ColourSystem csLongPersistencePhosphors;
00103 extern ColourSystem csDellPhosphors;
00104
00105 #endif