Image Convolution & Filter Lab
Image filters are built from a tiny grid of numbers called a kernel. Slide that kernel over every pixel, multiply and sum, and you get blur, sharpen, edge detection, and more. Pick a sample image and a kernel, then hover any pixel to watch the convolution happen one neighborhood at a time.
Guided Experiment: Which kernel finds vertical edges, and what does Sobel Y do instead?
You will filter the vertical-edge sample. Predict which kernel produces a strong response right at the edge column, and predict what happens when you switch from Sobel X to Sobel Y on the same image.
Write your hypothesis in the Lab Report panel, then click Next.
Controls
Editing any cell switches to a custom kernel and recomputes the output. Pick a preset above to return to a named filter.
Input
48 × 48 pixelsFiltered output
same sizeHover the input image to inspect a pixel. The amber box marks the 3 × 3 neighborhood and the teal box marks the pixel being computed in both images.
Active kernel: Gaussian blur
A weighted blur that favors the center. Smooths noise while keeping a natural look.
Hover a pixel on the input image to see its 3 × 3 neighborhood multiplied by the kernel and summed into the output value.
What this filter does
Filtering the Circle sample with the Gaussian blur kernel.
This is a smoothing kernel. It averages each pixel with its neighbors, which softens edges and reduces noise.
Data Table
(0 rows)| # | Sample | Kernel | Effect |
|---|
Reference Guide
What a Convolution Is
A convolution slides a small grid of weights, the kernel, across the image. At each pixel it lines the kernel up with the pixel and its neighbors, multiplies matching cells, and adds the products into a single new value.
- Kernel. A small matrix of weights, here 3 × 3.
- Neighborhood. The pixel plus the 8 around it.
- Output. The weighted sum, written back into a new image.
Repeating this for every pixel produces a filtered image the same size as the original. The weights alone decide what the filter does.
Common Kernels
A handful of classic kernels cover most of image processing. Their weights tell you at a glance whether they smooth, sharpen, or detect change.
- Box and Gaussian blur. Positive weights that average and smooth.
- Sharpen. A large positive center against negative neighbors.
- Laplacian edge detect. A zero-sum kernel that responds to change.
- Sobel X and Sobel Y. Gradient kernels for vertical and horizontal edges.
- Emboss. Turns gradients into a lit relief effect.
Normalization, Bias, and Borders
Two small details keep the output looking right. The divisor normalizes the sum so brightness is preserved, and the bias shifts results into a visible range.
- Divisor. Usually the kernel sum, so a blur of all-equal weights averages.
- Bias. Added after dividing, often 128 for zero-sum kernels so flat areas read as mid-gray.
- Borders. Edge pixels lack full neighbors, so this lab clamps to the nearest edge value.
Without a bias, a zero-sum edge kernel would map every flat region to black. The bias lifts it to gray so the edges stand out against it.
From Filters to Neural Networks
These same operations power both classical image editing and modern computer vision. The kernel is the unit that scales up into deep networks.
- Image processing. Blur, sharpen, denoise, and edge maps in any photo editor.
- Feature detection. Sobel and Laplacian kernels find edges and corners.
- Convolutional neural networks. Each layer learns its own kernels from data instead of using fixed ones.
In a convolutional network the weights you edit by hand here are learned during training, so the network discovers the filters that best solve its task.