Computer Vision · Beginner level

Beginner level · Module 3: Image Processing Fundamentals · Lesson 1 of 3

Geometric and Intensity Transformations

Learners resize, rotate, flip and adjust brightness and contrast, and see how each operation changes the pixel values.

In this lesson you will

  • Apply geometric transforms with OpenCV
  • Adjust brightness and contrast safely

Key concepts

cv2.resizecv2.rotate and warpAffinecv2.flipconvertScaleAbsclipping at 0 and 255

The lesson

Geometric transforms change where pixels are: cv2.resize changes size, cv2.rotate turns by 90-degree steps, cv2.getRotationMatrix2D with cv2.warpAffine rotates by any angle, and cv2.flip mirrors. These are also the building blocks of data augmentation later in the programme.

Intensity transforms change pixel values. new = alpha × old + beta raises contrast (alpha > 1) or brightness (beta > 0). cv2.convertScaleAbs(img, alpha=1.3, beta=20) does this and keeps values within 0–255.

Plain NumPy addition on uint8 arrays wraps around (250 + 10 becomes 4), which creates strange dark spots. Use OpenCV functions or convert to a larger type before arithmetic.

Step by step

  1. Resize, rotate by 15 degrees and flip one image, and display all versions.
  2. Brighten an underexposed photo with convertScaleAbs.
  3. Add 50 to a uint8 image with NumPy and with cv2.add and compare.
  4. Explain the difference you see.

Practice activity

Correct three poorly exposed produce photos and document the settings used.

Expected result: Visibly improved images and a note explaining the overflow problem.

Check your understanding

  1. What happens when you add 10 to a uint8 pixel of 250 with NumPy?

    Show answer

    It wraps around to 4.

  2. What does alpha control in new = alpha × old + beta?

    Show answer

    Contrast.

Further learning

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.