Computer science | Helping machines interpret images

Computer vision: turning images into information

Explore how computers represent images, find visual patterns, classify objects, detect regions, and evaluate vision systems in the conditions where people use them.

COMPUTER SCIENCECOMPUTER VISION GUIDEBeginner to intermediate
A computer-vision pipelineA camera image is prepared, represented by a model, evaluated to produce visual predictions, and checked by an application or person. ImagePrepareModelPredictionDecision real-world errors inform testing and model updates
Figure 1. Vision systems turn sampled pixels into predictions, but data and evaluation must match the intended environment.

What computer vision does

Computer vision studies methods for extracting useful information from images and video. Tasks include recognizing categories, locating objects, tracking motion, reconstructing depth, reading text, and identifying boundaries between regions.

Vision systems do not “see” in the human sense. They operate on numerical representations derived from sensors. Performance depends on image quality, model assumptions, training data, and the environment. A system that performs well on clear daytime photos may fail at night, in rain, or with a different camera.

The prediction is only one part of a complete product. The system must communicate uncertainty, handle bad inputs, and avoid treating an uncertain output as a guaranteed fact.

Images as sampled data

A digital image is a two-dimensional array of pixels. Each pixel stores one or more channels, such as grayscale intensity or red, green, and blue values. A color image's meaning also depends on its color space, bit depth, and camera processing.

Images are samples of a continuous scene. Camera optics, sensor size, exposure, focus, motion, and lighting influence what is captured. Resolution describes the number of samples, not the amount of useful detail; a high-resolution blurred image can contain less usable information than a focused lower-resolution image.

Image coordinates and channels

Image coordinates commonly use an origin at the top-left, with columns increasing to the right and rows increasing downward. A pixel can be represented as image[row, column, channel]. Confusing row and column order or color-channel order can produce rotated images or unexpected colors.

Color channels may be encoded nonlinearly for display. Some algorithms expect normalized values, a particular channel order, or a specific color space. Preprocessing must match the assumptions used when a model was trained.

Sampling and aliasing

Fine patterns can change faster than a sensor's pixel grid can represent. The resulting aliasing may appear as moiré patterns, jagged edges, or false textures. Optical and digital filtering, suitable resolution, and careful resizing reduce some artifacts but cannot recreate information that was not captured.

Preprocessing and image filters

Preprocessing makes image inputs suitable for later algorithms. Common operations include cropping, resizing, color conversion, normalization, denoising, and contrast adjustment. Every transformation can remove or distort information, so choose it based on the task and model requirements.

A convolutional filter applies a small matrix of weights to neighboring pixels. A blur filter averages nearby values; an edge filter responds to rapid intensity changes. Convolution captures local patterns and is a foundation of many vision algorithms and neural networks.

Image normalization rescales values, often to a specified numeric range. Training and inference must use consistent preprocessing; a model trained on normalized RGB images will receive a different input distribution if inference uses raw BGR values.

Augmentation and invariance

Data augmentation creates altered training images, such as crops, flips, or small color changes. It can help a model handle expected variation, but only when transformations preserve the correct label. Flipping a medical image may change meaningful orientation; rotating a digit can change its identity.

An invariance is a property that remains unchanged under a transformation. A cat remains a cat when the image is slightly brighter, but a traffic sign's meaning may change when rotated. Decide which variations should be ignored and which should matter.

Features and representations

Traditional vision systems often compute hand-designed features, such as corners, edges, local texture descriptors, or color histograms, then use a classifier or geometric algorithm. These features can be interpretable and efficient, but their performance depends on whether they capture the patterns relevant to the task.

Deep-learning systems learn feature representations from training data. Early layers may respond to simple edges or color changes, while later layers represent more complex patterns. These representations are useful but do not necessarily correspond to human concepts or provide causal explanations.

Geometry and matching

Feature matching finds corresponding points between images. If many points correspond consistently, geometry can estimate a camera motion or a transformation between views. Outliers arise from repeated patterns, occlusion, or incorrect matches, so robust estimation methods reject inconsistent correspondences.

Depth can be estimated from multiple views, stereo cameras, structured light, or learned prediction. Each method has assumptions and failure modes. A camera image alone generally does not uniquely determine the three-dimensional scene without additional information.

Classification, detection, and segmentation

TaskOutputExample
ClassificationOne or more image-level labelsIdentify whether an image contains a bicycle
Object detectionLabels and bounding boxesLocate several vehicles in a street scene
Semantic segmentationA class label for each pixelMark road, sky, and buildings
Instance segmentationSeparate masks for individual objectsDistinguish each person in a crowd
TrackingObject identities across framesFollow a moving ball through video
Optical flowEstimated motion between image regionsMeasure apparent movement between frames

