Skip to content

Commit

Permalink
Rename ".*matrix.*" objects in "colour.models" sub-package.
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Oct 3, 2020
1 parent 9a8e794 commit e65b38d
Show file tree
Hide file tree
Showing 22 changed files with 322 additions and 200 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -846,15 +846,15 @@ RGB Colourspace and Transformations
>>> illuminant_XYZ = [0.34570, 0.35850]
>>> illuminant_RGB = [0.31270, 0.32900]
>>> chromatic_adaptation_transform = 'Bradford'
>>> XYZ_to_RGB_matrix = [
>>> matrix_XYZ_to_RGB = [
[3.24062548, -1.53720797, -0.49862860],
[-0.96893071, 1.87575606, 0.04151752],
[0.05571012, -0.20402105, 1.05699594]]
>>> colour.XYZ_to_RGB(
XYZ,
illuminant_XYZ,
illuminant_RGB,
XYZ_to_RGB_matrix,
matrix_XYZ_to_RGB,
chromatic_adaptation_transform)
array([ 0.45595571, 0.03039702, 0.04087245])
Expand Down
48 changes: 26 additions & 22 deletions colour/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,19 @@
Luv_uv_to_xy, OETFS, OETF_INVERSES, OOTFS, OOTF_INVERSES, OSA_UCS_to_XYZ,
Prismatic_to_RGB, RGB_COLOURSPACES, RGB_Colourspace, RGB_luminance,
RGB_luminance_equation, RGB_to_CMY, RGB_to_HSL, RGB_to_HSV, RGB_to_ICTCP,
RGB_to_Prismatic, RGB_to_RGB, RGB_to_RGB_matrix, RGB_to_XYZ, RGB_to_YCbCr,
RGB_to_YCoCg, RGB_to_YcCbcCrc, UCS_to_XYZ, UCS_to_uv, UCS_uv_to_xy,
UVW_to_XYZ, WEIGHTS_YCBCR, XYZ_to_Hunter_Lab, XYZ_to_Hunter_Rdab,
XYZ_to_IPT, XYZ_to_JzAzBz, XYZ_to_K_ab_HunterLab1966, XYZ_to_Lab,
XYZ_to_Luv, XYZ_to_OSA_UCS, XYZ_to_RGB, XYZ_to_UCS, XYZ_to_UVW,
XYZ_to_hdr_CIELab, XYZ_to_hdr_IPT, XYZ_to_sRGB, XYZ_to_xy, XYZ_to_xyY,
YCbCr_to_RGB, YCoCg_to_RGB, YcCbcCrc_to_RGB, cctf_decoding, cctf_encoding,
RGB_to_Prismatic, RGB_to_RGB, RGB_to_XYZ, RGB_to_YCbCr, RGB_to_YCoCg,
RGB_to_YcCbcCrc, UCS_to_XYZ, UCS_to_uv, UCS_uv_to_xy, UVW_to_XYZ,
WEIGHTS_YCBCR, XYZ_to_Hunter_Lab, XYZ_to_Hunter_Rdab, XYZ_to_IPT,
XYZ_to_JzAzBz, XYZ_to_K_ab_HunterLab1966, XYZ_to_Lab, XYZ_to_Luv,
XYZ_to_OSA_UCS, XYZ_to_RGB, XYZ_to_UCS, XYZ_to_UVW, XYZ_to_hdr_CIELab,
XYZ_to_hdr_IPT, XYZ_to_sRGB, XYZ_to_xy, XYZ_to_xyY, YCbCr_to_RGB,
YCoCg_to_RGB, YcCbcCrc_to_RGB, cctf_decoding, cctf_encoding,
chromatically_adapted_primaries, eotf, eotf_inverse, full_to_legal,
gamma_function, hdr_CIELab_to_XYZ, hdr_IPT_to_XYZ, legal_to_full,
linear_function, log_decoding, log_encoding, normalised_primary_matrix,
oetf, oetf_inverse, ootf, ootf_inverse, primaries_whitepoint, sRGB_to_XYZ,
uv_to_Luv, uv_to_UCS, xyY_to_XYZ, xyY_to_xy, xy_to_Luv_uv, xy_to_UCS_uv,
xy_to_XYZ, xy_to_xyY)
linear_function, log_decoding, log_encoding, matrix_RGB_to_RGB,
normalised_primary_matrix, oetf, oetf_inverse, ootf, ootf_inverse,
primaries_whitepoint, sRGB_to_XYZ, uv_to_Luv, uv_to_UCS, xyY_to_XYZ,
xyY_to_xy, xy_to_Luv_uv, xy_to_UCS_uv, xy_to_XYZ, xy_to_xyY)
from .corresponding import (
BRENEMAN_EXPERIMENTS, BRENEMAN_EXPERIMENT_PRIMARIES_CHROMATICITIES,
CORRESPONDING_CHROMATICITIES_PREDICTION_MODELS, CorrespondingColourDataset,
Expand Down Expand Up @@ -262,17 +262,17 @@ def __getattr__(self, attribute):
'OOTF_INVERSES', 'OSA_UCS_to_XYZ', 'Prismatic_to_RGB', 'RGB_COLOURSPACES',
'RGB_Colourspace', 'RGB_luminance', 'RGB_luminance_equation', 'RGB_to_CMY',
'RGB_to_HSL', 'RGB_to_HSV', 'RGB_to_ICTCP', 'RGB_to_Prismatic',
'RGB_to_RGB', 'RGB_to_RGB_matrix', 'RGB_to_XYZ', 'RGB_to_YCbCr',
'RGB_to_YCoCg', 'RGB_to_YcCbcCrc', 'UCS_to_XYZ', 'UCS_to_uv',
'UCS_uv_to_xy', 'UVW_to_XYZ', 'WEIGHTS_YCBCR', 'XYZ_to_Hunter_Lab',
'XYZ_to_Hunter_Rdab', 'XYZ_to_IPT', 'XYZ_to_JzAzBz',
'XYZ_to_K_ab_HunterLab1966', 'XYZ_to_Lab', 'XYZ_to_Luv', 'XYZ_to_OSA_UCS',
'XYZ_to_RGB', 'XYZ_to_UCS', 'XYZ_to_UVW', 'XYZ_to_hdr_CIELab',
'XYZ_to_hdr_IPT', 'XYZ_to_sRGB', 'XYZ_to_xy', 'XYZ_to_xyY', 'YCbCr_to_RGB',
'YCoCg_to_RGB', 'YcCbcCrc_to_RGB', 'cctf_decoding', 'cctf_encoding',
'chromatically_adapted_primaries', 'eotf', 'eotf_inverse', 'full_to_legal',
'gamma_function', 'hdr_CIELab_to_XYZ', 'hdr_IPT_to_XYZ', 'legal_to_full',
'linear_function', 'log_decoding', 'log_encoding',
'RGB_to_RGB', 'RGB_to_XYZ', 'RGB_to_YCbCr', 'RGB_to_YCoCg',
'RGB_to_YcCbcCrc', 'UCS_to_XYZ', 'UCS_to_uv', 'UCS_uv_to_xy', 'UVW_to_XYZ',
'WEIGHTS_YCBCR', 'XYZ_to_Hunter_Lab', 'XYZ_to_Hunter_Rdab', 'XYZ_to_IPT',
'XYZ_to_JzAzBz', 'XYZ_to_K_ab_HunterLab1966', 'XYZ_to_Lab', 'XYZ_to_Luv',
'XYZ_to_OSA_UCS', 'XYZ_to_RGB', 'XYZ_to_UCS', 'XYZ_to_UVW',
'XYZ_to_hdr_CIELab', 'XYZ_to_hdr_IPT', 'XYZ_to_sRGB', 'XYZ_to_xy',
'XYZ_to_xyY', 'YCbCr_to_RGB', 'YCoCg_to_RGB', 'YcCbcCrc_to_RGB',
'cctf_decoding', 'cctf_encoding', 'chromatically_adapted_primaries',
'eotf', 'eotf_inverse', 'full_to_legal', 'gamma_function',
'hdr_CIELab_to_XYZ', 'hdr_IPT_to_XYZ', 'legal_to_full', 'linear_function',
'log_decoding', 'log_encoding', 'matrix_RGB_to_RGB',
'normalised_primary_matrix', 'oetf', 'oetf_inverse', 'ootf',
'ootf_inverse', 'primaries_whitepoint', 'sRGB_to_XYZ', 'uv_to_Luv',
'uv_to_UCS', 'xyY_to_XYZ', 'xyY_to_xy', 'xy_to_Luv_uv', 'xy_to_UCS_uv',
Expand Down Expand Up @@ -1931,6 +1931,10 @@ def __getattr__(self, attribute):
'colour.RGB_CMFS',
'colour.colorimetry.MSDS_CMFS_RGB',
],
[
'colour.RGB_to_RGB_matrix',
'colour.matrix_RGB_to_RGB',
],
[
'colour.RLAB_D_FACTOR',
'colour.appearance.D_FACTOR_RLAB',
Expand Down
6 changes: 3 additions & 3 deletions colour/characterisation/aces_it.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def k(x, y):
chromatic_adaptation_transform)
E_rgb = XYZ_to_RGB(XYZ, RGB_COLOURSPACE_ACES2065_1.whitepoint,
RGB_COLOURSPACE_ACES2065_1.whitepoint,
RGB_COLOURSPACE_ACES2065_1.XYZ_to_RGB_matrix)
RGB_COLOURSPACE_ACES2065_1.matrix_XYZ_to_RGB)

