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 (in a chapter in preparation)
  • Be able to load, display, and save images (likewise)

What Is a Digital Image?

A digital image is a dense grid of tiny square pixels. In a color image each pixel holds its color as three numbers, R, G, and B (each 0–255 for 8 bits). 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. (Source: USC-SIPI Image Database)

Contents

1. Digital Image Basics (in preparation)

The starting point of image processing.

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

2. Color Spaces (in preparation)

How color is represented.

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

3. Histograms (in preparation)

Statistical analysis of an image.

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

4. Basic Image Operations (in preparation)

The first step of implementation.

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

5. Point Operations (in preparation)

Per-pixel transformations.

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

6. Getting Started with Python/OpenCV (in preparation)

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 (an idealized model; real printing adds black ink: CMYK).

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; V is the maximum of R, G, B, a different quantity from luminance), organized around hue, and grayscale, which keeps a single brightness component, 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
Few pixels stuck at the ends (where the peak sits depends on the subject; it need not be 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 mark pixels piled up at the ends; some areas are pure white or black to begin with) erases detail that cannot be recovered from the processed image alone. (Source: USC-SIPI Image Database)

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 (height × width × 3; the third axis is the color channel, not depth).

Grayscale conversion

A common formula for converting an RGB image to grayscale: $Y = 0.299R + 0.587G + 0.114B$. These are the ITU-R BT.601 coefficients, applied to gamma-corrected values (based on human visual sensitivity; BT.709 uses 0.2126, 0.7152, 0.0722).

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 (in a discrete image it does not become exactly uniform, and noise can be amplified).

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 (the implementation chapter is in preparation).
How is a digital image represented?
As an array of pixel values. A grayscale image is a 2D array of height × width, and a color image is an array of height × width × 3, where the third axis is the color channel (not depth). Each pixel value is an integer from 0 to 255 for 8-bit images (16-bit and floating-point images also exist).
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.