How Computers See Images
Computers do not 'see' images the way humans do. They see grids of numbers. Understanding this helps you understand how AI processes images.
12 min•By Priygop Team•Updated 2026
Images as Numbers
To a computer, an image is just a grid of numbers. Each number represents the brightness of one pixel.
For a grayscale image:
- Each pixel is one number from 0 (black) to 255 (white)
- A 28x28 grayscale image is a grid of 784 numbers
For a color image (RGB):
- Each pixel has three numbers: red, green, blue (each 0 to 255)
- A 1920x1080 color photo contains 1920 x 1080 x 3 = 6,220,800 numbers
The neural network processes these numbers to find patterns.
Diagram
Loading diagram…
Deep Learning ⊂ Machine Learning ⊂ Artificial Intelligence
Representing an Image in Python
Representing an Image in Python
# Representing images as number grids
# A tiny 5x5 grayscale image (0 = black, 255 = white)
image_5x5 = [
[ 0, 0, 255, 0, 0], # top
[ 0, 255, 255, 255, 0], # upper middle
[255, 255, 255, 255, 255], # center (bright)
[ 0, 255, 255, 255, 0], # lower middle
[ 0, 0, 255, 0, 0], # bottom
]
print("5x5 Image as numbers (0=black, 255=white):")
for row in image_5x5:
formatted = " ".join(f"{val:3}" for val in row)
print(f" {formatted}")
print()
# Convert to 0-1 range (called normalization)
normalized = [[px / 255 for px in row] for row in image_5x5]
print("Normalized (0 to 1 range):")
for row in normalized:
formatted = " ".join(f"{val:.2f}" for val in row)
print(f" {formatted}")
print()
# Show statistics about the image
flat = [px for row in image_5x5 for px in row]
print(f"Total pixels: {len(flat)}")
print(f"Min value: {min(flat)}")
print(f"Max value: {max(flat)}")
print(f"Average brightness: {sum(flat)/len(flat):.1f}")Try It Yourself
Try It YourselfHTML
HTML Editor
✓ ValidTab = 2 spaces
HTML|20 lines|653 chars|✓ Valid syntax
UTF-8