return from_range_1(E_rgb)

Expand Down Expand Up @@ -643,7 +643,7 @@ def objective_function(M, RGB, Lab):

M = np.reshape(M, [3, 3])

XYZ_t = dot_vector(RGB_COLOURSPACE_ACES2065_1.RGB_to_XYZ_matrix,
XYZ_t = dot_vector(RGB_COLOURSPACE_ACES2065_1.matrix_RGB_to_XYZ,
dot_vector(M, RGB))
Lab_t = XYZ_to_Lab(XYZ_t, RGB_COLOURSPACE_ACES2065_1.whitepoint)

Expand Down Expand Up @@ -692,7 +692,7 @@ def objective_function(M, RGB, Jab):

M = np.reshape(M, [3, 3])

XYZ_t = dot_vector(RGB_COLOURSPACE_ACES2065_1.RGB_to_XYZ_matrix,
XYZ_t = dot_vector(RGB_COLOURSPACE_ACES2065_1.matrix_RGB_to_XYZ,
dot_vector(M, RGB))
Jab_t = XYZ_to_JzAzBz(XYZ_t)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
RGB = colour.XYZ_to_RGB(
colour.xyY_to_XYZ(xyY), illuminant,
colour.CCS_ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D65'],
colour.RGB_COLOURSPACES['sRGB'].XYZ_to_RGB_matrix, 'Bradford',
colour.RGB_COLOURSPACES['sRGB'].matrix_XYZ_to_RGB, 'Bradford',
colour.RGB_COLOURSPACES['sRGB'].cctf_encoding)

RGB = [int(round(x * 255)) if x >= 0 else 0 for x in np.ravel(RGB)]
Expand Down
4 changes: 2 additions & 2 deletions colour/examples/models/examples_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
XYZ,
D65,
colour.RGB_COLOURSPACES['sRGB'].whitepoint,
colour.RGB_COLOURSPACES['sRGB'].XYZ_to_RGB_matrix,
colour.RGB_COLOURSPACES['sRGB'].matrix_XYZ_to_RGB,
'Bradford',
colour.RGB_COLOURSPACES['sRGB'].cctf_encoding,
))
Expand All @@ -81,7 +81,7 @@
RGB,
colour.RGB_COLOURSPACES['sRGB'].whitepoint,
D65,
colour.RGB_COLOURSPACES['sRGB'].RGB_to_XYZ_matrix,
colour.RGB_COLOURSPACES['sRGB'].matrix_RGB_to_XYZ,
'Bradford',
colour.RGB_COLOURSPACES['sRGB'].cctf_decoding,
))
Expand Down
8 changes: 4 additions & 4 deletions colour/examples/models/examples_rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
print('Name:\n"{0}"'.format(colourspace.name))
print('\nPrimaries:\n{0}'.format(colourspace.primaries))
print(('\nNormalised primary matrix to "CIE XYZ" '
'tristimulus values:\n{0}').format(colourspace.RGB_to_XYZ_matrix))
'tristimulus values:\n{0}').format(colourspace.matrix_RGB_to_XYZ))
print('\nNormalised primary matrix to "ACES2065-1":\n{0}'.format(
colourspace.XYZ_to_RGB_matrix))
colourspace.matrix_XYZ_to_RGB))
print('\nOpto-electronic transfer function from '
'linear to colourspace:\n{0}'.format(colourspace.cctf_encoding))
print('\nElectro-optical transfer function from '
Expand All @@ -38,8 +38,8 @@
colour.xy_to_XYZ(colourspace.whitepoint),
colour.xy_to_XYZ(colour.RGB_COLOURSPACES['ITU-R BT.709'].whitepoint))
print(
np.dot(colour.RGB_COLOURSPACES['ITU-R BT.709'].XYZ_to_RGB_matrix,
np.dot(cat, colourspace.RGB_to_XYZ_matrix)))
np.dot(colour.RGB_COLOURSPACES['ITU-R BT.709'].matrix_XYZ_to_RGB,
np.dot(cat, colourspace.matrix_RGB_to_XYZ)))

