[issue45775] Implementation of colorsys.rgb_to_yuv and vice versa

2021-11-23 Thread Éric Araujo

Éric Araujo  added the comment:

Thank you for suggesting the improvement and working on a PR nonetheless!
Hope the experience can be useful for other tickets in the future.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45775] Implementation of colorsys.rgb_to_yuv and vice versa

2021-11-23 Thread Éric Araujo

Éric Araujo  added the comment:

I think that there’s no need to change the existing tests.
The CPython project prefers to not do tiny improvements for their own sake.

--
nosy: +eric.araujo

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45775] Implementation of colorsys.rgb_to_yuv and vice versa

2021-11-23 Thread Thomas Stolarski


Thomas Stolarski  added the comment:

I figured this would probably be the case, but since YIQ also requires a 
profile (and the FCC one it implements is pretty weird for digital work), I 
thought I'd give it a shot anyway.

Would it be worth moving the test/formatting changes over to a different ticket 
or should we just leave them?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45775] Implementation of colorsys.rgb_to_yuv and vice versa

2021-11-23 Thread STINNER Victor


STINNER Victor  added the comment:

You can write your own module on PyPI with more advanced features if you want 
to extend colorsys ;-)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45775] Implementation of colorsys.rgb_to_yuv and vice versa

2021-11-23 Thread STINNER Victor


STINNER Victor  added the comment:

Ok, let's reject this feature and restrict colorsys to simple color spaces 
which don't require profiles.

--
resolution:  -> rejected
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45775] Implementation of colorsys.rgb_to_yuv and vice versa

2021-11-23 Thread Petr Viktorin


Petr Viktorin  added the comment:

> YUV is a common color encoding system. It's used by the JPEG image format and 
> MPEG video format for example.

As far as I understand it, the YUV/RGB conversion used by JPEG is not the same 
as the one used by MPEG, and neither of those is the Rec 709 YUV proposed here.

YUV is used in video production and photography. If you need to work with it, 
you most likely need some kind of precise color matching. If colorsys 
implements the wrong one *for you* (even if it's the most commonly used one, 
and what HDTV uses), then the stdlib has failed you.

Meanwhile, RGB/HLS is used by Web designers writing CSS, GUI authors giving you 
a big green button to click, or color pickers for your avatar's hair. They're 
designing for uncalibrated monitors. *That* is the target audience for colorsys.
The image libraries these people use to read JPGs invariably convert to RGB and 
throw away any precise color information, which is meaningless on uncalibrated 
monitors.

I cannot see a use case for YUV in colorsys that doesn't also require a more 
complex image processing library. It's that library that should provide the 
necessary colorspace conversions, depending on if it's dealing with JPEG or 
MPEG or HDTV.

But please point out my mistakes and clear my doubts!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45775] Implementation of colorsys.rgb_to_yuv and vice versa

2021-11-18 Thread STINNER Victor


STINNER Victor  added the comment:

The GIMP image editor uses https://gegl.org/babl/ which supports tons of 
formats and supports color spaces, ICC profiles, etc.

I would also prefer to keep colorsys simple and so not support ICC profiles for 
example.

YUV is a common color encoding system. It's used by the JPEG image format and 
MPEG video format for example.
https://en.wikipedia.org/wiki/YUV

In terms of complexity and maintenance burden, supporting YUV (PR 29512) sounds 
reasonable me.

If colorsys is limited to RGB/HLS/HSV, I'm not sure if it is useful. Nowadays, 
there are more color formats which are getting popular. If they are not 
supported, maybe it's better to just remove the module. I don't know.

Well, I don't have a strong opinion on adding YUV support or not.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45775] Implementation of colorsys.rgb_to_yuv and vice versa

2021-11-18 Thread Petr Viktorin


Petr Viktorin  added the comment:

I argued for keeping colorsys: RGB/HLS/HSV are useful in several fields. 
Colorsys is a nice low-power battery to have around for e.g. picking a color 
for highlighting any kind of output.

YIQ is the odd one out: it describes actual color, rather than instructions for 
a monitor. I think that if you need YIQ, YUV, CMYK, sRGB, XYZ or Lab, you 
should reach for a more specialized library. In other words, I don't see YIQ as 
an example to be followed.

--
nosy: +petr.viktorin

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45775] Implementation of colorsys.rgb_to_yuv and vice versa

2021-11-12 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

On pydev, Guido said "There was talk of deprecating colorsys, but PEP 594 now 
lists it under "modules to keep".  Victor, do you know enough to review?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45775] Implementation of colorsys.rgb_to_yuv and vice versa

2021-11-12 Thread STINNER Victor

STINNER Victor  added the comment:

> A link to an authoritative reference with the formulas would be necessary to 
> merge this.

The PR says: "ATSC BT.709 standard constants".

For exmaple, I found:
https://en.wikipedia.org/wiki/Rec._709#Luma_coefficients

"When encoding Y’CBCR video, BT.709 creates gamma-encoded luma (Y’) using 
matrix coefficients 0.2126, 0.7152, and 0.0722 (together they add to 1)."

--
nosy: +vstinner

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45775] Implementation of colorsys.rgb_to_yuv and vice versa

2021-11-12 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

A link to an authoritative reference with the formulas would be necessary to 
merge this.  I inquired of pydev list whether improvement is allowed.

--
nosy: +terry.reedy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45775] Implementation of colorsys.rgb_to_yuv and vice versa

2021-11-09 Thread Thomas Stolarski


Change by Thomas Stolarski :


--
keywords: +patch
pull_requests: +27763
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/29512

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45775] Implementation of colorsys.rgb_to_yuv and vice versa

2021-11-09 Thread Thomas Stolarski


New submission from Thomas Stolarski :

Since the implementation of `rgb_to_yiq` roughly 30 years ago now, the advent 
of HDTV has resulted in most broadcasting and video processing having moved 
towards Rec 709 (or BT.709).

While I know colorsys has been on the chopping block for a while, it seemed a 
little silly that what is now arguably the most common color space used in 
video editors isn't available as part of this module, despite being a matrix 
mapping like much of the others.

YUV is a bit more contentious on its definition than YIQ is, but it is still 
widely used to refer to Rec 709 and this is the ATSC standardization for HDTV.

I've written a PR for both conversions and will add it to this ticket once it's 
up.

--
components: Library (Lib)
messages: 406067
nosy: thomas.stolarski
priority: normal
severity: normal
status: open
title: Implementation of colorsys.rgb_to_yuv and vice versa
type: enhancement
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com