#MATL, 36 29 bytes
MATL, 36 29 bytes
5l$rtP+!kllII$r*O16tQ/XE'a'YG
This saves the result in file a.png
.
Replacing 'a'
by 2
in the code displays the image (scaled up) instead of saving a file:
5l$rtP+!kllII$r*O16tQ/XE2YG
Here's an example output:
###Explanation
Explanation
5l$r % 5×5 matrix of independent random values with uniform distribution
% on the interval (0,1)
tP+! % Duplicate, flip vertically, add, transpose. This gives a horizontally
% symetric matrix. Center column pixels are uniformly distributed on the
% interval (0,2). Rest have a triangular distribution on (0,2)
k % Round down. In either of the above cases, this gives 0 and 1
% with the same probability
llII$r % 1×1×3 array of independent random numbers with uniform distribution
% on (0,1). This is the foreground color.
* % Multiply the two arrays with broadcast. Gives a 5×5×3 array. Ones in the
% 5×5 array become the random foreground color. Zeros remain as zeros.
O % Push 0
16tQ/ % 16, duplicate, add 1, divide: gives 16/17, or 240/255
XE % Replace 0 by 16/17: background color
'a' % Push file name
YG % Write image to that file