Computer Vision Basics
How computers 'see' — from pixels to convolutional neural networks
How Do Computers "See"?
To a computer, an image is just a grid of numbers. Each pixel has 3 values (Red, Green, Blue) ranging from 0 to 255.
A 1920×1080 image = 1920 × 1080 × 3 = 6,220,800 numbers to process!
An Image as Numbers
The Computer Vision Pipeline
1. Image Acquisition
Capture images through cameras, scanners, or datasets.
2. Preprocessing
Clean and prepare images:
- Grayscale conversion — reduce to one channel
- Resizing — standardize dimensions
- Normalization — scale pixel values to 0-1
- Noise removal — smooth out artifacts
3. Feature Extraction
Find meaningful patterns in the pixels:
- Edges — boundaries between objects
- Corners — distinctive points
- Textures — repeating patterns
- Shapes — circles, rectangles, lines
4. Analysis / Classification
"What is in this image?"
Convolutional Neural Networks (CNNs)
CNNs are the breakthrough that made modern computer vision possible. They learn to detect features automatically:
Input Image Feature Maps Classification
[224x224x3] ---> [Conv → Pool] ---> [Fully Connected] ---> "Cat (97%)"
How Convolution Works
A small filter (kernel) slides over the image, detecting patterns:
Edge Detection with Convolution
Check Your Understanding
What does a convolutional filter do in a CNN?
Real-World Applications
| Application | How It Works | Example |
|---|---|---|
| Face Recognition | CNN detects facial landmarks | Phone unlock |
| Medical Imaging | Detects tumors in X-rays/MRIs | Cancer screening |
| Self-Driving Cars | Detects lanes, signs, pedestrians | Tesla Autopilot |
| Agriculture | Identifies crop diseases from photos | Smart farming |
| Retail | Scans shelves for inventory | Amazon Go |
The Data Challenge
Computer vision models need lots of labeled data:
- A cat/dog classifier needs thousands of labeled images
- A medical diagnosis model needs expert-labeled scans
- Data augmentation helps: flipping, rotating, cropping existing images
Check Your Understanding
Why do computer vision models need so much training data?
Exercise
Write a Python function `detect_brightness(image_2d)` that takes a 2D list of pixel values (0-255) and returns: (1) the average brightness, (2) the location (row, col) of the brightest pixel, and (3) whether the image is 'dark' (avg < 85), 'medium' (85-170), or 'bright' (>170).
Key Takeaways
- Computers see images as grids of numbers (pixel values)
- CNNs use filters to automatically learn visual features
- Computer vision powers face recognition, medical imaging, self-driving cars, and more
- Data is critical — models need diverse, labeled examples
- Practical AI starts with understanding what the technology can (and cannot) do