# What does convolving an image with kernel [1 -2 1] do? How is it different than convolving with the derivative kernel [1 -1]?

What does convolving an image with the filter [1 -2 1] do? I see that it's a form of edge detection but it's also very similar to the results I get when convolving with the derivative kernel [1 -1] so I don't really see the difference between them

## 2 Answers

Both are high pass filters. Filtering with [1 -2 1] is the same as filtering with [1 -1] twice. So the longer kernel is a steeper high pass filter and emphasize the edges more.

• As mentioned by @Cris below, it's not general highpass filter, but is a discrete-time differentiator (first derivative or slope) and two differentiators (second derivative or curvature). Oct 1, 2022 at 21:45

Convolution with the [1 -1] kernel (A) is a derivative filter, which computes the finite difference approximation to the first derivative.

The [1 -2 1] kernel (B) is the result of convolving kernel A with itself. Thus, convolving an image with kernel A twice is the same as convolving with kernel B once. This means that convolution with kernel B is a second derivative filter, and computes the finite difference approximation to the second derivative.