print('\n')

Expand Down
4 changes: 2 additions & 2 deletions colour/graph/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,13 +388,13 @@ def RGB_luminance_to_RGB(Y):
XYZ_to_RGB,
illuminant_XYZ=RGB_COLOURSPACE__DEFAULT_RGB.whitepoint,
illuminant_RGB=RGB_COLOURSPACE__DEFAULT_RGB.whitepoint,
XYZ_to_RGB_matrix=RGB_COLOURSPACE__DEFAULT_RGB.XYZ_to_RGB_matrix)),
matrix_XYZ_to_RGB=RGB_COLOURSPACE__DEFAULT_RGB.matrix_XYZ_to_RGB)),
('RGB', 'CIE XYZ',
partial(
RGB_to_XYZ,
illuminant_RGB=RGB_COLOURSPACE__DEFAULT_RGB.whitepoint,
illuminant_XYZ=RGB_COLOURSPACE__DEFAULT_RGB.whitepoint,
RGB_to_XYZ_matrix=RGB_COLOURSPACE__DEFAULT_RGB.RGB_to_XYZ_matrix)),
matrix_RGB_to_XYZ=RGB_COLOURSPACE__DEFAULT_RGB.matrix_RGB_to_XYZ)),
('RGB', 'Scene-Referred RGB',
partial(
RGB_to_RGB,
Expand Down
4 changes: 4 additions & 0 deletions colour/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,10 @@ def __getattr__(self, attribute):
'colour.models.YCBCR_WEIGHTS',
'colour.models.WEIGHTS_YCBCR',
],
[
'colour.models.RGB_to_RGB_matrix',
'colour.models.matrix_RGB_to_RGB',
],
]

