Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!
Practice
Practice the fundamental concepts from this module: loading images, reading their properties, and exploring pixel values.
15 min•By Priygop Team•Updated 2026
Mini Project: Image Inspector
Mini Project: Image Inspector
import cv2
import numpy as np
def inspect_image(image_path):
"""
A complete image inspector — practice applying Module 1 concepts.
"""
# Load the image
image = cv2.imread(image_path)
if image is None:
print(f"Error: Could not load image from '{image_path}'")
print("Make sure the file path is correct and the image exists.")
return
print("=" * 45)
print("IMAGE INSPECTION REPORT")
print("=" * 45)
# Basic dimensions
height, width, channels = image.shape
print(f"Width: {width} pixels")
print(f"Height: {height} pixels")
print(f"Channels: {channels}")
print(f"Total pixels: {width * height:,}")
print(f"Memory used: {image.nbytes:,} bytes")
print(f"Data type: {image.dtype}")
# Colour channel analysis
b, g, r = cv2.split(image)
print()
print("COLOUR CHANNEL STATISTICS")
print(f" Blue — min: {b.min():3d}, max: {b.max():3d}, mean: {b.mean():.1f}")
print(f" Green — min: {g.min():3d}, max: {g.max():3d}, mean: {g.mean():.1f}")
print(f" Red — min: {r.min():3d}, max: {r.max():3d}, mean: {r.mean():.1f}")
# Grayscale analysis
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
print()
print("GRAYSCALE ANALYSIS")
print(f" Min brightness: {gray.min()}")
print(f" Max brightness: {gray.max()}")
print(f" Mean brightness: {gray.mean():.1f}")
# Sample some pixels
print()
print("SAMPLE PIXELS (row, col) -> [B, G, R]")
for row, col in [(0, 0), (height//2, width//2), (height-1, width-1)]:
print(f" ({row}, {col}) -> {image[row, col]}")
print("=" * 45)
# Run the inspector
# Replace with a real image path on your computer
inspect_image("your_image.jpg")Diagram
Loading diagram…
Machine Learning follows a structured pipeline from data to deployment
Your Turn
Your TurnHTML
HTML Editor
✓ ValidTab = 2 spaces
HTML|22 lines|675 chars|✓ Valid syntax
UTF-8
Key Takeaways from Module 1
- Computer Vision teaches computers to understand images and video using numerical pixel data
- A digital image is a grid of pixels — each pixel is one or more numbers representing colour
- Grayscale images: one number per pixel (0–255). Colour images: three numbers per pixel (B, G, R)
- OpenCV stores images in BGR channel order — not RGB. Remember this to avoid colour bugs
- Image shape in NumPy/OpenCV is (height, width, channels) — height comes first
- Resolution is the total pixel count (width × height). Higher resolution = more detail but more memory
- Every CV operation is ultimately a mathematical operation on these pixel numbers
Key Takeaways
- Practice the fundamental concepts from this module: loading images, reading their properties, and exploring pixel values.
- Computer Vision teaches computers to understand images and video using numerical pixel data
- A digital image is a grid of pixels — each pixel is one or more numbers representing colour
- Grayscale images: one number per pixel (0–255). Colour images: three numbers per pixel (B, G, R)