Simulated annealing process of 512x512, 6x3 bit Mona Lisa using different definition of "Energy",
where Energy = A*(squared neighbor pixel color differences) + B*(squared color differences to the target).
I used "l2-norm", namely (Ri-Rj)^2 + (Gi-Gj)^2 + (Bi-Bj)^2.
The ratio of coefficients A:B is, from top to bottom, 256:1, 64:1, 16:1, 4:1, 1:1, 1:4, 1:16, 1:64.
Images from right to left shows equilibrium state at higher to lower temperature.
The annealing process consists of standard Metropolis update as follows:
- Choose a pixel i
- Choose another pixel j, which modestly differs in color with i. To do this, one must maintain color-to-position pointers.
- Calculate energy change by swapping i and j (=dE).
- If dE<0, accept the change. Otherwise accept it with a probability exp(-dE/T) where T is a temperature.
Repeating this process drives the system to a Boltzmann distribution in which a state of energy E appears with probability proportional to exp(-E/T).
Starting from large T and gradually decreasing T drives the system to lower energy state.