35
10
Introduction
A quixel is a quantum pixel. Similar to a classical pixel, it is represented with 3 integer values (Red, Green, Blue). However, quixels are in a super position of these 3 states instead of a combination. This super position only lasts until the quixel is observed at which point it collapses to one of three classical pixels; RGB(255,0,0)
, RGB(0,255,0)
and RGB(0,0,255)
.
Specification
- Representation
- Each quixel is represented as an array of 3 integers between 0 and 255, r, g and b respectively.
- Super Positions
- Each quixel is in a super position between the Red, Blue and Green states represented by R, G and B respectively.
- Observation
- When each quixel is observed it collapses into one of the three states. The probability of each classical state is
R = (r + 1) / (r + g + b +3)
,G = (g + 1) / (r + g + b + 3)
andB = (b + 1) / (r + g + b + 3)
. This way each classical state always as a non-zero probability of showing up.
- When each quixel is observed it collapses into one of the three states. The probability of each classical state is
- Input
- The function or program should take a image of quixels. How it does this is flexible. A filename, using a multi-dimensional array, etc are all acceptable.
- Output
- The function or program should produce an image of classical pixels. The data structure for this produced image is also flexible. Note that all of the pixels should be one of these three:
RGB(255,0,0)
,RGB(0,255,0)
andRGB(0,0,255)
- The output should not be deterministic; these are quantum pixels! The same input should result in different outputs.
- If your language has no way of generating a random number, you can take random bytes as input
- The function or program should produce an image of classical pixels. The data structure for this produced image is also flexible. Note that all of the pixels should be one of these three:
- Scoring
- This is code-golf so fewest bytes win.
Images
Mona Lisa by Leonardo da Vinci
Starry Night by Vincent van Gogh
Persistence of Memory by Salvador Dali
Teddy Roosevelt VS. Bigfoot by SharpWriter
Can the image filename / URL be an input argument? – Luis Mendo – 2016-08-30T22:06:45.823
@LuisMendo Yes, you can read from a file (or URL) – NonlinearFruit – 2016-08-30T22:09:14.283
My question is, can the name of that file / URL be an input? As opposed to hard-coded. So it wouldn't be included in the byte count – Luis Mendo – 2016-08-30T22:12:28.383
@LuisMendo Sorry. Yes, that is what I meant – NonlinearFruit – 2016-08-30T22:35:26.287
2That JPEG image of the Mona Lisa is causing 16x16 prominent visual artefacts on the output images. – wizzwizz4 – 2016-08-31T08:14:41.437
Where the hell is Lena when you need her? – YSC – 2016-08-31T13:55:39.003
1@wizzwizz4 Actually it isn't. It is the downsized preview that has artefacts. Click an image to view it full-sized. I suspect it is the particular width of only that image that gives the effect. – Adám – 2016-08-31T14:43:14.187
@Adám Oh, my bad. Thanks for correcting me. – wizzwizz4 – 2016-08-31T15:54:37.057
2You'll get better (visual) results if your quantum space was
RGBK
, whereK=255*3-R-G-B
, then make your quantum pixels be any one of the 4. (If K is selected, display (0,0,0). Extend your RGB equations in the obvious way, changing 3s to 4s, adding K when you would add R+G+B, etc). A blur after doing this should reconstruct a pretty decent noisy copy of the original. (K stands for black or key, in case you wondered) – Yakk – 2016-08-31T19:18:23.900If using a deterministic language (i.e. output = func(input)), is is alright if the input consists of the image followed by an infinite stream of random bytes? Some esolangs don't have a built-in RNG. Or are deterministic languages not allowed? – TLW – 2016-08-31T20:03:03.093
2@TLW If your language has no way of generating a random number, you can take random bytes as input – NonlinearFruit – 2016-09-01T02:17:05.443
@Yakk Have you tried it? Pure red (255,0,0) would give K=2×255, so a pure red picture would become two thirds black pixels and one third red. I.e. it would become very much darker. – Adám – 2016-09-01T23:39:13.150
@Adám You are right. The proper K is harder to calculate. Treating channels as values from 0 to 1 and ignoring the "+1 per channel" in the quantum equation as tiny, the average total pixel value ("brightness") after is (R^2 + B^2 + G^2)/(R+G+B), while before it was (R+G+B). To repair this we need to dim it by a factor of (R+G+B) / ( (R^2 + B^2 + G^2)/(R+G+B) ) = (R+G+B)^2/(R^2 + B^2 + G^2). Then scale that by (R+G+B). Sigh. – Yakk – 2016-09-02T00:51:17.173