AI Glossary / Computer vision and multimodal AI / Beginner

Linear interpolation

Definition

Linear interpolation estimates a value between two known samples by following the straight line that connects them. The estimate is a weighted average of the endpoint values, with weights determined by the query's relative position. It is widely used in image resampling, animation, numerical tables, and other tasks that require values between recorded or computed samples.

What it means

Suppose a quantity is known at two positions but needed somewhere between them. Linear interpolation assumes a straight transition across that interval. It does not establish that the underlying physical quantity really changes linearly; it supplies a simple, explicit approximation.

When many samples are available, adjacent pairs form a piecewise-linear function. Each interval is straight, although the slope can change where intervals meet. The result can be continuous without having a smooth derivative.

Interpolation refers to estimating within the sampled range. Extending a line beyond its known endpoints is extrapolation, which involves a different level of assumption. Software may clamp outside-range queries, extrapolate, or raise an error, so its boundary behavior must be understood.

How it works

Let the sample positions be x0 and x1, with distinct positions and values y0 and y1. For a query x between them, calculate t = (x − x0)/(x1 − x0). Then estimate y = (1 − t) times y0 plus t times y1.

Within the interval, t lies between zero and one. At the left endpoint the result is y0, and at the right endpoint it is y1. Halfway between, both values receive equal weight.

For a sequence, first locate the interval containing the query. Ordered sample positions make this efficient and unambiguous. Duplicate positions can require a special policy because the basic formula divides by their difference.

In images, bilinear interpolation extends the idea across two spatial directions using neighboring samples. Other quantities need care: angles, orientations, and categorical labels may not be meaningfully interpolated by ordinary scalar averaging.

Three practical examples

1. Image resizing: A processing system estimates intensity values at positions that fall between existing pixels when constructing a new sampling grid.

2. Animation: A graphic moves from one position to another at a constant rate between two keyframes, with intermediate coordinates calculated by interpolation.

3. Calibration tables: An instrument estimates an intermediate response between nearby tabulated values when the local straight-line approximation is suitable for the intended accuracy.

Think of it this way

Think of drawing a straight ruler line between two marks on a graph and reading values along it. The line provides a clear estimate between the marks. The analogy's limit is also the method's limit: a curved or abruptly changing real process need not follow the ruler, even if both endpoint measurements are correct.

Worked example

Suppose an image-related calibration table gives a value of 20 at position 10 and 50 at position 30. To estimate the value at position 18, compute t = (18 − 10)/(30 − 10) = 8/20 = 0.4.

The estimate is 0.6 × 20 + 0.4 × 50 = 12 + 20 = 32. The query is forty percent of the way across the position interval, so the value is forty percent of the way from 20 to 50.

At position 20, t is 0.5 and the estimate is 35. At position 40, the same algebra gives t = 1.5 and a value of 65, but this is extrapolation because 40 lies beyond the known interval. A particular interpolation function may instead return the endpoint value 50 outside its range.

If the underlying relationship bends strongly, the estimate can be inaccurate despite correct arithmetic. More samples or a better model may be needed. Interpolation and measurement errors are distinct.

Illustrative case study

Fictional case study: A visualization team animates a marker between measurements taken at irregular times. Its first implementation averages adjacent values without considering the actual time gap, which places intermediate positions incorrectly.

The team switches to a time-based interpolation fraction and checks the animation at both recorded timestamps and intermediate points. It also labels the interpolated portions so viewers do not mistake every displayed frame for a separate measurement.

A sudden event occurs between two widely spaced samples, and the straight transition hides that possibility. The team adds more measurements for the next capture rather than assuming a smoother animation provides more evidence. The case illustrates a modeling choice, not a claim that linear interpolation reconstructs unobserved events.

Common misconceptions and mistakes

Linear interpolation is not the same as taking an unweighted average. Equal weights are appropriate only at the midpoint between the two sample positions.

It does not create new observations. A dense output grid can still be based on sparse input information.

A piecewise-linear curve can have sharp changes in slope at sample locations. Continuity of values does not imply smoothness of every derivative.

Interpolating encoded color values can differ from interpolating linear-light values. The intended meaning of the numbers matters to the visual result.

Ordinary interpolation between angles near a wrap boundary can take the wrong route. For example, halfway between 359 and 1 degrees is not necessarily intended to be 180 degrees; circular quantities require an appropriate convention.

Business use

Linear interpolation provides a simple, reproducible estimate between samples and a baseline for evaluating more complex interpolation or learned reconstruction methods.

Choose sample spacing and an error tolerance suited to the process being represented. Test known values, endpoints, irregular spacing, and outside-range queries. For dashboards and reports, distinguish interpolated values from measured ones when that distinction affects decisions. For images, inspect boundaries and fine detail because interpolation can soften features without restoring information lost during capture or downsampling.

People also ask

Is the interpolated value always between the endpoint values?

For ordinary scalar interpolation with a query between the positions, yes. The weights are nonnegative and sum to one.

Does linear interpolation require evenly spaced samples?

No. The fraction uses actual sample positions, so unequal intervals can be handled.

Is extrapolation the same operation?

The formula can be extended, but estimating outside the observed interval is extrapolation and software may use a different boundary policy.

Check your understanding

Values are 8 at position 0 and 20 at position 4. What is the linear estimate at position 1?

Answer: 11, because the query is one quarter of the way across the interval: 0.75 × 8 + 0.25 × 20 = 11.

Related terms

  • Bilinear interpolation
  • Resampling
  • Sampling error
  • Interpolation
  • extrapolation
  • keyframe
  • piecewise-linear function

Learn next

Work through interpolation with irregularly spaced sample positions, then compare it with nearest-neighbor and a smooth cubic method. Examine where each method introduces smoothing, slope changes, or assumptions unsupported by the observations.

  • Nearest neighbor

More in Computer vision and multimodal AI

  • Light transport - Light transport describes how light moves through a scene and interacts with surfaces and media before reaching a sensor or observer.
  • Line intersection - Line intersection is the geometric relationship in which two lines share one or more points.
  • Linear filter - A linear filter transforms a signal or image while preserving superposition: filtering a weighted sum of inputs gives the same result as taking the...
  • Linear inverse problem - A linear inverse problem estimates an unknown quantity from measurements related to it by a linear forward model.
  • Linear light - Linear light describes an image representation in which numerical values are proportional to the represented light quantity within a defined color and...
  • Linear shift-invariant (LSI) filter - A linear shift-invariant filter, or LSI filter, preserves superposition and responds the same way when an input pattern is shifted in space.

Sources

NumPy, numpy.interp official reference: https://numpy.org/doc/stable/reference/generated/numpy.interp.html

The primary software documentation was opened, including ordered-sample and boundary behavior. Numerical examples and the visualization scenario are original teaching material.

Previous: Linear hashing Next: Linear interpolation smoothing

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer