PIXELBANKv9.1.0
Menu

Bidirectional Frame Blending

Implement a frame interpolation technique to generate an intermediate frame between two given frames. This task is crucial in motion estimation and video processing as it enables the creation of smooth motion sequences.

The concept of frame interpolation is based on linear interpolation, where each pixel in the intermediate frame is calculated as a weighted average of the corresponding pixels in the input frames. The interpolation factor tt controls the blending process, ranging from 0 (first frame) to 1 (second frame).

To perform the interpolation, follow these steps:

  1. Iterate over each pixel in the input frames
  2. Calculate the weighted average of the pixel values using the interpolation factor tt
  3. Assign the resulting value to the corresponding pixel in the intermediate frame
It(x,y)=(1−t)⋅I0(x,y)+t⋅I1(x,y)I_t(x, y) = (1 - t) \cdot I_0(x, y) + t \cdot I_1(x, y)

This technique is widely used in video processing and computer vision applications.

Example:

Input:
frame0 = [[0, 0], [0, 0]]
frame1 = [[100, 100], [100, 100]]
t = 0.5
Output:
[[50, 50], [50, 50]]
Reasoning:

Blending each pixel:

  • (0,0): (1-0.5)×0 + 0.5×100 = 0 + 50 = 50
  • (0,1): (1-0.5)×0 + 0.5×100 = 0 + 50 = 50
  • (1,0): (1-0.5)×0 + 0.5×100 = 0 + 50 = 50
  • (1,1): (1-0.5)×0 + 0.5×100 = 0 + 50 = 50

Result: [[50,50], [50,50]]

  • At t=0.5, each pixel is the average of the two frames.

Constraints:

  • frame0 and frame1 are 2D grayscale images of same size
  • t is interpolation factor (0 to 1)
  • Return blended frame with values rounded to nearest integer
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.
Bidirectional Frame Blending - Medium | PixelBank