chartjs / chartjs-color

JavaScript color conversion and manipulation library
MIT License
21 stars 6 forks source link

Consider re-evaluating YIQ formula #2

Open simonbrunel opened 7 years ago

simonbrunel commented 7 years ago

Note: issue posted by @zlumer in the deprecated "color" repository on Jul 14 '16.

See index.js:201

As stated here: ColorFAQ

The coefficients 0.299, 0.587 and 0.114 properly computed luminance for monitors having phosphors that were contemporary at the introduction of NTSC television in 1953. They are still appropriate for computing video luma to be discussed below in section 11. However, these coefficients do not accurately compute luminance for contemporary monitors.

The proposed formula is as follows:

image

Or

yiq = (rgb[0] * 2126 + rgb[1] * 7152 + rgb[2] * 722) / 10000;
Qix- commented 7 years ago

Note: issue posted by @zlumer in the deprecated "color" repository on Jul 14 '16.

I don't see that issue anywhere in the issues tracker - apologies if it got lost in the ownership handoff.

simonbrunel commented 7 years ago

@Qix- the issue was in chartjs/color repository that we decided to remove in favor of this one which is a real fork of your work.

I updated the link over index.js in the ticket description.

Qix- commented 7 years ago

Aha, gotcha. :)

I'd be down to change the coefficients in color. The note about the current coefficients being archaic and geared towards NTSC phosphors is quite interesting - it appears the tutorial the original author of that function used for the YIQ formula didn't do a whole lot of research.

I'm curious to see if there is a drastic change in the output, though. I've opened qix-/color#107 to do some research when I get a spare moment.

Side note: see https://github.com/chartjs/Chart.js/issues/3823#issuecomment-275078341.

zlumer commented 7 years ago

Haha, I'm trying to remember why I even reported this issue in the first place. Don't have a clue where I used it, but pretty sure it should be changed according to standard.