← Image Processing for EveryoneToolsInVisionLearning Center
Enhancement and Filtering · Lesson 7

Convolution: Let Neighboring Pixels Help

One noisy pixel does not tell the whole story.

Watch the lesson

Convolution: Let Neighboring Pixels Help explained visually

1:34

One noisy pixel does not tell the whole story. English captions are optional and start off. The complete transcript follows the written lesson.

Lesson overview

What you will learn

One noisy pixel does not tell the whole story.

  1. A moving neighborhood
  2. Weights define the operation
  3. Borders need a rule
  4. A worked example
01

A moving neighborhood

One bright speck sits in the middle of a smooth part. We can ask its neighbors whether it looks unusual. A small array of weights, called a kernel, moves across the image. At each position, it combines nearby pixel values to produce one output. The weights decide whether we smooth the speck, emphasize a change, or detect a particular direction.

02

Weights define the operation

Take three neighboring values: ten, twenty, and thirty. Give each a weight of one third. Their output is twenty. An averaging kernel uses that idea across the image, but repeated smoothing can weaken our real scratch too. A directional kernel may subtract values on opposite sides, giving negative intermediate results that we shouldn't clip before analysis.

03

Borders need a rule

At the border, the requested neighborhood extends beyond the image. We have to choose a rule, such as zero padding, edge repetition, or reflection. Different choices change the answer near that border. Also note that strict mathematical convolution flips the kernel; many image libraries instead perform cross-correlation and call it convolution. Symmetric kernels hide this difference, while directional ones may not.

04

A worked example

Draw one tiny neighborhood and compute it by hand before trusting the full image. Next, we'll choose a filter according to the noise we actually have.

Worked example

For a simple one-dimensional example, average neighboring intensities 10, 20, and 30 using three equal weights. Their sum is 60, and dividing by three gives 20. Replacing the middle value with this average smooths a local fluctuation, but repeated smoothing also weakens fine detail.

Knowledge check

Quick check: test your understanding

Try it yourself: Find the average of 10, 100, and 10. Explain why the output is affected by the large central value.

Check the reasoning

The average is 40. Averaging gives every sample influence, so a single extreme value can pull the output away from the surrounding level.

Why can two implementations of the same kernel differ near the image edge?

They may use different padding or border-handling rules.

How would you solve the practice case?

The average is 40. Averaging gives every sample influence, so a single extreme value can pull the output away from the surrounding level.

What does the worked example show?

For a simple one-dimensional example, average neighboring intensities 10, 20, and 30 using three equal weights. Their sum is 60, and dividing by three gives 20. Replacing the middle value with this average smooths a local fluctuation, but repeated smoothing also weakens fine detail.

Further reading

Digital Image Processing, 4th edition — Rafael C. Gonzalez and Richard E. Woods.

Original ToolsInVision teaching examples. Editorial approach · Suggest a correction

Accessible referenceLesson 7 transcript203 words · Video transcript · Matches the published narration and captionsOpen transcript

One bright speck sits in the middle of a smooth part. We can ask its neighbors whether it looks unusual. A small array of weights, called a kernel, moves across the image. At each position, it combines nearby pixel values to produce one output. The weights decide whether we smooth the speck, emphasize a change, or detect a particular direction.

Take three neighboring values: ten, twenty, and thirty. Give each a weight of one third. Their output is twenty. An averaging kernel uses that idea across the image, but repeated smoothing can weaken our real scratch too. A directional kernel may subtract values on opposite sides, giving negative intermediate results that we shouldn't clip before analysis.

At the border, the requested neighborhood extends beyond the image. We have to choose a rule, such as zero padding, edge repetition, or reflection. Different choices change the answer near that border. Also note that strict mathematical convolution flips the kernel; many image libraries instead perform cross-correlation and call it convolution. Symmetric kernels hide this difference, while directional ones may not.

Draw one tiny neighborhood and compute it by hand before trusting the full image. Next, we'll choose a filter according to the noise we actually have.