Loading and Displaying Images
Introduction: Building Our First Workbench Tool
Welcome to the course! Over the next four units, we will build a complete panorama stitcher from scratch using Python. We will learn how to take multiple overlapping photos and blend them into one seamless wide-angle image.
Before we can perform any complex math or image stitching, our first step is to build a reliable workbench tool. We need a way to load an image, inspect its properties, and view it on our screen. This basic setup provides a dependable way to check our inputs before we run any advanced algorithms.
As a sneak peek, you will be able to take multiple images like these:
And recreate a big image looking like this:

To do this, we will use OpenCV (imported as cv2), which is one of the most popular and powerful computer vision libraries in the world. While you will need to learn how to install OpenCV on your own personal computer, you do not need to worry about that right now. In the CodeSignal environment, OpenCV and all other necessary tools come pre-installed and ready to use!
Also, you will have a small Image Gallery to help you debug your work along the exercises!
What is a Digital Image?
Before we dive deeper into the code, it is important to understand what a digital image actually is. To our eyes, it’s a photograph, but to a computer, it is a three-dimensional grid of numbers, also known as a multidimensional array.
- Pixels: The grid is made up of individual dots called pixels. Every pixel in the image contains numerical data that tells the computer what color to display.
- Spatial Dimensions: The first two dimensions of this grid represent the height and width of the image (the number of pixels stacked vertically and horizontally).
- Channels: The third dimension represents color channels.
Understanding Color Channels
In digital imaging, colors are created by mixing primary colors of light. Most images use the RGB color model, which consists of three channels: Red, Green, and Blue.
Think of these channels as three separate grayscale layers. When you stack them on top of each other, they blend to create a full-color image. Each pixel in a standard 8-bit image has a value for each channel ranging from 0 (no intensity) to 255 (full intensity). For example:
- A pixel with values
(255, 0, 0)in RGB is pure Red. - A pixel with
(0, 0, 0)is Black (all lights off). - A pixel with
(255, 255, 255)is White (all colors at maximum intensity).

The OpenCV Difference: While the world usually uses RGB, OpenCV reads images in BGR (Blue-Green-Red) order. This means the first layer of data is Blue, the second is Green, and the third is Red. We must keep this in mind whenever we manipulate individual color values!
