Live data from Hacker News

Color: From Hex codes to Eyeballs

jamie-wong.com

31–40 of 55 posts

Re: Color: From Hex codes to Eyeballs

#31
A couple of years ago, I built an app that would generate websites from photographs. The idea was if you liked a particular scenery/color combination from the real world, then you'd have a website built from it. All you had to do was a take a photo and it'd generate a color palette from which the website would be built on the fly.

However, I faced with the same challenge as the author has pointed out - what our eyes see and perceive as "bright" are very totally different from what computers perceive. So, I designed an algorithm from scratch using ML and the HSV color model. The tests I ran showed me the real difference between what I saw and what the computers saw.

Here's some samples:

1. https://i.imgur.com/jhWR3pq.jpg

2. https://i.imgur.com/M6Oo6dp.jpg

I think I'll probably open source it soon.

Re: Color: From Hex codes to Eyeballs

#33
post #20

Earlier quoted context omitted.

> It looks a little suspicious to me the way he simply just multiplies the normalized relative sensitivity measure with the spectral fluxes. What is suspicious about it? This is how all response functions work mathematically, both for humans and animals, as well as for mechanical sensors. The response function is the measured ratio of the input value to the output response (for a given wavelength in this case, but it…

An analogy of filling a curved-bottom tub would be a better fit than of someone making bets optimally when the chances are non-uniform. Our cones can be stimulated only up to some certain amount. At the point of saturation, any further stimuli would have no effect, other than perhaps frying the receptors. I would also suspect that the receptors are becoming less and less sensitive to the stimuli they accept as they g…

You're right that once you saturate your green cones, the marginal response of other wavelengths will overtake 550nm. But until you hit saturation, the most efficient use of energy is to put everything on 550nm, not spread it out. You're saying that changing the response curve (e.g. by saturating the green cones) changes the optimal wavelength, but that doesn't change the fact that there's always a single optimal wavelength that is the argmax of the current marginal response curve.

In any case, we're talking about displaying color on computer monitors here. If your computer monitor is getting anywhere near saturating your cones, you have a big problem.

Re: Color: From Hex codes to Eyeballs

#34
post #31

A couple of years ago, I built an app that would generate websites from photographs. The idea was if you liked a particular scenery/color combination from the real world, then you'd have a website built from it. All you had to do was a take a photo and it'd generate a color palette from which the website would be built on the fly. However, I faced with the same challenge as the author has pointed out - what our eyes…

Very interesting! I think you have a powerful base for building posters on the fly. Take image A, crop the background, take the colors from your algorithm and use the ones that the regular algorithm wouldn't consider (the ones that stand out more but appear in less quantity) for generating headers and subheaders of the poster. You have a color balanced algorithm made poster with just an image and a background as an input from the user.

Re: Color: From Hex codes to Eyeballs

#35

Earlier quoted context omitted.

Could you elaborate on the intuition gaps that people have? I have a pretty good understanding of color theory and the physics/biology behind it, but I have no knowledge on the pedagogy of it. Hence learning about the more common false beliefs sounds fascinating.

Mainly, the concept of subtractive mixing. Paint (or pigment) works by absorbing a portion of the visible spectrum and reflecting the rest. What you see is what is reflected. When you mix pigments, both portions of the spectrum are absorbed, and a smaller resultant portion is reflected. We mostly think of color in terms of light, and mixing colors of light which is often the opposite (light: "all colors mixed is whit…

I think the intuition gap comes from the misleading arts education about colour. It's still common to teach in schools that primary colors for paint are blue, red and yellow - when the correct primary colors are cyan, magenta and yellow as everybody familiar with CMYK printing can tell. If you search the internet about mixing paints, almost every site claims that the primary colours are blue, red and yellow... So I don't think it's the subtractive mixing itself, but subtractive mixing with CMY colors (and not the wrong model of red, blue and yellow they are used to).

There's long history of arts education with this misconception, partly because suitable pigments for CMY colour model are relatively new invention. Blue, red and yellow also kind of work well enough, especially if you tweak the palette by having two shades of each as your "primary colors". (E.g. you can mix saturated green from cadmium yellow and prussian blue, but if you mix chrome yellow and ultramarine blue, the green will be muddy). It's kind of like instead of having a full triangular gamut of CMY space, you crop the corners off of the triangle and have a a sort of hexagonal gamut.

As primary colors are by definition "colors that can't be mixed from other colors", it's strange that in arts education they still claim that red and blue are primary colors, when it's obvious that red can be mixed from magenta and yellow, and blue can be mixed from cyan and magenta, as every colour printer is doing it like this.

Re: Color: From Hex codes to Eyeballs

#36
post #5

I write firmware for theater/TV LED lights. I have a spectrometer on my desk. This is the guide I wish I had to get started with! It’s amazing!

Here's another trove of information about color, if anyone finds it useful: http://www.handprint.com/LS/CVS/color.html

See also the classic Color FAQ:

http://poynton.ca/ColorFAQ.html

Re: Color: From Hex codes to Eyeballs

#37
post #7

How can an image properly illustrate (in RGB) what colors are outside of the RGB gamut? That image must be inaccurate? Should I assume the image is technically incorrect but a good illustration of what the RGB gamut does look like?

This (and every other gamut picture in existence) can't, which is why the colors don't change any further outside the RGB triangle in these illustrations online. (In CMYK print it's even worse.) You have to use your imagination that the colors become even more intense. A good parallel would be if you ever try to take a snapshot of a vivid sunset on your phone, then compare the screen image with the sunset behind you.…

The closest comparison would be to try to match the colours of the sunset with a paint app on your phone.

The phone's camera has its own limitations which prevent it from reproducing certain colourful settings well, even if you viewed the photo on a wide gamut screen.

Re: Color: From Hex codes to Eyeballs

#38

I've been trying to build my own mental model that's easy to visualize how your eyes build color. Imagine 3 people (r,g,b) standing across from each other playing a 3 way tug of war with a bowling ball in the center. They each can feed on certain ranges of radiation to help them pull the ball towards them, color is determined by where the ball ends up. If red and green pull equally the ball moves sideways out of the…

As a "colorblind" person, this is a bit frustrating so bear with me.

Few people are literally "colorblind". You don't have one cone cell of each type, you have loads of them. Colorblind people generally have fewer of them (or some of them are shifted) but usually only for one type (usually red/green).

The "red" and "green" cones overlap quite a lot[1] and they also overlap with the rods. This means that even if you lack some "green" cones you will still likely perceive "green" colors, except they will be hue-shifted into red and less saturated. Simulating this effect for people with normal vision usually results in "muddier" colors.

Your analogy is pretty good otherwise (except as someone else pointed out, that's apparently not at all how the signals are processed) but this seems to be a widespread misconception about color "blindness", so I felt it's important to point that out.

It's also worth mentioning that it's meaningless to say "there's no such thing as pure green". Physically isolating certain wavelengths produces a "pure green" light. What someone with normal color vision perceives when they see "pure green" light is the result of multiple cones being stimulated at the same time, sure, but there's no one-to-one mapping of cones and colors except for some very small bits at both ends of the spectrum, which is why the cones are generally referred to as L/M/S (for long/medium/short wavelengths) rather than R/G/B (for the colors).

A tetrachromatic person (assuming the fourth cone type's peak sits somewhere between 420nm and 564nm, i.e. "blue" and "red") likely won't enable someone to perceive colors outside that range. In your example, the 3 people are forming a lopsided triangle. Adding a fourth person makes it a four-sided polygon but doesn't add another dimension. Tetrachromacy (depending on where the cones lie) would make it easier to distinguish certain shades though by making them more vibrant -- to them, normal vision would appear as "muddy" as my vision does to someone with normal vision.

[1]: https://commons.wikimedia.org/wiki/File:Cone-response-en.svg

EDIT: Because some people find that interesting, here's a page with a bunch of photos that fairly accurately simulate my color vision (i.e. looking randomly at both sets of photos I wouldn't be able to tell you which one is the original): https://web.archive.org/web/20160308043950/http://critiquewa... -- apparently brown skin looks green to me.

Re: Color: From Hex codes to Eyeballs

#39
post #30

One interesting facet of all this is that afaik most of our hyper-realistic "physically based rendering" 3D renderers are still based on these color models instead of modeling the light spectrally. I imagine that somewhere in near future that will change as we start reaching the limits of the color models. It is actually interesting how well simple RGB has served in practice when it is fairly simple to imagine scenes…

See https://news.ycombinator.com/item?id=16799578

Re: Color: From Hex codes to Eyeballs

#40
post #31

A couple of years ago, I built an app that would generate websites from photographs. The idea was if you liked a particular scenery/color combination from the real world, then you'd have a website built from it. All you had to do was a take a photo and it'd generate a color palette from which the website would be built on the fly. However, I faced with the same challenge as the author has pointed out - what our eyes…

There is also a very nice JS lib that does this: https://jariz.github.io/vibrant.js/
Post reply on HN