Practical 1: Loading & Displaying Images

Open In Colab Run this practical in Google Colab

1. Aim

Objective

To learn how to load, display, and inspect digital images using OpenCV and Matplotlib.

2. Description / Theory
Theory: A digital image is a 2D matrix of pixel intensity values. For an 8-bit grayscale image, each pixel holds a value between 0 (black) and 255 (white). Understanding image representation is the foundation of all image processing.
3. Code

Part 1: Load and Display a Single Image

Load the selected image in grayscale and display it with its properties.

Part 2: Pixel Intensity Histogram

Visualize the distribution of pixel intensities. The histogram shows how many pixels have each intensity value (0-255).

Part 3: Display Multiple Images

Select up to 4 images from any chapter to compare in a grid.

4. Output 5. Analysis / Conclusion

Analysis Questions

  1. What does the shape of the image array represent? How do grayscale and color images differ in shape?
  2. Why do we specify cmap='gray' when displaying grayscale images? What happens if we don't?
  3. Compare the histogram distributions of two different images. What does a narrow histogram vs a wide histogram indicate about the image?