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.
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.
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.
#FFFFFF
Add light on a black background. All three at max → white (the sum of light).
#000000
Subtract color from a white background. All three at max → black (everything absorbed).
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).
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)