Module 2: Image Formation and Representation

1. Learning Objectives

2. Key Concepts

3. Digital Image Formation

Images are formed through a camera sensor, which captures light from a scene and converts it into a 2D grid of pixels. Each pixel stores intensity (grayscale) or RGB color values.

Digital Image = 2D array of pixels
Each pixel = [R, G, B] values (0–255)

4. Real-World Example

Medical imaging devices (e.g., MRI, CT scanners) produce grayscale or pseudo-color images. Proper understanding of resolution, pixel intensity, and format is crucial in analysis.

5. Hands-on Lab (OpenCV)

Use the following Colab-compatible code to load and convert images.

!pip install opencv-python-headless matplotlib

import cv2
import matplotlib.pyplot as plt
from google.colab import files
from google.colab.patches import cv2_imshow

# Upload an image
uploaded = files.upload()
img_path = next(iter(uploaded))

# Load image
image = cv2.imread(img_path)
cv2_imshow(image)

# Convert to grayscale
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
cv2_imshow(gray)

# Convert to HSV
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
cv2_imshow(hsv)

# Resize image
resized = cv2.resize(image, (300, 300))
cv2_imshow(resized)

6. Assignment

Objective: Apply and visualize different image formats and color models.

Due: End of Week 2