- LPU MCA Semester 1
- CAB107
- Unit 6
CAB107 · Unit 6: Natural language processing and vision
Computer vision fundamentals
10 practice questions · in the ETE syllabus
Key points
- Images are grids of pixel values from 0 to 255
- Convolution detects local patterns with filters
- Pooling reduces spatial size, keeping strong responses
- Max pooling takes the window maximum
Computer vision enables machines to interpret images and video. A digital grayscale image is stored as a grid of pixel intensity values, usually from 0 (black) to 255 (white); a colour image has three such channels, red, green and blue.
A convolutional neural network (CNN) is the standard model for images.
| Layer | What it does |
|---|---|
| Convolution | Slides small filters over the image to produce feature maps that detect local patterns such as edges |
| Activation (ReLU) | Adds non-linearity |
| Pooling | Reduces the spatial size of feature maps while keeping the strongest responses |
| Fully connected | Combines features into the final class scores |
Worked example: 2 x 2 max pooling with stride 2 on the 4 x 4 map with rows [1,3,2,1], [4,6,5,0], [7,2,9,8], [3,1,4,6] takes the maximum of each window: top-left 6, top-right 5, bottom-left 7, bottom-right 9, giving [[6, 5], [7, 9]]. Average pooling would give [[3.5, 2.0], [3.25, 6.75]].
import numpy as np
m = np.array([[1,3,2,1],[4,6,5,0],[7,2,9,8],[3,1,4,6]])
print(m.reshape(2, 2, 2, 2).max(axis=(1, 3)))
Typical tasks: classification, object detection and segmentation.
Exam trap: pooling shrinks the map but has no learned filters, and max pooling takes the largest value in each window, not the average.
Try two questions
How many bytes does an uncompressed 100 x 100 RGB image need at 8 bits per channel?
- 10,000
- 240,000
- 30,000
- 3,000
Show the answer
C. 100 x 100 x 3 channels x 1 byte = 30,000 bytes.
Why not A: 10,000 is the number of pixels, not the bytes.
Why not B: 240,000 counts bits rather than bytes.
Why not D: 3,000 loses a factor of 10.
What is the purpose of a pooling layer in a CNN?
- To increase the number of pixels so that the feature maps become larger and sharper
- To reduce the spatial size of the feature maps while keeping the strongest responses
- To label each of the input images with a class name before training starts
- To change the colour balance of the picture so that the network sees more contrast
Show the answer
B. Max pooling keeps the largest value in each window, reducing computation and adding small shift tolerance.
Why not A: Pooling shrinks the maps instead of enlarging them.
Why not C: Labelling is a human or training step.
Why not D: Pooling does not recolour the image.