Latest Page Update: 23-09-2026
Exercise 6 - Pixel classification and object segmentation¶
In the first part of this exercise, we will use pixel classification to label pixels in an image. In the second part, pixel classification will be combined with BLOB analysis to segment the spleen from a computed tomography (CT) scan.
Learning Objectives¶
After completing this exercise, the student should be able to do the following:
- Describe the basic anatomy of a abdominal computed tomography scan including the liver, the spleen, the kidneys, bone and fat.
- Describe the concept of Hounsfield units as used in computed tomography scans.
- Describe the relationship between the Hounsfield unit corresponding to water and to air.
- Use pixel value mapping in
io.imshowto get optimal contrast for 16-bit medical scans. - Use a binary segmentation mask to extract pixel values corresponding to the pixels covered by the mask.
- Compute standard measures as the average value and the standard deviation of a selected set of pixel values.
- Visualize the histogram of a selected set of pixel values.
- Use the SciPy function
norm.pdfto sample values in a Gaussian distribution with a given mean and standard deviation. - Plot a histogram of a selected set of pixel values together with the best fitting Gaussian distribution.
- Visualize and evaluate the class overlap by plotting fitted Gaussian functions of each pre-defined class.
- Describe the concept of minimum distance classification.
- Compute class ranges using the concept of minimum distance classification.
- Apply a minimum distance classifier to an image and visualize the results.
- Visually evaluate the result of a pixel classification by visually comparing with a ground truth image.
- Compute the class ranges in a parametric classifier by visually inspecting the Gaussians representing each class and manually finding where they cross.
- Use
norm.pdfto find the class with the highest probability given a pixel value. - Use
norm.pdfto compute the class ranges by testing the probabilities with a set of pixel values. - Apply a parametric classifier to an image and visualize the results.
- Use morphological opening and closing to repair holes in objects and separate objects in a binary image.
- Use BLOB analysis to label objects in a binary image.
- Use BLOB feature based classification to identify an object in an image. For example the spleen in a computed tomography scan.
- Describe the concept of the DICE score.
- Compute the DICE score between two segmentations.
- Compute and evaluate the DICE score between a computed segmentation and a ground truth segmentation.
- Evaluate and optimize a segmentation algorithm based on visual results and DICE scores.
- Describe why it is important to split data into a training set, a validation set and a test set.
- Compute the final result of an algorithm on a test set and evaluate the results both visually and using the DICE score.
Installing Python packages¶
In this exercise, we will be using both scikit-image and SciPy. You should have these 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.
Data outline¶
For this exercise, there are one training image, three validation images and three test images. They have ground truth annotations of the spleen that we will use for training, validation and testing of our algorithm.