本文整理汇总了Python中colour.colorimetry.ILLUMINANTS.get方法的典型用法代码示例。如果您正苦于以下问题:Python ILLUMINANTS.get方法的具体用法?Python ILLUMINANTS.get怎么用?Python ILLUMINANTS.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类colour.colorimetry.ILLUMINANTS
的用法示例。
在下文中一共展示了ILLUMINANTS.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RGB_to_Lab
# 需要导入模块: from colour.colorimetry import ILLUMINANTS [as 别名]
# 或者: from colour.colorimetry.ILLUMINANTS import get [as 别名]
def RGB_to_Lab(RGB, colourspace):
"""
Converts given *RGB* value from given colourspace to *CIE Lab* colourspace.
Parameters
----------
RGB : array_like
*RGB* value.
colourspace : RGB_Colourspace
*RGB* colourspace.
Returns
-------
bool
Definition success.
"""
return XYZ_to_Lab(
RGB_to_XYZ(np.array(RGB),
colourspace.whitepoint,
ILLUMINANTS.get(
'CIE 1931 2 Degree Standard Observer').get('E'),
colourspace.to_XYZ,
'Bradford',
colourspace.decoding_cctf),
colourspace.whitepoint)
示例2: XYZ_to_xy
# 需要导入模块: from colour.colorimetry import ILLUMINANTS [as 别名]
# 或者: from colour.colorimetry.ILLUMINANTS import get [as 别名]
def XYZ_to_xy(XYZ, illuminant=ILLUMINANTS.get("CIE 1931 2 Degree Standard Observer").get("D50")):
"""
Returns the *xy* chromaticity coordinates from given *CIE XYZ* tristimulus
values.
Parameters
----------
XYZ : array_like
*CIE XYZ* tristimulus values.
illuminant : array_like, optional
Reference *illuminant* chromaticity coordinates.
Returns
-------
ndarray
*xy* chromaticity coordinates.
Notes
-----
- Input *CIE XYZ* tristimulus values are in domain [0, 1].
- Output *xy* chromaticity coordinates are in domain [0, 1].
Examples
--------
>>> XYZ = np.array([0.07049534, 0.10080000, 0.09558313])
>>> XYZ_to_xy(XYZ) # doctest: +ELLIPSIS
array([ 0.2641477..., 0.3777000...])
"""
xy = xyY_to_xy(XYZ_to_xyY(XYZ, illuminant))
return xy
示例3: XYZ_to_xy
# 需要导入模块: from colour.colorimetry import ILLUMINANTS [as 别名]
# 或者: from colour.colorimetry.ILLUMINANTS import get [as 别名]
def XYZ_to_xy(XYZ,
illuminant=ILLUMINANTS.get(
'CIE 1931 2 Degree Standard Observer').get('D50')):
"""
Returns the *xy* chromaticity coordinates from given *CIE XYZ* colourspace
matrix.
Parameters
----------
XYZ : array_like, (3,)
*CIE XYZ* colourspace matrix.
illuminant : array_like, optional
Reference *illuminant* chromaticity coordinates.
Returns
-------
tuple
*xy* chromaticity coordinates.
Notes
-----
- Input *CIE XYZ* colourspace matrix is in domain [0, 1].
- Output *xy* chromaticity coordinates are in domain [0, 1].
Examples
--------
>>> XYZ_to_xy(np.array([0.97137399, 1, 1.04462134])) # doctest: +ELLIPSIS
(0.3220741..., 0.3315655...)
>>> XYZ_to_xy((0.97137399, 1, 1.04462134)) # doctest: +ELLIPSIS
(0.3220741..., 0.3315655...)
"""
xyY = np.ravel(XYZ_to_xyY(XYZ, illuminant))
return xyY[0], xyY[1]
示例4: XYZ_to_xy
# 需要导入模块: from colour.colorimetry import ILLUMINANTS [as 别名]
# 或者: from colour.colorimetry.ILLUMINANTS import get [as 别名]
def XYZ_to_xy(XYZ,
illuminant=ILLUMINANTS.get(
'CIE 1931 2 Degree Standard Observer').get('D50')):
"""
Returns the *xy* chromaticity coordinates from given *CIE XYZ* colourspace
matrix.
Parameters
----------
XYZ : array_like, (3,)
*CIE XYZ* colourspace matrix.
illuminant : array_like, optional
Reference *illuminant* chromaticity coordinates.
Returns
-------
tuple
*xy* chromaticity coordinates.
Notes
-----
- Input *CIE XYZ* colourspace matrix is in domain [0, 1].
- Output *xy* chromaticity coordinates are in domain [0, 1].
Examples
--------
>>> XYZ = np.array([0.07049534, 0.1008, 0.09558313])
>>> XYZ_to_xy(XYZ) # doctest: +ELLIPSIS
(0.2641477..., 0.3777000...)
"""
xyY = np.ravel(XYZ_to_xyY(XYZ, illuminant))
return xyY[0], xyY[1]
示例5: Luv_to_XYZ
# 需要导入模块: from colour.colorimetry import ILLUMINANTS [as 别名]
# 或者: from colour.colorimetry.ILLUMINANTS import get [as 别名]
def Luv_to_XYZ(Luv,
illuminant=ILLUMINANTS.get(
'CIE 1931 2 Degree Standard Observer').get('D50')):
"""
Converts from *CIE Luv* colourspace to *CIE XYZ* tristimulus values.
Parameters
----------
Luv : array_like
*CIE Luv* colourspace array.
illuminant : array_like, optional
Reference *illuminant* *xy* chromaticity coordinates or *CIE xyY*
colourspace array.
Returns
-------
ndarray
*CIE XYZ* tristimulus values.
Notes
-----
- Input :math:`L^*` is in domain [0, 100].
- Input *illuminant* *xy* chromaticity coordinates or *CIE xyY*
colourspace array are in domain [0, :math:`\infty`].
- Output *CIE XYZ* tristimulus values are in range [0, 1].
References
----------
.. [3] Lindbloom, B. (2003). Luv to XYZ. Retrieved February 24, 2014,
from http://brucelindbloom.com/Eqn_Luv_to_XYZ.html
Examples
--------
>>> Luv = np.array([37.9856291 , -28.80219593, -1.35800706])
>>> Luv_to_XYZ(Luv) # doctest: +ELLIPSIS
array([ 0.0704953..., 0.1008 , 0.0955831...])
"""
L, u, v = tsplit(Luv)
X_r, Y_r, Z_r = tsplit(xyY_to_XYZ(xy_to_xyY(illuminant)))
Y = np.where(L > CIE_E * CIE_K, ((L + 16) / 116) ** 3, L / CIE_K)
a = 1 / 3 * ((52 * L / (u + 13 * L *
(4 * X_r / (X_r + 15 * Y_r + 3 * Z_r)))) - 1)
b = -5 * Y
c = -1 / 3.0
d = Y * (39 * L / (v + 13 * L *
(9 * Y_r / (X_r + 15 * Y_r + 3 * Z_r))) - 5)
X = (d - b) / (a - c)
Z = X * a + b
XYZ = tstack((X, Y, Z))
return XYZ
示例6: XYZ_to_Lab
# 需要导入模块: from colour.colorimetry import ILLUMINANTS [as 别名]
# 或者: from colour.colorimetry.ILLUMINANTS import get [as 别名]
def XYZ_to_Lab(XYZ,
illuminant=ILLUMINANTS.get(
'CIE 1931 2 Degree Standard Observer').get('D50')):
"""
Converts from *CIE XYZ* tristimulus values to *CIE Lab* colourspace.
Parameters
----------
XYZ : array_like
*CIE XYZ* tristimulus values.
illuminant : array_like, optional
Reference *illuminant* *xy* chromaticity coordinates or *CIE xyY*
colourspace array.
Returns
-------
ndarray
*CIE Lab* colourspace array.
Notes
-----
- Input *CIE XYZ* tristimulus values are in domain [0, 1].
- Input *illuminant* *xy* chromaticity coordinates or *CIE xyY*
colourspace array are in domain [0, :math:`\infty`].
- Output *Lightness* :math:`L^*` is in domain [0, 100].
References
----------
.. [2] Lindbloom, B. (2003). XYZ to Lab. Retrieved February 24, 2014,
from http://www.brucelindbloom.com/Eqn_XYZ_to_Lab.html
Examples
--------
>>> XYZ = np.array([0.07049534, 0.10080000, 0.09558313])
>>> XYZ_to_Lab(XYZ) # doctest: +ELLIPSIS
array([ 37.9856291..., -23.6230288..., -4.4141703...])
"""
XYZ = np.asarray(XYZ)
XYZ_r = xyY_to_XYZ(xy_to_xyY(illuminant))
XYZ_f = XYZ / XYZ_r
XYZ_f = np.where(XYZ_f > CIE_E,
np.power(XYZ_f, 1 / 3),
(CIE_K * XYZ_f + 16) / 116)
X_f, Y_f, Z_f = tsplit(XYZ_f)
L = 116 * Y_f - 16
a = 500 * (X_f - Y_f)
b = 200 * (Y_f - Z_f)
Lab = tstack((L, a, b))
return Lab
示例7: XYZ_to_Luv
# 需要导入模块: from colour.colorimetry import ILLUMINANTS [as 别名]
# 或者: from colour.colorimetry.ILLUMINANTS import get [as 别名]
def XYZ_to_Luv(XYZ,
illuminant=ILLUMINANTS.get(
'CIE 1931 2 Degree Standard Observer').get('D50')):
"""
Converts from *CIE XYZ* tristimulus values to *CIE Luv* colourspace.
Parameters
----------
XYZ : array_like
*CIE XYZ* tristimulus values.
illuminant : array_like, optional
Reference *illuminant* *xy* chromaticity coordinates or *CIE xyY*
colourspace array.
Returns
-------
ndarray
*CIE Luv* colourspace array.
Notes
-----
- Input *CIE XYZ* tristimulus values are in domain [0, 1].
- Input *illuminant* *xy* chromaticity coordinates or *CIE xyY*
colourspace array are in domain [0, :math:`\infty`].
- Output :math:`L^*` is in range [0, 100].
References
----------
.. [2] Lindbloom, B. (2003). XYZ to Luv. Retrieved February 24, 2014,
from http://brucelindbloom.com/Eqn_XYZ_to_Luv.html
Examples
--------
>>> XYZ = np.array([0.07049534, 0.10080000, 0.09558313])
>>> XYZ_to_Luv(XYZ) # doctest: +ELLIPSIS
array([ 37.9856291..., -28.8021959..., -1.3580070...])
"""
X, Y, Z = tsplit(XYZ)
X_r, Y_r, Z_r = tsplit(xyY_to_XYZ(xy_to_xyY(illuminant)))
y_r = Y / Y_r
L = np.where(y_r > CIE_E, 116 * y_r ** (1 / 3) - 16, CIE_K * y_r)
u = (13 * L * ((4 * X / (X + 15 * Y + 3 * Z)) -
(4 * X_r / (X_r + 15 * Y_r + 3 * Z_r))))
v = (13 * L * ((9 * Y / (X + 15 * Y + 3 * Z)) -
(9 * Y_r / (X_r + 15 * Y_r + 3 * Z_r))))
Luv = tstack((L, u, v))
return Luv
示例8: XYZ_to_UVW
# 需要导入模块: from colour.colorimetry import ILLUMINANTS [as 别名]
# 或者: from colour.colorimetry.ILLUMINANTS import get [as 别名]
def XYZ_to_UVW(XYZ,
illuminant=ILLUMINANTS.get(
'CIE 1931 2 Degree Standard Observer').get('D50')):
"""
Converts from *CIE XYZ* tristimulus values to *CIE 1964 U\*V\*W\**
colourspace.
Parameters
----------
XYZ : array_like
*CIE XYZ* tristimulus values.
illuminant : array_like, optional
Reference *illuminant* *xy* chromaticity coordinates or *CIE xyY*
colourspace array.
Returns
-------
ndarray
*CIE 1964 U\*V\*W\** colourspace array.
Notes
-----
- Input *CIE XYZ* tristimulus values are in domain [0, 100].
- Input *illuminant* *xy* chromaticity coordinates or *CIE xyY*
colourspace array are in domain [0, :math:`\infty`].
- Output *CIE UVW* colourspace array is in range [0, 100].
Warning
-------
The input / output domains of that definition are non standard!
Examples
--------
>>> import numpy as np
>>> XYZ = np.array([0.07049534, 0.10080000, 0.09558313]) * 100
>>> XYZ_to_UVW(XYZ) # doctest: +ELLIPSIS
array([-28.0579733..., -0.8819449..., 37.0041149...])
"""
xyY = XYZ_to_xyY(XYZ, xyY_to_xy(illuminant))
_x, _y, Y = tsplit(xyY)
u, v = tsplit(UCS_to_uv(XYZ_to_UCS(XYZ)))
u_0, v_0 = tsplit(
UCS_to_uv(XYZ_to_UCS(xyY_to_XYZ(xy_to_xyY(illuminant)))))
W = 25 * Y ** (1 / 3) - 17
U = 13 * W * (u - u_0)
V = 13 * W * (v - v_0)
UVW = tstack((U, V, W))
return UVW
示例9: Lab_to_XYZ
# 需要导入模块: from colour.colorimetry import ILLUMINANTS [as 别名]
# 或者: from colour.colorimetry.ILLUMINANTS import get [as 别名]
def Lab_to_XYZ(Lab,
illuminant=ILLUMINANTS.get(
'CIE 1931 2 Degree Standard Observer').get('D50')):
"""
Converts from *CIE Lab* colourspace to *CIE XYZ* colourspace.
Parameters
----------
Lab : array_like, (3,)
*CIE Lab* colourspace matrix.
illuminant : array_like, optional
Reference *illuminant* chromaticity coordinates.
Returns
-------
ndarray, (3,)
*CIE XYZ* colourspace matrix.
Notes
-----
- Input *Lightness* :math:`L^*` is in domain [0, 100].
- Input *illuminant* chromaticity coordinates are in domain [0, 1].
- Output *CIE XYZ* colourspace matrix is in domain [0, 1].
References
----------
.. [3] http://www.brucelindbloom.com/Eqn_Lab_to_XYZ.html
(Last accessed 24 February 2014)
Examples
--------
>>> Lab = np.array([100, -7.41787844, -15.85742105])
>>> Lab_to_XYZ(Lab) # doctest: +ELLIPSIS
array([ 0.9219310..., 1. , 1.0374424...])
"""
L, a, b = np.ravel(Lab)
Xr, Yr, Zr = np.ravel(xy_to_XYZ(illuminant))
fy = (L + 16) / 116
fx = a / 500 + fy
fz = fy - b / 200
xr = fx ** 3 if fx ** 3 > CIE_E else (116 * fx - 16) / CIE_K
yr = ((L + 16) / 116) ** 3 if L > CIE_K * CIE_E else L / CIE_K
zr = fz ** 3 if fz ** 3 > CIE_E else (116 * fz - 16) / CIE_K
X = xr * Xr
Y = yr * Yr
Z = zr * Zr
return np.array([X, Y, Z])
示例10: Luv_to_XYZ
# 需要导入模块: from colour.colorimetry import ILLUMINANTS [as 别名]
# 或者: from colour.colorimetry.ILLUMINANTS import get [as 别名]
def Luv_to_XYZ(Luv,
illuminant=ILLUMINANTS.get(
'CIE 1931 2 Degree Standard Observer').get('D50')):
"""
Converts from *CIE Luv* colourspace to *CIE XYZ* colourspace.
Parameters
----------
Luv : array_like, (3,)
*CIE Luv* colourspace matrix.
illuminant : array_like, optional
Reference *illuminant* chromaticity coordinates.
Returns
-------
ndarray, (3,)
*CIE XYZ* colourspace matrix.
Notes
-----
- Input :math:`L^*` is in domain [0, 100].
- Input *illuminant* chromaticity coordinates are in domain [0, 1].
- Output *CIE XYZ* colourspace matrix is in domain [0, 1].
References
----------
.. [3] http://brucelindbloom.com/Eqn_Luv_to_XYZ.html
(Last accessed 24 February 2014)
Examples
--------
>>> Luv = np.array([100, -20.04304247, -19.81676035])
>>> Luv_to_XYZ(Luv) # doctest: +ELLIPSIS
array([ 0.9219310..., 1. , 1.0374424...])
"""
L, u, v = np.ravel(Luv)
Xr, Yr, Zr = np.ravel(xy_to_XYZ(illuminant))
Y = ((L + 16) / 116) ** 3 if L > CIE_E * CIE_K else L / CIE_K
a = 1 / 3 * ((52 * L / (u + 13 * L *
(4 * Xr / (Xr + 15 * Yr + 3 * Zr)))) - 1)
b = -5 * Y
c = -1 / 3.0
d = Y * (39 * L / (v + 13 * L *
(9 * Yr / (Xr + 15 * Yr + 3 * Zr))) - 5)
X = (d - b) / (a - c)
Z = X * a + b
return np.array([X, Y, Z])
示例11: Lab_to_XYZ
# 需要导入模块: from colour.colorimetry import ILLUMINANTS [as 别名]
# 或者: from colour.colorimetry.ILLUMINANTS import get [as 别名]
def Lab_to_XYZ(Lab,
illuminant=ILLUMINANTS.get(
'CIE 1931 2 Degree Standard Observer').get('D50')):
"""
Converts from *CIE Lab* colourspace to *CIE XYZ* tristimulus values.
Parameters
----------
Lab : array_like
*CIE Lab* colourspace array.
illuminant : array_like, optional
Reference *illuminant* *xy* chromaticity coordinates or *CIE xyY*
colourspace array.
Returns
-------
ndarray
*CIE XYZ* tristimulus values.
Notes
-----
- Input *Lightness* :math:`L^*` is in domain [0, 100].
- Input *illuminant* *xy* chromaticity coordinates or *CIE xyY*
colourspace array are in domain [0, :math:`\infty`].
- Output *CIE XYZ* tristimulus values are in domain [0, 1].
References
----------
.. [3] Lindbloom, B. (2008). Lab to XYZ. Retrieved February 24, 2014,
from http://www.brucelindbloom.com/Eqn_Lab_to_XYZ.html
Examples
--------
>>> Lab = np.array([37.98562910, -23.62302887, -4.41417036])
>>> Lab_to_XYZ(Lab) # doctest: +ELLIPSIS
array([ 0.0704953..., 0.1008 , 0.0955831...])
"""
L, a, b = tsplit(Lab)
XYZ_r = xyY_to_XYZ(xy_to_xyY(illuminant))
f_y = (L + 16) / 116
f_x = a / 500 + f_y
f_z = f_y - b / 200
x_r = np.where(f_x ** 3 > CIE_E, f_x ** 3, (116 * f_x - 16) / CIE_K)
y_r = np.where(L > CIE_K * CIE_E, ((L + 16) / 116) ** 3, L / CIE_K)
z_r = np.where(f_z ** 3 > CIE_E, f_z ** 3, (116 * f_z - 16) / CIE_K)
XYZ = tstack((x_r, y_r, z_r)) * XYZ_r
return XYZ
示例12: Luv_to_XYZ
# 需要导入模块: from colour.colorimetry import ILLUMINANTS [as 别名]
# 或者: from colour.colorimetry.ILLUMINANTS import get [as 别名]
def Luv_to_XYZ(Luv,
illuminant=ILLUMINANTS.get(
'CIE 1931 2 Degree Standard Observer').get('D50')):
"""
Converts from *CIE Luv* colourspace to *CIE XYZ* colourspace.
Parameters
----------
Luv : array_like, (3,)
*CIE Luv* colourspace matrix.
illuminant : array_like, optional
Reference *illuminant* chromaticity coordinates.
Returns
-------
ndarray, (3,)
*CIE XYZ* colourspace matrix.
Notes
-----
- Input :math:`L^*` is in domain [0, 100].
- Input *illuminant* chromaticity coordinates are in domain [0, 1].
- Output *CIE XYZ* colourspace matrix is in domain [0, 1].
References
----------
.. [3] Lindbloom, B. (2003). Luv to XYZ. Retrieved February 24, 2014,
from http://brucelindbloom.com/Eqn_Luv_to_XYZ.html
Examples
--------
>>> Luv = np.array([37.9856291, -28.79229446, -1.3558195])
>>> Luv_to_XYZ(Luv) # doctest: +ELLIPSIS
array([ 0.0704953..., 0.1008 , 0.0955831...])
"""
L, u, v = np.ravel(Luv)
Xr, Yr, Zr = np.ravel(xy_to_XYZ(illuminant))
Y = ((L + 16) / 116) ** 3 if L > CIE_E * CIE_K else L / CIE_K
a = 1 / 3 * ((52 * L / (u + 13 * L *
(4 * Xr / (Xr + 15 * Yr + 3 * Zr)))) - 1)
b = -5 * Y
c = -1 / 3.0
d = Y * (39 * L / (v + 13 * L *
(9 * Yr / (Xr + 15 * Yr + 3 * Zr))) - 5)
X = (d - b) / (a - c)
Z = X * a + b
return np.array([X, Y, Z])
示例13: XYZ_to_Lab
# 需要导入模块: from colour.colorimetry import ILLUMINANTS [as 别名]
# 或者: from colour.colorimetry.ILLUMINANTS import get [as 别名]
def XYZ_to_Lab(XYZ,
illuminant=ILLUMINANTS.get(
'CIE 1931 2 Degree Standard Observer').get('D50')):
"""
Converts from *CIE XYZ* colourspace to *CIE Lab* colourspace.
Parameters
----------
XYZ : array_like, (3,)
*CIE XYZ* colourspace matrix.
illuminant : array_like, optional
Reference *illuminant* chromaticity coordinates.
Returns
-------
ndarray, (3,)
*CIE Lab* colourspace matrix.
Notes
-----
- Input *CIE XYZ* is in domain [0, 1].
- Input *illuminant* chromaticity coordinates are in domain [0, 1].
- Output *Lightness* :math:`L^*` is in domain [0, 100].
References
----------
.. [2] http://www.brucelindbloom.com/Eqn_XYZ_to_Lab.html
(Last accessed 24 February 2014)
Examples
--------
>>> XYZ_to_Lab(np.array([0.92193107, 1, 1.03744246])) # doctest: +ELLIPSIS
array([ 100. , -7.4178784..., -15.8574210...])
"""
X, Y, Z = np.ravel(XYZ)
Xr, Yr, Zr = np.ravel(xy_to_XYZ(illuminant))
xr = X / Xr
yr = Y / Yr
zr = Z / Zr
fx = xr ** (1 / 3) if xr > CIE_E else (CIE_K * xr + 16) / 116
fy = yr ** (1 / 3) if yr > CIE_E else (CIE_K * yr + 16) / 116
fz = zr ** (1 / 3) if zr > CIE_E else (CIE_K * zr + 16) / 116
L = 116 * fy - 16
a = 500 * (fx - fy)
b = 200 * (fy - fz)
return np.array([L, a, b])
示例14: XYZ_to_xyY
# 需要导入模块: from colour.colorimetry import ILLUMINANTS [as 别名]
# 或者: from colour.colorimetry.ILLUMINANTS import get [as 别名]
def XYZ_to_xyY(XYZ,
illuminant=ILLUMINANTS.get(
'CIE 1931 2 Degree Standard Observer').get('D50')):
"""
Converts from *CIE XYZ* tristimulus values to *CIE xyY* colourspace and
reference *illuminant*.
Parameters
----------
XYZ : array_like
*CIE XYZ* tristimulus values.
illuminant : array_like, optional
Reference *illuminant* chromaticity coordinates.
Returns
-------
ndarray
*CIE xyY* colourspace array.
Notes
-----
- Input *CIE XYZ* tristimulus values are in domain [0, 1].
- Output *CIE xyY* colourspace array is in range [0, 1].
References
----------
.. [2] Lindbloom, B. (2003). XYZ to xyY. Retrieved February 24, 2014,
from http://www.brucelindbloom.com/Eqn_XYZ_to_xyY.html
Examples
--------
>>> XYZ = np.array([0.07049534, 0.10080000, 0.09558313])
>>> XYZ_to_xyY(XYZ) # doctest: +ELLIPSIS
array([ 0.2641477..., 0.3777000..., 0.1008 ])
"""
XYZ = np.asarray(XYZ)
X, Y, Z = tsplit(XYZ)
xy_w = np.asarray(illuminant)
XYZ_n = np.zeros(XYZ.shape)
XYZ_n[..., 0:2] = xy_w
xyY = np.where(
np.all(XYZ == 0, axis=-1)[..., np.newaxis],
XYZ_n,
tstack((X / (X + Y + Z), Y / (X + Y + Z), Y)))
return xyY
示例15: XYZ_to_Luv
# 需要导入模块: from colour.colorimetry import ILLUMINANTS [as 别名]
# 或者: from colour.colorimetry.ILLUMINANTS import get [as 别名]
def XYZ_to_Luv(XYZ,
illuminant=ILLUMINANTS.get(
'CIE 1931 2 Degree Standard Observer').get('D50')):
"""
Converts from *CIE XYZ* colourspace to *CIE Luv* colourspace.
Parameters
----------
XYZ : array_like, (3,)
*CIE XYZ* colourspace matrix.
illuminant : array_like, optional
Reference *illuminant* chromaticity coordinates.
Returns
-------
ndarray, (3,)
*CIE Luv* colourspace matrix.
Notes
-----
- Input *CIE XYZ* colourspace matrix is in domain [0, 1].
- Input *illuminant* chromaticity coordinates are in domain [0, 1].
- Output :math:`L^*` is in domain [0, 100].
References
----------
.. [2] Lindbloom, B. (2003). XYZ to Luv. Retrieved February 24, 2014,
from http://brucelindbloom.com/Eqn_XYZ_to_Luv.html
Examples
--------
>>> XYZ = np.array([0.07049534, 0.1008, 0.09558313])
>>> XYZ_to_Luv(XYZ) # doctest: +ELLIPSIS
array([ 37.9856291..., -28.7922944..., -1.3558195...])
"""
X, Y, Z = np.ravel(XYZ)
Xr, Yr, Zr = np.ravel(xy_to_XYZ(illuminant))
yr = Y / Yr
L = 116 * yr ** (1 / 3) - 16 if yr > CIE_E else CIE_K * yr
u = (13 * L * ((4 * X / (X + 15 * Y + 3 * Z)) -
(4 * Xr / (Xr + 15 * Yr + 3 * Zr))))
v = (13 * L * ((9 * Y / (X + 15 * Y + 3 * Z)) -
(9 * Yr / (Xr + 15 * Yr + 3 * Zr))))
return np.array([L, u, v])