OpenCV Linear Interpolation

Resize image

Linear interpolation uses linear function to find the a weight of point between given two points. Given two point $A = (x_1, y_2)$ and $B = (x_2, y_2)$ Find a weight of a point between $A$ and $B$ \begin{equation} \begin{aligned} x' &= (1 - t)x_1 + t x_2 \\ y' &= (1 - t)y_1 + t y_2 \quad \text{ where } 0 \leq t \leq 1 \\ \end{aligned} \end{equation} Given four points: $p_{0}, p_{1}, p_{2}, p_{3}$ Compute the weight of two points:

Compute $p_{01}$ from $p_0$ to $p_1$ \begin{equation} \begin{aligned} x_{01} = (1 - t)x_0 + t x_1 \\ y_{01} = (1 - t)y_0 + t y_1 \\ \end{aligned} \end{equation} Compute $p_{23}$ from $p_2$ to $p_3$ \begin{equation} \begin{aligned} x_{23} = (1 - t)x_2 + t x_3 \\ y_{23} = (1 - t)y_2 + t y_3 \\ \end{aligned} \end{equation} Compute $p_{0123}$ from $p_{01}, p_{23}$ \begin{equation} \begin{aligned} x_{0123} = (1 - t)x_{01} + t x_{23} \\ y_{0123} = (1 - t)y_{01} + t y_{23} \\ \end{aligned} \end{equation}

Linear interpolation uses linear function to find the a weight of point between given two points. Given two point $A = (x_1, y_2)$ and $B = (x_2, y_2)$ Find a weight of a point between $A$ and $B$ \begin{equation} \begin{aligned} x' &= (1 - t)x_1 + t x_2 \\ y' &= (1 - t)y_1 + t y_2 \quad \text{ where } 0 \leq t \leq 1 \\ \end{aligned} \end{equation} Given four points: $p_{0}, p_{1}, p_{2}, p_{3}$ Compute the weight of two points:

Compute $p_{01}$ from $p_0$ to $p_1$ \begin{equation} \begin{aligned} x_{01} = (1 - t)x_0 + t x_1 \\ y_{01} = (1 - t)y_0 + t y_1 \\ \end{aligned} \end{equation} Compute $p_{23}$ from $p_2$ to $p_3$ \begin{equation} \begin{aligned} x_{23} = (1 - t)x_2 + t x_3 \\ y_{23} = (1 - t)y_2 + t y_3 \\ \end{aligned} \end{equation} Compute $p_{0123}$ from $p_{01}, p_{23}$ \begin{equation} \begin{aligned} x_{0123} = (1 - t)x_{01} + t x_{23} \\ y_{0123} = (1 - t)y_{01} + t y_{23} \\ \end{aligned} \end{equation}

Let's enlarge an image three times the original size

Given four points $A, B, C, D$ from the figure below, they can be interpolated it with various $t$

1. Interpolate $A, B$

$A = (1-t)A + tB$ where $t = 0$

$E = (1-t)A + tB$ where $t = \frac{1}{3}$

$F = (1-t)A + tB$ where $t = \frac{2}{3}$

$B = (1-t)A + tB$ where $t = 1 $

2. Interpolate $C, D$

similar to 1

3. Interpolate $A, C$

similar to 1

4. Interpolate $B, D$

similar to 1

Given four points $A, B, C, D$ from the figure below, they can be interpolated it with various $t$

1. Interpolate $A, B$

$E = (1-t)A + tB$ where $t = \frac{1}{3}$

$F = (1-t)A + tB$ where $t = \frac{2}{3}$

$B = (1-t)A + tB$ where $t = 1 $

similar to 1

3. Interpolate $A, C$

similar to 1

4. Interpolate $B, D$

similar to 1