Choose the task that matches the application. A classification score cannot say where an object is; a bounding box cannot precisely outline its shape. More detailed outputs often require more labeled data and more careful evaluation.

Convolutional neural networks

A convolutional neural network (CNN) applies learned filters across image locations. Shared filters detect patterns wherever they appear, reducing the number of parameters compared with a fully connected layer over every pixel. Pooling or strided operations can summarize information at lower spatial resolution.

Training uses labeled examples and an optimization procedure to adjust weights. The model's loss measures a training objective, such as classification error. A lower training loss does not guarantee better performance on unseen images; evaluation and regularization are necessary.

Modern vision models also use attention mechanisms and transformer architectures. These can model relationships across distant image regions, but still depend on data, computation, and evaluation. A more complex model is not automatically more reliable or appropriate.

Inference and confidence

At inference time, a model processes a new image and returns scores or predictions. A softmax score may rank classes but should not automatically be interpreted as a calibrated probability. Calibration and reliability need to be measured with held-out data relevant to the use case.

Evaluation, data quality, and generalization

Split data so evaluation estimates performance on genuinely new situations. If images from the same person, video, location, or capture session appear in both training and test sets, the model may exploit similarities and receive an overly optimistic score. Split by the source of dependence where appropriate.

Accuracy summarizes the fraction of correct predictions but may hide rare classes or unequal error costs. Detection uses measures involving overlap between predicted and true boxes; segmentation can use intersection-over-union. The metric should match how the output is used.

Distribution shift occurs when deployment images differ from training images. A model trained on curated photos may fail on low-quality mobile images. Monitoring image quality and out-of-distribution behavior helps, but systems should also define a safe response when inputs are unfamiliar.

Worked example: inspect an image pipeline

Imagine a system that counts bicycles in a campus entrance video. First define what counts as a bicycle, whether parked bicycles count, and how to handle partially hidden objects. Then document camera position, frame rate, lighting, retention, and privacy constraints.

  1. Sample frames at a rate that captures motion without unnecessary processing.
  2. Resize and normalize frames using the model's training conventions.
  3. Run an object detector and examine labels, boxes, and confidence behavior.
  4. Track detections across frames so one bicycle is not counted repeatedly.
  5. Compare counts with manually verified samples and investigate missed or duplicate objects.

Performance can vary when bicycles overlap or appear at night. A high average score may hide errors at peak times. The application should distinguish an estimate from an exact count and avoid retaining identifiable video longer than necessary.

Testing includes not only model accuracy but camera placement, network outages, frame drops, and privacy practices. If the camera is moved, the image distribution and counting behavior may change; re-evaluation is needed.

Limits, privacy, and responsible use

Images can contain faces, license plates, homes, medical details, and other sensitive information. Obtain appropriate authorization, minimize collection and retention, restrict access, and consider on-device processing when it reduces exposure.

Vision systems can perform differently across skin tones, ages, assistive devices, camera qualities, and environments. A single benchmark rarely represents every deployment population. Test relevant groups and communicate limitations, especially when errors could affect safety, access, or opportunity.

Computer vision is not a neutral observer. Teams choose what to detect, how to label it, what error rates to accept, and what action follows. Provide human review and appeal for consequential decisions, and do not infer sensitive traits without a legitimate, carefully assessed basis.

A compact glossary

Pixel
A discrete image sample containing one or more channel values.
Convolution
A local weighted operation that combines neighboring image values.
Feature
A measured or learned representation used by an algorithm.
Bounding box
A rectangular region indicating an object's approximate location.
Segmentation
Assigning labels or object identities to image regions or pixels.
Data shift
A change between image conditions in training and deployment.

References and further reading

  1. Richard Szeliski. Computer Vision: Algorithms and Applications, 2nd edition. Springer, 2022. Free online edition.
  2. OpenCV. OpenCV Tutorials. Documentation and examples.
  3. Stanford University. CS231n: Deep Learning for Computer Vision. Course materials.
  4. World Wide Web Consortium. Ethical Web Principles. Design principles.

Try it yourself

  1. Explain the difference between classification, detection, and segmentation.
  2. Why should video frames from one recording usually stay together in a train or test split?
  3. List two ways lighting changes can affect a camera-based system.
  4. Describe one privacy-preserving design choice for a camera that counts objects.
  5. Choose an evaluation metric for object detection and explain what errors it may not capture.

Remember: vision systems turn pixels into estimates; trustworthy use requires representative data, careful evaluation, and attention to privacy and impact.

Keep exploring

Try another topic

A fresh topic suggestion is ready for you.

Explore a topic
0% read