home/ atoms/ convolution-kernel

Image convolution applies a kernel matrix to each pixel's neighbourhood to produce blur and sharpen filters

A convolution kernel is a small matrix (e.g., 3x3) of weights. For each pixel, the kernel is centred on it, each overlapping pixel’s value is multiplied by the corresponding weight, and all products are summed to produce the output pixel. All-positive weights create a low-pass (blur) filter; a mix of positive and negative values creates a high-pass (sharpen or edge-detect) filter. For all kernels, the sum of values should be 1 to preserve brightness. Edge pixels where the kernel extends outside the image require special handling (typically ignored or padded). This is the mathematical foundation for most image filters.

Examples

// Blur kernel (box filter) float[][] kernel = { {0.111, 0.111, 0.111}, {0.111, 0.111, 0.111}, {0.111, 0.111, 0.111} };

Assessment

Given a 3x3 kernel with all weights equal to 1/9, explain what visual effect it has and why; then describe a kernel that would detect horizontal edges.

“Patterns in the kernel numbers create different types of filters. If all the values for the kernel are positive, it creates what is called a low pass filter.”
corpus · processing-handbook-no-login-mirror-pdf-reas-and-fry · chunk 75