if not is_documentation_building():
Expand Down
4 changes: 2 additions & 2 deletions colour/models/rgb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
RGB_luminance_equation, RGB_luminance)
from .rgb_colourspace import RGB_Colourspace
from .rgb_colourspace import XYZ_to_RGB, RGB_to_XYZ
from .rgb_colourspace import RGB_to_RGB_matrix, RGB_to_RGB
from .rgb_colourspace import matrix_RGB_to_RGB, RGB_to_RGB
from .transfer_functions import * # noqa
from . import transfer_functions
from .datasets import * # noqa
Expand All @@ -27,7 +27,7 @@
]
__all__ += ['RGB_Colourspace']
__all__ += ['XYZ_to_RGB', 'RGB_to_XYZ']
__all__ += ['RGB_to_RGB_matrix', 'RGB_to_RGB']
__all__ += ['matrix_RGB_to_RGB', 'RGB_to_RGB']
__all__ += transfer_functions.__all__
__all__ += datasets.__all__
__all__ += ['XYZ_to_sRGB', 'sRGB_to_XYZ']
Expand Down
4 changes: 2 additions & 2 deletions colour/models/rgb/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def XYZ_to_sRGB(XYZ,
XYZ,
illuminant,
sRGB.whitepoint,
sRGB.XYZ_to_RGB_matrix,
sRGB.matrix_XYZ_to_RGB,
chromatic_adaptation_transform,
sRGB.cctf_encoding if apply_cctf_encoding else None,
)
Expand Down Expand Up @@ -162,7 +162,7 @@ def sRGB_to_XYZ(RGB,
RGB,
sRGB.whitepoint,
illuminant,
sRGB.RGB_to_XYZ_matrix,
sRGB.matrix_RGB_to_XYZ,
chromatic_adaptation_method,
sRGB.cctf_decoding if apply_cctf_decoding else None,
)
Loading

0 comments on commit e65b38d

Please sign in to comment.