Latest Page Update: 23-09-2026
Solution is now available! Download the full solution from here: Solution
Exercise 1 - Introduction to Image Analysis using Python¶
This exercise introduces image analysis in Python.
Learning Objectives¶
After completing this exercise, the student should be able to do the following:
- Install and use the Conda framework.
- Create and activate a conda virtual environment.
- Install Python packages in a virtual environment.
- Import Python packages.
- Read an image
- Extract information about the dimensions of the image and the pixel type.
- Display an image using both grey level scaling and using color maps.
- Display an image histogram.
- Extract individual bin counts and the bin edges from an image histogram.
- Describe the (row, col) coordinate system used in scikit-image.
- Inspect pixel values in an image using (row, column) pixel coordinates.
- Use NumPy slicing to extract and change pixel values in an image.
- Compute a binary mask image based on an input image.
- Use a binary mask image to extract and change pixel values in an image.
- Inspect RGB values in a color image.
- Extract and change RGB values in a color image.
- Transfer images from a camera or a mobile phone to the computer so it can be used in Python image analysis scripts.
- Rescale an image, where the width and height of the image are scaled with the same factor.
- Resize and image, where the width and height of the image are scaled with the different factors.
- Transform an RGB image into a grey-level image using
rgb2gray. - Transform a gray-level image into an RGB image
gray2rgb. - Transform a pixel representation from floating points to unsigned bytes using
img_as_ubyte. - Visualize individual color channels in an RGB image.
- Change and manipulate individual color channels in an RGB image.
- Sample and visualize grey scale profiles from gray scale images using
profile_line. - Create 3D visualizations of an image, so it is seen as a height map.
- Read individual DICOM files and get information about the image from the DICOM header.
- Access the raw pixel data of individual DICOM files.
- Visualize individual DICOM files and select appropriate gray value mapping limits to enhance contrast.
Conda, VS Code, virtual environments and setting up Exercises¶
See the setup guide for instructions on how to install and setup Conda, VS Code and virtual environments. The guide also includes some navigation tips and tricks in VS code for an easy start and in the end, setup to start the exercises.
Getting The Data¶
Start by creating an exercise folder where you keep your data, Python scripts and/or Notebooks. Download the data you'll need for this exercise by clicking here: Data
Place the data into the folder you just created.
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.