Identity
The identity kernel leaves the image unchanged. Every output pixel is exactly the input pixel beneath the centre cell. A useful reference point.
A small matrix is the engine behind sharpen, blur, emboss, and edge detection. It is also the first move inside every convolutional neural network. Here is how it works, one pixel at a time.
Below is a small grayscale picture of a face. Each square is one pixel, and each number is its brightness, somewhere between 0 for black and 255 for white. The grid on the right is the same data, drawn at its real size, so you can see what the numbers describe.
Slide the lens across the image. For every position, multiply each of the nine pixels under the lens by the matching weight in the kernel, then add the products. That single number is one pixel of the new image.
The corner pixel only has three real neighbours, not eight. We have to invent the missing five somehow. Two common answers, shown to the right. The walkthrough above zeroes them out, which shows up as a black ring on the new image. Cleaner code, sharper border. The other option is to extend the existing edge outward, which keeps the picture intact at the cost of a little soft halo.
Pick a kernel, then move across the source. The lens follows your cursor and the matching output pixel lights up on the right.
Hover the source.
Sharpen amplifies local contrast. The strong positive centre boosts the current pixel while the negative neighbours subtract anything that already looks similar, so edges read louder.
The identity kernel leaves the image unchanged. Every output pixel is exactly the input pixel beneath the centre cell. A useful reference point.
Sharpen amplifies local contrast. The strong positive centre boosts the current pixel while the negative neighbours subtract anything that already looks similar, so edges read louder.
A box blur averages each pixel with its eight neighbours. Differences shrink, transitions soften, fine grain disappears.
divide by 9
Emboss leans on a directional difference, top left versus bottom right, then adds a mid-grey bias so light comes from one corner. The image looks pressed into metal.
add 128
Sobel kernels isolate change in one direction. This one responds to horizontal change, so vertical edges glow and flat regions fall to mid-grey.
add 128
Outline subtracts every neighbour from a pixel scaled up eight times. Where neighbours match, the result is zero, so flat regions go black and only sharp transitions survive.