Web Simulation 

 

 

 

 

1D Convolution Visualization Tutorial 

1D convolution is the operation that combines two discrete signals — an input x[n] and a kernel h[n] — into a third signal y[n] by sliding the kernel across the input and computing a weighted sum at every position. It is the fundamental building block of digital filtering, image processing, and the convolutional layers in deep learning.

This tutorial animates that sliding operation. The top panels show the input signal (blue) and kernel (red) as stem plots. The bottom panel runs the kernel across the input position by position, accumulating the output (yellow) one sample at a time. A green rectangle highlights the current overlap window so you can see exactly which input samples contribute to each output value.

Mathematical Foundation

Discrete 1D convolution of input x[n] with kernel h[n] produces output y[n]:

y[n] = Σk x[k] · h[n − k]

For each output index n, the kernel is flipped (the h[n−k] form), shifted to align with position n, multiplied element-wise with the overlapping input samples, and summed.

Kernel Flipping

The h[n−k] in the formula reverses the kernel's sample order before it slides. This distinguishes convolution from correlation, which uses h[n+k] (no flip).

See it directly: select the Asymmetric (Ramp) kernel. The top-right panel shows the kernel as defined: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7] (small → large). In the animation panel below, the same kernel slides as [0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1] (large → small). The flip is built into the convolution math; symmetric kernels (Box, Gaussian) look identical either way which is why the effect is invisible for those presets.

Output Length and Boundaries

If the input has length L and the kernel has length M:

output length = L + M − 1

The extra M − 1 samples come from the partial overlaps at each end — the "transient regions" where the kernel is just entering the input on the left or exiting on the right. The simulator shows the full convolution including these transients. For a typical 20-sample input with a 5-sample kernel, the output is 24 samples long.

Kernel Effects

Each kernel preset implements a different linear operation. The available presets group naturally:

Kernel

Length

Effect

Box / Average

5

Uniform smoothing — running mean

Gaussian

5

Smooth bell-shaped low-pass

Low Pass Filter

9

Bell-shaped Gaussian, stronger low-pass

Smoothing

5

Center-weighted smoothing

Edge Detection

5

Coefficients [−1, −1, 0, 1, 1] — first-difference style

High Pass Filter

11

Passes high frequencies, blocks low

Band Pass Filter

11

Keeps mid-range frequencies only

Differentiator

11

[0, 1, −1, 0, ...] — discrete derivative

Asymmetric (Ramp)

7

Ramp [0.1 … 0.7] — makes the flip visible

Ringing

11

Exponentially decaying with alternating signs

Scaled Delay

11

Single impulse at the end — pure delay + gain

Reflection

28

Main pulse + delayed echo — echo simulation

Impulse response trick: when the input is an Impulse (single spike), the output is exactly the (flipped) kernel itself. This is why "kernel" and "impulse response" are interchangeable terms in linear systems theory — the output of any LTI system fed an impulse is its kernel.

Simulation

The interactive simulator is below. Pick an input signal and a kernel from the dropdowns, then either step manually or hit Run to let the kernel slide automatically. Watch the output stem plot accumulate sample by sample as the green overlap window moves across.

Usage

  1. Pick an input: Square Pulse, Sine Wave, Triangle, Impulse, etc. The Impulse is the cleanest way to see what a kernel actually does, because the output IS the kernel.
  2. Pick a kernel: start with Box / Average to see smoothing, then try Edge Detection to see derivatives, then Asymmetric (Ramp) to see the flip.
  3. Run or step: click Run to let the animation play, or use Step Fwd / Step Back to walk one output sample at a time. The current sample index is shown as "n=X" below the output plot.
  4. Watch the green window: at every position it shows which input samples are being multiplied by the (flipped) kernel and summed.
  5. Reset to clear the output and start over with the current input + kernel.

Parameters

Parameter

Symbol

Role

Input signal

x[n]

Discrete sequence to be filtered. Length L = 20–101 depending on preset.

Kernel

h[n]

Filter coefficients applied at every position. Length M = 5–28 depending on preset.

Output signal

y[n]

Convolution result, length L + M − 1.

Current position

n

The output sample index currently being computed (shown as "n=X").

Overlap window

Green rectangle covering the M input samples currently under the kernel.

Key Concepts

  • Sliding dot product: convolution is fundamentally a weighted sum over a sliding window. The window is the (flipped) kernel; the weights are its coefficients.
  • Kernel = impulse response: any LTI (linear time-invariant) system is fully characterized by what it does to an impulse. The output of "impulse input + arbitrary kernel" is the kernel. This is why digital filters are usually specified by their impulse response.
  • Linearity and superposition: the response to x = x1 + x2 equals the sum of the individual responses. The Double Square Pulse preset demonstrates this directly.
  • Convolution vs correlation: identical sliding/summing logic, but convolution flips the kernel first. For symmetric kernels (Box, Gaussian) the distinction is invisible; for asymmetric ones it matters.
  • Boundary transients: the first M − 1 and last M − 1 output samples are partial overlaps and tend to ramp up / down even if the input is constant. Production filters often discard these.

Limitations

  • 1D only — no images or video. The same mechanism extends to 2D and 3D but isn't shown here.
  • Real-valued samples only. No complex-valued signals (so no separable I/Q processing).
  • "Full" convolution mode only — output length L + M − 1. There's no toggle for "same" (length L) or "valid" (length L − M + 1) modes that production libraries provide.
  • No zero-padding choices; the signal is treated as zero outside its defined range.