1 / 6
Initial image
Every color occupies a position in the square.
Interactive laboratory · Algebra and dynamical systems
Stretch, compress and reassemble an image: watch the mixing step by step
Imagine stretching dough, folding it and repeating. The baker’s transformation does something similar to the points of a square. Start with the four colored quadrants on the 8×8 grid, press “1 forward iteration” and watch what changes; then increase the resolution to see the mixing in finer detail.
Choose a demo image or upload your own. The default is four quadrants on an 8×8 grid.
The image is cropped centrally if not square and adapted to the chosen grid. At the end of the cycle it returns exactly to this gridded version, not to the full-resolution original file. Your file stays in your browser and is not sent to the server. Up to 32 iterations are kept.
Click the image to follow a point.
“Run N iterations” computes all selected steps immediately. Every intermediate image appears in the gallery below, where you can open it individually. “1 inverse iteration” runs the map backwards.
Each thumbnail is an actual computed state. Select one to revisit it and continue from there. The six panels below explain just one step.
The six panels explain the stages of just one iteration: they are not six iterations and do not show the return to the starting image. The first five are schematic; the sixth is the exact result of the first step on the chosen grid. Use the lab button to see the return.
1 / 6
Every color occupies a position in the square.
2 / 6
We conceptually separate the left half from the right half.
3 / 6
Each half is widened to the original width; the left half is shown here.
4 / 6
The two widened halves are shortened and shown separately so they remain visible.
5 / 6
The left half fills the upper band and the right half fills the lower band.
6 / 6
Pixels are permuted without losing any: neighboring rows interleave into new columns.
The schematic drawing illustrates the continuous map. On a finite grid we use a pixel permutation: it keeps N×N cells and neither invents nor removes colors after the initial crop.
Click the original image to see the point’s coordinates after every computed iteration and a schematic path in the square. The point follows the continuous formula, not the permutation of pixel centers.
No point selected.
This transformation of a square resembles a baker’s action: stretching dough, compressing it and stacking the parts. Repeated many times, a region that was initially compact is distributed into ever thinner strips.
Each half is stretched horizontally by a factor of 2 and compressed vertically by a factor of 1/2. The product of these factors is 1, so the continuous map preserves area. The halves fill the upper and lower parts of the square without overlap.
The rule uses no randomness: every point has a precisely determined next position. Nevertheless, two points with very close initial x coordinates can separate quickly, because their horizontal distance doubles until folding intervenes. This is sensitivity to initial conditions.
If x is written in base 2 as 0.b₁b₂b₃…, multiplying by 2 and removing any integer part produces 0.b₂b₃…: a binary shift, or Bernoulli shift. The first digit b₁ determines whether the point enters the upper or lower band and is recorded in the y coordinate.
A digital image contains finitely many pixels. Our discrete version is a reversible permutation: it preserves every pixel and must eventually revisit a previous state. Visual mixing is instructive, but it is neither encryption nor genuine randomness.
B(x,y) = (2x, y/2) if x < 1/2
B(x,y) = (2x−1, (y+1)/2) if x ≥ 1/2
Example: applying the rule to (0.3, 0.4) three times gives:
(0.3, 0.4) → (0.6, 0.2) → (0.2, 0.6) → (0.4, 0.3)