Computer Vision Starter · free course

Free course · Lesson 3 of 5

Basic Image Processing

In this lesson you will

  • Explain thresholding and histograms
  • Clean up an unevenly lit document photo

Image processing changes pixel values to make information easier to see or measure. A histogram counts how many pixels have each brightness, showing whether an image is too dark or has low contrast. Thresholding turns a grayscale image into black and white.

  • Global threshold: one cut-off for the whole image. Otsu's method chooses it automatically.
  • Adaptive threshold: a cut-off for each neighbourhood, so documents photographed in uneven light still give clean black text.
  • Morphology: erosion and dilation remove specks and fill gaps in black-and-white masks, which helps when counting seeds or grains.
Worked exampleCleaning a Photographed Form

Python

Python
import cv2 page = cv2.imread("fictional_form.jpg", cv2.IMREAD_GRAYSCALE)page = cv2.GaussianBlur(page, (5, 5), 0)               # reduce noise first clean = cv2.adaptiveThreshold(page, 255,                              cv2.ADAPTIVE_THRESH_GAUSSIAN_C,                              cv2.THRESH_BINARY, 31, 10)cv2.imwrite("form_clean.png", clean)                   # PNG: lossless for documents

Practice exercise

Photograph a printed page in uneven light and describe which parts a single threshold would turn black or white wrongly.

Key takeaways

  • Histograms show brightness and contrast
  • Adaptive thresholding handles uneven lighting
In the full program Module 3: Image Processing Fundamentals See how this topic is taught in depth, with practical activities and an assessment.

Free self-study lesson — no certificate. For the full instructor-led program, see registration options.