Skip to content

Latest Page Update: 23-09-2026

Solution is now available! Download the full solution from here: Solution

Exercise3 - Pixelwise operations

In this exercise you will learn to perform pixelwise operations using Python.

Learning Objectives

After completing this exercise, the student should be able to do the following:

  1. Convert from unsigned byte to float images using the scikit-image function img_as_float
  2. Convert from float to unsigned byte images using the scikit-image function img_as_ubyte
  3. Implement and test a function that can do linear histogram stretching of a grey level image.
  4. Implement and test a function that can perform gamma mapping of a grey level image.
  5. Implement and test a function that can threshold a grey scale image.
  6. Use Otsu's automatic method to compute an optimal threshold that seperates foreground and background
  7. Perform RGB thresholding in a color image.
  8. Convert a RGB image to HSV using the function rgsb2hsv from the skimage.color package.
  9. Visualise individual H, S, V components of a color image.
  10. Implement and test thresholding in HSV space.
  11. Implement and test a program that can do perform pixelwise operations on a video stream

Installing Python packages

In this exercise, we will be using both scikit-image and OpenCV. You should have both libraries installed, else instructions can be found in the previous exercises.

We will use the virtual environment from the previous exercise (course02503).

Exercise data and material

Download the data you'll need for this exercise by clicking here: Data

Alternatively, you can also fetch the data for the whole course through the Image Analysis GitHub repository. See the Data and GitHub section for more information. If you're using Git, it may be wise run:

git pull

As this will fetch updates to the material, which may happen throughout the course.