previndexinfo

code guessing, round #101, stage 1 (writing)

started at . submit by

specification

I've been trying to sleep better lately, so can you help me filter blue light? submissions may be written in any language.

the blue light spectrum is a strong signal to the human body that it is currently daytime, and it significantly impacts the circadian rhythm and melatonin production. it is thus a common desire to decrease one's exposure to it at night, especially if one already has sleep issues. as computer screens (along with white lightbulbs) are among the biggest household sources of blue light at night, a class of software exists to filter out blue and shift the colours displayed on the screen to warmer tones with more red.

filtering the whole screen is a bit much, so I won't ask you to do that. starting simple is always best, so let's just do one image. there are multiple ways to interpret "filtering out blue" and multiple ways to go about it. I will briefly go over one; however, this problem is open-ended and any solution is admissible.

colour temperature is a parameter based on the colour of light emitted by an idealized black body at a certain temperature, usually given in Kelvin. 1,000K is quite red, while 10,000K is quite blue. the path the colour takes as the temperature changes is called the Planckian locus. with a lookup table or approximation of this locus, you can find the corresponding colour to a temperature in a colour space such as sRGB. once you take the difference between a "reference" like 6,500K (the D65 standard used by sRGB; 6,500K corresponds to rgb(1.0, 1.0, 1.0)) and a warmer "target" like 2,400K, you can now add that difference to any colour to get an equivalent calibrated for a warmer white point. (actual blue light filter software uses the difference to compute gamma settings for each channel for the same effect.)

your challenge, given an image, is to return the same image with less blue in it. it is not acceptable to return an image with more blue in it. as any language is allowed, there is no fixed API.

entries

2 entries have been received so far.

submit