Gaussian blur — computer vision in the browser

Gaussian blur smooths an image by averaging each pixel with its neighbours weighted by a bell curve — a fundamental computer-vision preprocessing step (denoising before edge detection or thresholding). OpenCV’s cv2.GaussianBlur takes a kernel size; bigger means smoother. Run it live and compare kernel sizes.

Gaussian blur — example output

Example code (Python / OpenCV)

"""
Gaussian blur

Gaussian blur smooths an image by averaging each pixel with its neighbours weighted by a bell curve — a fundamental computer-vision preprocessing step (denoising before edge detection or thresholding). OpenCV’s cv2.GaussianBlur takes a kernel size; bigger means smoother. Run it live and compare kernel sizes.
"""

import cv2
import requests
import numpy as np

# A real photo, fetched live from the web — nothing is uploaded
url = "https://images.unsplash.com/photo-1464820453369-31d2c0b651af?w=480&q=70"
# no-cache: always fetch a fresh copy so a stale browser-cache entry can't break decoding
resp = requests.get(url, headers={"Cache-Control": "no-cache"})
img = cv2.imdecode(np.frombuffer(resp.content, np.uint8), cv2.IMREAD_COLOR)

cv2.imshow("original", img)

# Gaussian blur — a bigger (odd) kernel means stronger smoothing
cv2.imshow("blur 5x5", cv2.GaussianBlur(img, (5, 5), 0))
cv2.imshow("blur 15x15", cv2.GaussianBlur(img, (15, 15), 0))   # try (9,9) or (21,21)

More computer-vision techniques →