Quixels - Quantum Pixels 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) and B = (b + 1) / (r + g + b + 3). This way each classical state always as a non-zero probability of showing up. 

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) and RGB(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

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
Dyalog APL, 23 21 19 bytes

Takes table of (R, G, B) triplets.
Inspired by miles' algorithm
Returns table of indices into {(255, 0, 0), (0, 255, 0), (0, 0, 255)}. Horribly wasteful.
(?∘≢⊃⊢)¨(⊂⍳3)/¨⍨1+⊢

(
 ?∘≢ random index
 ⊃ selects
 ⊢ from
)¨ each of
(
 ⊂ the entire
 ⍳3 first three indices
)/¨⍨ replicated by each of
1+⊢ the incremented triplets
TryAPL!

Old version
Returns table of 0-based indices into {(255, 0, 0), (0, 255, 0), (0, 0, 255)}
{+/(?0)≥+\(1+⍵)÷3++/⍵}¨

{...}¨ for each quixel in the table, find the:
 +/ the sum of (i.e. count of truths of)
 (?0)≥ a random 0 &lt; number &lt; 1 being greater than or equal to
 +\ the cumulative sum of
 (1+⍵)÷ the incremented RGB values divided by
 3+ three plus
 +/⍵ the sum of the quixel
Note: Dyalog APL lets you chose between the Lehmer linear congruential generator, the Mersenne Twister, and the Operating System's RNG¹ ².
For example, the image:
┌──────────┬──────────┬───────────┬───────────┬─────────┐
│52 241 198│148 111 45│197 165 180│9 137 120  │46 62 75 │
├──────────┼──────────┼───────────┼───────────┼─────────┤
│81 218 104│0 0 255   │0 255 0    │181 202 116│122 89 76│
├──────────┼──────────┼───────────┼───────────┼─────────┤
│181 61 34 │84 7 27   │233 220 249│39 184 160 │255 0 0  │
└──────────┴──────────┴───────────┴───────────┴─────────┘

can give
┌─┬─┬─┬─┬─┐
│1│0│2│2│1│
├─┼─┼─┼─┼─┤
│2│2│1│1│2│
├─┼─┼─┼─┼─┤
│0│2│1│2│0│
└─┴─┴─┴─┴─┘

Notice how the three &quot;pure&quot; quixels collapsed to their respective colors.
TryAPL online!