Skip to content

Commit

Permalink
Update various object names and docstrings in "colour.models.rgb.ycbc…
Browse files Browse the repository at this point in the history
…r" module.
  • Loading branch information
KelSolaar committed Jan 14, 2021
1 parent d716e14 commit 0fa21fc
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions colour/models/rgb/ycbcr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Y'CbCr Colour Encoding
======================
Defines the *Y'CbCr* colour encoding related transformations:
Defines the *Y'CbCr* colour encoding related attributes and objects:
- :func:`colour.RGB_to_YCbCr`
- :func:`colour.YCbCr_to_RGB`
Expand Down Expand Up @@ -60,7 +60,7 @@
__status__ = 'Development'

__all__ = [
'WEIGHTS_YCBCR', 'YCbCr_ranges', 'RGB_to_YCbCr', 'YCbCr_to_RGB',
'WEIGHTS_YCBCR', 'ranges_YCbCr', 'RGB_to_YCbCr', 'YCbCr_to_RGB',
'RGB_to_YcCbcCrc', 'YcCbcCrc_to_RGB'
]

Expand All @@ -86,7 +86,7 @@
"""


def YCbCr_ranges(bits, is_legal, is_int):
def ranges_YCbCr(bits, is_legal, is_int):
""""
Returns the *Y'CbCr* colour encoding ranges array for given bit depth,
range legality and representation.
Expand All @@ -108,11 +108,11 @@ def YCbCr_ranges(bits, is_legal, is_int):
Examples
--------
>>> YCbCr_ranges(8, True, True)
>>> ranges_YCbCr(8, True, True)
array([ 16, 235, 16, 240])
>>> YCbCr_ranges(8, True, False) # doctest: +ELLIPSIS
>>> ranges_YCbCr(8, True, False) # doctest: +ELLIPSIS
array([ 0.0627451..., 0.9215686..., 0.0627451..., 0.9411764...])
>>> YCbCr_ranges(10, False, False)
>>> ranges_YCbCr(10, False, False)
array([ 0. , 1. , -0.5, 0.5])
"""

Expand Down Expand Up @@ -187,7 +187,7 @@ def RGB_to_YCbCr(RGB,
Array overriding the computed range such as
*out_range = (Y_min, Y_max, C_min, C_max)`. If ``out_range`` is
undefined, *Y_min*, *Y_max*, *C_min* and *C_max* will be computed
using :func:`colour.models.rgb.ycbcr.YCbCr_ranges` definition.
using :func:`colour.models.rgb.ycbcr.ranges_YCbCr` definition.
Returns
-------
Expand Down Expand Up @@ -241,27 +241,28 @@ def RGB_to_YCbCr(RGB,
>>> RGB_to_YCbCr(RGB) # doctest: +ELLIPSIS
array([ 0.9215686..., 0.5019607..., 0.5019607...])
Matching float output of The Foundry Nuke's Colorspace node set to YCbCr:
Matching the float output of *The Foundry Nuke*'s *Colorspace* node set to
*YCbCr*:
>>> RGB_to_YCbCr(RGB,
... out_range=(16 / 255, 235 / 255, 15.5 / 255, 239.5 / 255))
... # doctest: +ELLIPSIS
array([ 0.9215686..., 0.5 , 0.5 ])
Matching float output of The Foundry Nuke's Colorspace node set to YPbPr:
Matching the float output of *The Foundry Nuke*'s *Colorspace* node set to
*YPbPr*:
>>> RGB_to_YCbCr(RGB, out_legal=False, out_int=False)
... # doctest: +ELLIPSIS
array([ 1., 0., 0.])
Creating integer code values as per standard 10-bit SDI:
Creating integer code values as per standard *10-bit SDI*:
>>> RGB_to_YCbCr(RGB, out_legal=True, out_bits=10, out_int=True)
... # doctest: +ELLIPSIS
array([940, 512, 512]...)
For JFIF JPEG conversion as per ITU-T T.871
:cite:`InternationalTelecommunicationUnion2011e`:
For *JFIF JPEG* conversion as per *Recommendation ITU-T T.871*
>>> RGB = np.array([102, 0, 51])
>>> RGB_to_YCbCr(RGB, K=WEIGHTS_YCBCR['ITU-R BT.601'], in_range=(0, 255),
Expand All @@ -274,10 +275,10 @@ def RGB_to_YCbCr(RGB,
about 127.5, meaning that there is no integer code value to represent
achromatic colours. This does however create the possibility of output
integer codes with value of 256, which cannot be stored in 8-bit integer
representation. Recommendation ITU-T T.871 specifies these should be
representation. *Recommendation ITU-T T.871* specifies these should be
clamped to 255.
These JFIF JPEG ranges are also obtained as follows:
These *JFIF JPEG* ranges are also obtained as follows:
>>> RGB_to_YCbCr(RGB, K=WEIGHTS_YCBCR['ITU-R BT.601'], in_bits=8,
... in_int=True, out_legal=False, out_int=True)
Expand All @@ -294,7 +295,7 @@ def RGB_to_YCbCr(RGB,
RGB_min, RGB_max = kwargs.get('in_range',
CV_range(in_bits, in_legal, in_int))
Y_min, Y_max, C_min, C_max = kwargs.get(
'out_range', YCbCr_ranges(out_bits, out_legal, out_int))
'out_range', ranges_YCbCr(out_bits, out_legal, out_int))

RGB_float = RGB.astype(DEFAULT_FLOAT_DTYPE) - RGB_min
RGB_float *= 1 / (RGB_max - RGB_min)
Expand Down Expand Up @@ -364,7 +365,7 @@ def YCbCr_to_RGB(YCbCr,
Array overriding the computed range such as
*in_range = (Y_min, Y_max, C_min, C_max)*. If ``in_range`` is
undefined, *Y_min*, *Y_max*, *C_min* and *C_max* will be computed using
:func:`colour.models.rgb.ycbcr.YCbCr_ranges` definition.
:func:`colour.models.rgb.ycbcr.ranges_YCbCr` definition.
out_range : array_like, optional
Array overriding the computed range such as
*out_range = (RGB_min, RGB_max)*. If ``out_range`` is undefined,
Expand Down Expand Up @@ -423,7 +424,7 @@ def YCbCr_to_RGB(YCbCr,
Y, Cb, Cr = tsplit(YCbCr.astype(DEFAULT_FLOAT_DTYPE))
Kr, Kb = K
Y_min, Y_max, C_min, C_max = kwargs.get(
'in_range', YCbCr_ranges(in_bits, in_legal, in_int))
'in_range', ranges_YCbCr(in_bits, in_legal, in_int))
RGB_min, RGB_max = kwargs.get('out_range',
CV_range(out_bits, out_legal, out_int))

Expand Down Expand Up @@ -480,7 +481,7 @@ def RGB_to_YcCbcCrc(RGB,
Array overriding the computed range such as
*out_range = (Y_min, Y_max, C_min, C_max)*. If ``out_range`` is
undefined, *Y_min*, *Y_max*, *C_min* and *C_max* will be computed
using :func:`colour.models.rgb.ycbcr.YCbCr_ranges` definition.
using :func:`colour.models.rgb.ycbcr.ranges_YCbCr` definition.
Returns
-------
Expand Down Expand Up @@ -526,7 +527,7 @@ def RGB_to_YcCbcCrc(RGB,

R, G, B = tsplit(to_domain_1(RGB))
Y_min, Y_max, C_min, C_max = kwargs.get(
'out_range', YCbCr_ranges(out_bits, out_legal, out_int))
'out_range', ranges_YCbCr(out_bits, out_legal, out_int))

Yc = 0.2627 * R + 0.6780 * G + 0.0593 * B

Expand Down Expand Up @@ -584,7 +585,7 @@ def YcCbcCrc_to_RGB(YcCbcCrc,
Array overriding the computed range such as
*in_range = (Y_min, Y_max, C_min, C_max)*. If ``in_range`` is
undefined, *Y_min*, *Y_max*, *C_min* and *C_max* will be computed using
:func:`colour.models.rgb.ycbcr.YCbCr_ranges` definition.
:func:`colour.models.rgb.ycbcr.ranges_YCbCr` definition.
Returns
-------
Expand Down Expand Up @@ -636,7 +637,7 @@ def YcCbcCrc_to_RGB(YcCbcCrc,

Yc, Cbc, Crc = tsplit(YcCbcCrc.astype(DEFAULT_FLOAT_DTYPE))
Y_min, Y_max, C_min, C_max = kwargs.get(
'in_range', YCbCr_ranges(in_bits, in_legal, in_int))
'in_range', ranges_YCbCr(in_bits, in_legal, in_int))

Yc -= Y_min
Cbc -= (C_max + C_min) / 2
Expand Down

0 comments on commit 0fa21fc

Please sign in to comment.