An image is a signal
A grey image is a grid of numbers. Pixel x[m, n] holds the brightness at row m, column n. Our 6×6 image is dark (0) with a bright (9) square at the bottom right. Two indexes instead of one time.
Read row 3 from left to right: 0, 0, 9, 9, 9, 9. That is an ordinary discrete signal x[n], here a step. Every row and every column is a signal; the whole grid is a function of two variables.
Blur by convolution
An image filter is a small grid of weights, the kernel h[k, l]. The 3×3 box kernel has nine weights of 1/9, so each output pixel will be the average of a 3×3 patch of the image.
Lay the kernel on a patch, multiply each pixel by its weight and add the nine products: one output pixel. Slide one column and repeat. The kernel fits wholly in 16 places, so the output is 4×4.
Row 3 of the output reads 3, 6, 9, 9. The jump from 0 to 9 now climbs over three pixels. Averaging neighbours smooths sharp changes: that is blur, a 2-D moving average.
Frequency and speed
Along a row the box averages three neighbours. Its gain |1 + 2cos ω| / 3 is 1 for slow change (ω = 0), 0 at ω = 2π/3, and 1/3 for the fastest pixel-to-pixel flicker (ω = π). Fine detail fades.
The box kernel is a column [1 1 1]/3 times a row [1 1 1]/3. So blur every row, then every column: 6 multiplies a pixel instead of 9. Each output here is a(m)·a(n), with a = 1, 2, 3, 3.
Edges
Swap in the Sobel kernel. On the image it weighs the right column +1, +2, +1 and the left column −1, −2, −1, so it measures how fast brightness rises from left to right. Slide it again.
Where a patch is flat, right minus left is 0. Across the edge the sum is big: 9 + 18 + 9 = 36 in row 3. The output lights up exactly where the image jumps from dark to bright.
Along a row Sobel takes x[n+1] − x[n−1]. Its gain 2|sin ω| is 0 for flat areas (ω = 0) and peaks at 2 for ω = π/2: it keeps change and drops the constant, the opposite of blur.
In code
SciPy's convolve2d does the slide, multiply and add; "valid" keeps the 16 full-fit places. Convolution flips the kernel, so Sobel is written np.outer([1, 2, 1], [1, 0, −1]) and lands as −1 0 +1.
The working
# step 1/11 · pixels
x[m, n] m = row (0..5), n = column (0..5)
n=0 1 2 3 4 5
m=0 0 0 0 0 0 0
m=1 0 0 0 0 0 0
m=2 0 0 9 9 9 9
m=3 0 0 9 9 9 9
m=4 0 0 9 9 9 9
m=5 0 0 9 9 9 9
brightness on a 0..9 scale for easy sums
(8-bit images use 0..255)
Brightness uses a 0 to 9 scale so the sums stay small; 8-bit images store 0 to 255 per pixel and the arithmetic is the same. Every number and curve in the figure is computed from this model and matches numpy 2.5.4 with SciPy 1.18.1. "valid" convolution keeps only outputs that need no padding, so a 6×6 image gives 4×4. Other modes pad the border (with zeros, or a copy of the edge) to keep the size; the padded border then shows fake edges. Sources write the Sobel kernel with either sign, and some libraries slide the kernel without flipping it (correlation). The flip only changes the sign of the edge value here, never where the edge is. In the row plot the two sets of stems are nudged sideways a little so both stay visible; each belongs to the whole-number column n under it.