Machine Learning Β· Chapter 38 of 40

Image Basics

An image is a grid of PIXELS. Colour images have 3 CHANNELS (RGB). Classic ML uses hand-crafted features (edges, histograms); deep learning uses CNNs (Convolutional Neural Networks).

CNNs learn features automatically.

Example 1 (python)
import numpy as np
img = np.random.rand(28, 28, 3)  # HxWxChannels
print(img.shape)
Output
(28, 28, 3)

Represent as a 3D array.

Example 2 (python)
# Simple CNN with Keras
# tf.keras.layers.Conv2D(32, (3,3), activation='relu')

Convolution filters detect local patterns.

Key points

  • Images are grids of pixels.
  • Colour has 3 channels (RGB).
  • CNNs learn image features automatically.
  • Always normalize pixel values (0–1).
πŸ’‘ Note: Always divide pixel values by 255 to scale them to [0, 1] before feeding a neural net.

πŸ“ Quick Quiz

1. A colour image has:

2. CNNs learn:

3. Normalize pixels by: