Skip to content

Convolution Playground

Draw an 8×8 image, edit a 3×3 kernel, and sweep it across the image to build a feature map

1. The playground

The left grid is an 8×8 image. Blue means 1 and dark means 0. Choose Draw or Erase, then drag across the grid to paint. The right grid is the feature map produced by the 3×3 kernel in the middle.

Move the kernel with the arrow buttons, the position slider, or by clicking a feature-map cell. Sweep visits every valid position. The kernel values are editable; the presets give you a vertical edge, horizontal edge, blur, sharpen, and identity filter to start from.

Every feature-map value is computed from the current image and kernel. Nothing on the canvas is pre-drawn.

2. What to notice

  • The white box is the receptive field. The kernel reads exactly the 3×3 patch under it. Move the kernel and the patch moves.
  • Positive and negative responses are different. Orange cells are positive, blue cells are negative, and dark cells are near zero. The sign records which side of the pattern is brighter.
  • The output is smaller. An 8×8 image with a 3×3 kernel has 6×6 valid positions. There is no padding in this playground.
  • One kernel, many positions. The same nine weights visit every position. Change one kernel value and every feature-map cell can change.
  • The map is not the image. A feature map records how strongly one pattern appears at each location. A real layer has many kernels, so it produces many channels.

3. The math

At each valid position, the kernel and the image patch are multiplied cell by cell and added:

One output value

The output size for this valid convolution is:

Output size

With n = 8, k = 3, p = 0, and s = 1, the output is 6. The playground uses the same valid sliding window for every position.

The kernel has 9 weights. A dense hidden layer with 36 units reading all 64 pixels would have 2,340 parameters. The kernel shares its 9 weights across positions, which is the point of a convolutional layer.

Kernel parameters
Dense-layer parameters

Deep learning libraries call this operation convolution, but they usually do not flip the kernel. Mathematically it is cross-correlation. The lesson and the Fourier transform chapter explain the difference.

4. What is simplified

The playground uses a binary 8×8 image, one 3×3 kernel, and a valid stride-1 convolution. It does not train the kernel, apply a ReLU, add a bias, use padding, or pool. Those operations are covered in the lesson and are part of a real CNN.

The canvas is a teaching tool, not an image editor. A real image has more pixels, more channels, and values that are not just 0 and 1. The arithmetic is the same; the scale is not.

5. Related lessons

The lesson builds the kernel, the feature map, pooling, and the parameter argument from the beginning.

Site soundtrack