#include "HxVec3Double.h"
Go to the source code of this file.
Functions | |
L_HXBASIS HxVec3Double | HxColRGB2CMY (const HxVec3Double &v) |
Conversion from RGB to CMY. More... | |
L_HXBASIS HxVec3Double | HxColCMY2RGB (const HxVec3Double &v) |
Conversion from CMY to RGB. More... | |
L_HXBASIS HxVec3Double | HxColRGB2XYZ (const HxVec3Double &v) |
Conversion from RGB(Rec709) to XYZ (1931). More... | |
L_HXBASIS HxVec3Double | HxColXYZ2RGB (const HxVec3Double &v) |
Conversion from XYZ (1931) to RGB(Rec709). More... | |
L_HXBASIS HxVec3Double | HxColCMY2XYZ (const HxVec3Double &v) |
Conversion from CMY through RGB(Rec709) to XYZ (1931). More... | |
L_HXBASIS HxVec3Double | HxColXYZ2CMY (const HxVec3Double &v) |
Conversion from XYZ (1931) through RGB(Rec709) to CMY. More... | |
L_HXBASIS HxVec3Double | HxColLab2XYZ (const HxVec3Double &v) |
Conversion from Lab to XYZ (1931), D65 reference white point. More... | |
L_HXBASIS HxVec3Double | HxColXYZ2Lab (const HxVec3Double &v) |
Conversion from XYZ (1931) to Lab, D65 reference white point. More... | |
L_HXBASIS HxVec3Double | HxColLuv2XYZ (const HxVec3Double &v) |
Conversion from Luv to XYZ (1931), D65 reference white point. More... | |
L_HXBASIS HxVec3Double | HxColXYZ2Luv (const HxVec3Double &v) |
Conversion from XYZ (1931) to Luv, D65 reference white point. More... | |
L_HXBASIS HxVec3Double | HxColRGB2OOO (const HxVec3Double &v) |
Conversion from RGB(Rec709) to OOO (Geusebroek Thesis). More... | |
L_HXBASIS HxVec3Double | HxColOOO2RGB (const HxVec3Double &v) |
Conversion from OOO (Geusebroek Thesis) to RGB(Rec709). More... | |
L_HXBASIS HxVec3Double | HxColXYZ2OOO (const HxVec3Double &v) |
Conversion from XYZ(1931) to OOO (Geusebroek Thesis). More... | |
L_HXBASIS HxVec3Double | HxColOOO2XYZ (const HxVec3Double &v) |
Conversion from OOO (Geusebroek Thesis) to XYZ(1931). More... | |
L_HXBASIS HxVec3Double | HxColRGB2HSI (const HxVec3Double &v) |
Conversion from RGB to HSI. More... | |
L_HXBASIS HxVec3Double | HxColHSI2RGB (const HxVec3Double &v) |
Conversion from HSI to RGB. More... | |
L_HXBASIS int | HxColRGB2int (const HxVec3Double &v) |
Convert RGB HxVec3Double to an ARGB integer representation. More... | |
L_HXBASIS int | HxColRGB2int (const HxVec3Int &v) |
Convert RGB HxVec3Int to an ARGB integer representation. More... |
|
Conversion from RGB to CMY.
00020 { 00021 return HxVec3Double(1, 1, 1) - v; 00022 } |
|
Conversion from CMY to RGB.
00026 { 00027 return HxVec3Double(1, 1, 1) - v; 00028 } |
|
Conversion from RGB(Rec709) to XYZ (1931).
00034 { 00035 // Using Rec709 00036 // X = 100 * (0.412452 R/255 + 0.357580 G/255 + 0.180423 B/255) 00037 // Y = 100 * (0.212671 R/255 + 0.715160 G/255 + 0.072169 B/255) 00038 // Z = 100 * (0.019334 R/255 + 0.119193 G/255 + 0.950227 B/255) 00039 00040 double X = v.x() * 0.161746 + v.y() * 0.140227 + v.z() * 0.070754; 00041 double Y = v.x() * 0.083400 + v.y() * 0.280455 + v.z() * 0.028301; 00042 double Z = v.x() * 0.007582 + v.y() * 0.046742 + v.z() * 0.372638; 00043 00044 return HxVec3Double(X, Y, Z); 00045 } |
|
Conversion from XYZ (1931) to RGB(Rec709).
00049 { 00050 // Using rec709 00051 // R = 255 * (3.240479 X/100 - 1.537150 * Y/100 - 0.498535 * Z/100) 00052 // G = 255 * (-0.969256 * X/100 + 1.875992 * Y/100 + 0.041556 * Z/100) 00053 // B = 255 * (0.055648 * Z/100 - 0.204043 * Y/100 + 1.057311 * Z/100) 00054 00055 double R = v.x() * 8.25322145 + v.y() * -3.9197325 + v.z() * -1.27126425; 00056 double G = v.x() * -2.4716028 + v.y() * 4.7837796 + v.z() * 0.1059678; 00057 double B = v.x() * 0.1419024 + v.y() * -0.52030965 + v.z() * 2.69614305; 00058 00059 return HxVec3Double(R, G, B); 00060 } |
|
Conversion from CMY through RGB(Rec709) to XYZ (1931).
00066 { 00067 // Using rec709 00068 // R = 1-C, G = 1-M, B = 1-Y 00069 00070 double X = 95.045385 00071 - v.x() * 0.161746 - v.y() * 0.140227 - v.z() * 0.070754; 00072 double Y = 100.0 00073 - v.x() * 0.083400 - v.y() * 0.280455 - v.z() * 0.028301; 00074 double Z = 108.87531 00075 - v.x() * 0.007582 - v.y() * 0.046742 - v.z() * 0.372638; 00076 00077 return HxVec3Double(X, Y, Z); 00078 } |
|
Conversion from XYZ (1931) through RGB(Rec709) to CMY.
00082 { 00083 // Using rec709 00084 // C = 1-R, M = 1-G, Y = 1-B 00085 00086 double C = 255.0 00087 - v.x() * 8.25322145 - v.y() * -3.9197325 - v.z() * -1.27126425; 00088 double M = 255.0 00089 - v.x() * -2.4716028 - v.y() * 4.7837796 - v.z() * 0.1059678; 00090 double Y = 255.0 00091 - v.x() * 0.1419024 - v.y() * -0.52030965 - v.z() * 2.69614305; 00092 00093 return HxVec3Double(C, M, Y); 00094 } |
|
Conversion from Lab to XYZ (1931), D65 reference white point.
00128 { 00129 double Y = L2Y(v.x()); 00130 00131 double Ltmp = (v.x() + 16.0) / 116.0; // == f(Y / Yn) 00132 double atmp = Ltmp + v.y() / 500.0; 00133 double X = Xn * fInv4ab(atmp, Ltmp); 00134 double btmp = Ltmp - v.z() / 200.0; 00135 double Z = Zn * fInv4ab(btmp, Ltmp); 00136 return HxVec3Double(X, Y, Z); 00137 } |
|
Conversion from XYZ (1931) to Lab, D65 reference white point.
00141 { 00142 HxVec3Double n = v / HxVec3Double(Xn, Yn, Zn); 00143 00144 double L = Y2L(n.y()); 00145 00146 double fnX = f4ab(n.x()); 00147 double fnY = f4ab(n.y()); 00148 double fnZ = f4ab(n.z()); 00149 00150 double a = 500.0 * (fnX - fnY); 00151 double b = 200.0 * (fnY - fnZ); 00152 return HxVec3Double(L, a, b); 00153 } |
|
Conversion from Luv to XYZ (1931), D65 reference white point.
00161 { 00162 double Y = L2Y(v.x()); 00163 double tmp = Xn + 15 * Yn + 3 * Zn; 00164 double unp = 4 * Xn / tmp; 00165 double vnp = 9 * Yn / tmp; 00166 double Q = v.y() / (13 * v.x()) + unp; 00167 double R = v.z() / (13 * v.x()) + vnp; 00168 double A = 3 * Y * (5 * R - 3); 00169 double Z = ((Q - 4) * A - 15 * Q * R * Y) / (12 * R); 00170 double X = -(A / R + 3 * Z); 00171 return HxVec3Double(X, Y, Z); 00172 } |
|
Conversion from XYZ (1931) to Luv, D65 reference white point.
00176 { 00177 double L = Y2L(v.y() / Yn); 00178 double tmp = Xn + 15 * Yn + 3 * Zn; 00179 double unp = 4 * Xn / tmp; 00180 double vnp = 9 * Yn / tmp; 00181 tmp = v.x() + 15 * v.y() + 3 * v.z(); 00182 double up = 4 * v.x() / tmp; 00183 double vp = 9 * v.y() / tmp; 00184 double us = 13 * L * (up - unp); 00185 double vs = 13 * L * (vp - vnp); 00186 return HxVec3Double(L, us, vs); 00187 } |
|
Conversion from RGB(Rec709) to OOO (Geusebroek Thesis).
00275 { 00276 double E = v.x() * 0.000233846 + v.y() * 0.00261968 + v.z() * 0.00127135; 00277 double El = v.x() * 0.000726333 + v.y() * 0.000718106+ v.z() * -0.00121377; 00278 double Ell = v.x() * 0.000846833 + v.y() * -0.00173932+ v.z() * 0.000221515; 00279 00280 return HxVec3Double(E, El, Ell); 00281 } |
|
Conversion from OOO (Geusebroek Thesis) to RGB(Rec709).
|
|
Conversion from XYZ(1931) to OOO (Geusebroek Thesis).
|
|
Conversion from OOO (Geusebroek Thesis) to XYZ(1931).
|
|
Conversion from RGB to HSI. No formula yet...
00200 { 00201 double I = v.sum().x() / 3.0; 00202 double S = (I == 0.0) ? 1.0 : 1.0 - (v.min().x() / I); 00203 double H; 00204 if (v.x() == v.y() && v.y() == v.z()) 00205 H = 0.0; 00206 else { 00207 double tmp = acos((0.5*(v.x()-v.y()+v.x()-v.z())) / 00208 sqrt((v.x()-v.y())*(v.x()-v.y())+(v.x()-v.z())*(v.y()-v.z()))); 00209 H = (v.y() > v.z()) ? tmp : TWO_PI - tmp; 00210 } 00211 return HxVec3Double(H, S, I); 00212 } |
|
Conversion from HSI to RGB. No formula yet...
00216 { 00217 double H = v.x(); 00218 double S = v.y(); 00219 double I = v.z(); 00220 double Htmp; 00221 double R,B,G; 00222 00223 if (H == 0.0) 00224 R = G = B = I; 00225 else if (H > 0.0 && H < TWO_PI_3 ) { 00226 Htmp = 1 / sqrt(3.0) * tan(H - PI_3); 00227 B = (1.0 - S) * I; 00228 G = (1.5 + 1.5*Htmp ) * I - ((0.5 + 1.5*Htmp) * B); 00229 R = 3.0 * I - G - B; 00230 } 00231 else if (H >= TWO_PI_3 && H < FOUR_PI_3) { 00232 Htmp = 1 / sqrt(3.0) * tan(H - PI); 00233 R = (1.0 - S) * I; 00234 B = (1.5 + 1.5*Htmp ) * I - ((0.5 + 1.5*Htmp) * R); 00235 G = 3.0 * I - B - R; 00236 } 00237 else { 00238 Htmp = 1 / sqrt(3.0) * tan(H - FIVE_PI_3); 00239 G = (1.0 - S) * I; 00240 R = (1.5 + 1.5*Htmp ) * I - ((0.5 + 1.5*Htmp) * G); 00241 B = 3.0 * I - R - G; 00242 } 00243 return HxVec3Double(R, G, B); 00244 } |
|
Convert RGB HxVec3Double to an ARGB integer representation.
|
|
Convert RGB HxVec3Int to an ARGB integer representation.
00327 { 00328 int x = v.x(); 00329 if (x < 0) 00330 x = 0; 00331 else { 00332 if (x > 255) 00333 x = 255; 00334 } 00335 int y = v.y(); 00336 if (y < 0) 00337 y = 0; 00338 else { 00339 if (y > 255) 00340 y = 255; 00341 } 00342 int z = v.z(); 00343 if (z < 0) 00344 z = 0; 00345 else { 00346 if (z > 255) 00347 z = 255; 00348 } 00349 return (255 << 24) | (x << 16) | (y << 8) | z; 00350 } |