Introduction to Image Processing

The basics of digital images

About This Introduction

Image processing is the technology of analyzing, transforming, and improving digital images with a computer. Its applications are wide-ranging, from photo correction to diagnostic support in medical imaging, self-driving cars, and image recognition in AI.

This introductory level builds the background you need to learn image processing. From how a digital image is formed to color spaces, histograms, and basic image operations, it covers the concepts to grasp before you dive into implementation.

Learning Objectives

  • Understand the structure of a digital image (pixels, resolution, bit depth)
  • Grasp the idea of color spaces such as RGB, HSV, and grayscale
  • Understand what a histogram means and how to use it
  • Learn the basic use of Python and OpenCV
  • Be able to load, display, and save images

What Is a Digital Image?

A digital image is a dense grid of tiny square pixels. Each pixel holds its color as three numbers, R, G, and B (each 0–255). Use the resolution slider to change the number of pixels and feel the coarseness (mosaic effect), and hover the image to read that pixel's color value.

48 × 48 pixels
Hover the image to
read that pixel's value

The fewer the pixels, the larger each one becomes and the blockier the picture (mosaic). Turn it all the way up to show the original image.

Figure 1: An image is a set of pixels. Even a photo that looks smooth is, up close, a collection of small colored squares.

Contents

1. Digital Image Basics

The starting point of image processing.

  • What a pixel is
  • Resolution and size
  • Bit depth
  • Image formats (JPEG, PNG, BMP)

2. Color Spaces

How color is represented.

  • The RGB color space
  • The HSV/HSL color space
  • Grayscale conversion
  • Uses of color-space conversion

3. Histograms

Statistical analysis of an image.

  • The luminance histogram
  • How to read a histogram
  • Relation to contrast
  • Histogram equalization

4. Basic Image Operations

The first step of implementation.

  • Loading and saving images
  • Resizing and rotation
  • Cropping (ROI)
  • Direct pixel-value access

5. Point Operations

Per-pixel transformations.

  • Negative (invert)
  • Brightness and contrast adjustment
  • Gamma correction
  • Binarization (thresholding)

6. Getting Started with Python/OpenCV

Setting up the implementation environment.

  • Environment setup
  • NumPy and image arrays
  • Basic OpenCV functions
  • Display with Matplotlib

Color Spaces and Color Mixing

Colors on a screen come from additive mixing (RGB), adding light; colors in print come from subtractive mixing (CMY), subtracting light with ink. Move the sliders on the two mixers below to see how the mixing differs.

Additive mixing (RGB, light)
#FFFFFF

Add light on a black background. All three at max → white (the sum of light).

Subtractive mixing (CMY, ink)
#000000

Subtract color from a white background. All three at max → black (everything absorbed).

Figure 2: Left = additive mixing (adding light on black; overlaps are yellow, cyan, and magenta, and the center is white). Right = subtractive mixing (subtracting color from white; overlaps are blue, green, and red, and the center is black). Displays are additive; print and paint are subtractive. Overlaying semi-transparent RGB circles on white looks subtractive, so the correct way to draw additive mixing is adding light on a black background.

HSV (hue, saturation, value), organized around hue, and grayscale, which keeps only luminance, are also converted from RGB as needed. For the grayscale conversion formula, see Key Concepts.

Histograms

A histogram is a graph of "how many pixels there are at each brightness" (horizontal axis: dark 0 to light 255; vertical axis: pixel count). On the left is the actual image, and on the right is the luminance histogram of that image. As you move the brightness and contrast sliders, the image and the histogram change together. Push them too far and highlight clipping and shadow clipping destroy image detail (an irreversible loss of information).

Image (brightness and contrast applied)
Luminance histogram of that image
A well-balanced exposure. The histogram peaks in the middle.
Figure 3: Brightness shifts the whole image lighter or darker; contrast strengthens or weakens the difference between light and dark. The sliders make the image and histogram move together. Push them too far and highlight/shadow clipping (the orange bars) erases detail that can no longer be recovered.

Key Concepts

Digital image

A digital image is represented as a 2D array. Each element (pixel) is an integer holding luminance or color information. A color image is usually a 3D array with three RGB channels.

Grayscale conversion

A common formula for converting an RGB image to grayscale: $Y = 0.299R + 0.587G + 0.114B$. The weights are based on human visual sensitivity.

Histogram equalization

A technique for improving image contrast. Using the cumulative distribution function (CDF), it redistributes luminance values to make the histogram closer to uniform.

Supplementary Reading

Alongside the main material, these pieces gently explore how digital images work, using figures.

Sampling and Quantization

Understand how a continuous image of light becomes a digital image in two stages: sampling and quantization.

Bit Depth and Tone

Understand that bit depth sets the number of brightness steps, and that too few steps cause banding.

Resolution, PPI, and DPI

Learn to tell "resolution (pixel count)" apart from "PPI/DPI (density)."

Choosing an Image File Format

Understand lossless vs. lossy compression, and choose the right format for photos vs. logos.

The Intuition Behind Gamma Correction

Understand gamma correction as redistributing brightness to match human perception.

Tone Curves and LUTs

Understand that brightness and contrast adjustment can be expressed as a per-pixel mapping (a LUT).

Resizing by Interpolation

Understand why interpolation is needed for scaling, and how three common methods differ.

Anti-aliasing and Jaggies

Understand that jaggies arise from coarse sampling, and how intermediate colors soften them.

Moiré and Aliasing

Understand moiré as a false pattern that appears when sampling cannot keep up with fine detail.

The Alpha Channel and Compositing

Understand that alpha represents transparency, and that compositing is a weighted sum by alpha.

Prerequisites

  • Basic programming (Python recommended)
  • The idea of arrays and matrices
  • Basic mathematics (arithmetic, functions)

Frequently Asked Questions (FAQ)

What does the introductory image processing level cover?
The basic concepts of a digital image (pixels, resolution, bit depth, and color spaces), how to read a histogram, point operations such as brightness, contrast, and gamma correction, basic operations like resizing and cropping, and the fundamentals of implementation with Python and OpenCV.
How is a digital image represented?
As an array of pixel values arranged on a 2D or 3D grid. A grayscale image is a single channel, while a color image is a matrix with three channels such as RGB. Each pixel value is usually an integer from 0 to 255 (8 bits).
What kinds of color spaces are there?
RGB (the three primaries red, green, and blue), HSV (hue, saturation, value), YCbCr (luminance and chrominance), and Lab* (a perceptually uniform color space), among others. They are converted and used according to the task.