a day ago
- Image processing filters work using convolution matrices, where a small matrix (e.g., 3x3) is applied to each pixel and its neighbors to produce a new pixel.
- The process multiplies source pixel values by corresponding matrix elements, sums them, and divides by a divisor to compute the destination pixel.
- Different matrix values produce different effects: identity copies the image, lighten/darken adjust brightness, blur averages pixels, and sharpen uses weighted averages.
- Always write output to a separate destination buffer to avoid corrupting source pixels during computation.
- Edge handling can be done by cropping, assuming black/white, wrapping, or other methods; the demo masks edges with a border.