Skip to content
AI360Xpert
Beta

Prewitt Operator Edge Detection

Prewitt senses brightness change with two plain kernels that weight every row equally. It is Sobel without the double-weighted center.

The Prewitt Gx kernel subtracts the left column from the right with equal rows, returning 300 on the same step where Sobel returns 400.
The Prewitt Gx kernel subtracts the left column from the right with equal rows, returning 300 on the same step where Sobel returns 400.

Why Does This Exist?

Before Sobel became standard, Prewitt offered the simplest gradient estimator that still smooths: differentiate along one axis, average along the other, weight all rows the same. On clean high-contrast images it finds the same boundaries as Sobel with slightly less arithmetic and no special center weight to remember.

It belongs with the first-order detectors under spatial filtering. Prefer Sobel on noisy images, and step up to second-order tools like the Laplacian when you need both sides of an edge.

Think of It Like This

Three judges with equal votes

Three judges score a dive with equal votes and the average stands. Sobel instead lets the middle judge vote twice, trusting experience over rookies. Equal votes are simpler to explain and fair when all judges are sober, which is clean images. When the rookies are drunk on noise, you want Sobel's weighted panel instead.

How It Actually Works

The Prewitt kernels replace Sobel's 1-2-1 profile with a flat 1-1-1 average:

Gx=[−101−101−101],Gy=[−1−1−1000111]G_x = \begin{bmatrix} -1 & 0 & 1 \\ -1 & 0 & 1 \\ -1 & 0 & 1 \end{bmatrix}, \quad G_y = \begin{bmatrix} -1 & -1 & -1 \\ 0 & 0 & 0 \\ 1 & 1 & 1 \end{bmatrix}

GxG_x subtracts the left column from the right with every row equal. Magnitude Gx2+Gy2\sqrt{G_x^2 + G_y^2} and direction arctan⁡(Gy/Gx)\arctan(G_y / G_x) follow exactly as in Sobel. Responses run weaker than Sobel's because no row is doubled.

Worked example

Reuse the dark-to-light step window:

[001000010000100]\begin{bmatrix} 0 & 0 & 100 \\ 0 & 0 & 100 \\ 0 & 0 & 100 \end{bmatrix}

Gx=(100+100+100)−0=300G_x = (100 + 100 + 100) - 0 = 300, against Sobel's 400 on identical input. Same edge, same direction, three-quarters the strength, and slightly more noise per unit signal since the center earns no extra trust.

Watch Out For

Noisier than Sobel on grain

Equal row weights smooth less along the averaging axis, so speckle leaks into the response more easily. The symptom is ragged edges where Sobel draws clean lines on the same noisy input. Switch to Sobel, or pre-blur, whenever grain is visible.

The Quick Version

  • Prewitt estimates gradients with two 3x3 kernels using flat 1-1-1 weights.
  • Magnitude and direction combine exactly as in Sobel.
  • Responses run weaker and noisier than Sobel on identical input.
  • It suits clean high-contrast images and quick teaching demos.
  • Default to Sobel for real noisy images.