PIXELBANKv9.1.0
Menu

Problem Statement

A Moving Average Filter (also called a box filter) is one of the simplest smoothing techniques in image and signal processing. It replaces each pixel with the average of its neighboring pixels within a window.

Given a 1D signal (list of integers) and a window size k, compute the moving average for each valid position. Return the result as a list of floats rounded to 2 decimal places.

Application in CV

  • Noise reduction in images (applied row-wise or column-wise)
  • Temporal smoothing in video frames
  • Pre-processing before edge detection

Constraints

  • 1≤len(signal)≤100001 \leq len(signal) \leq 10000
  • 1≤k≤len(signal)1 \leq k \leq len(signal)
  • −10000≤signal[i]≤10000-10000 \leq signal[i] \leq 10000

Example:

Input:
signal = [1, 2, 3, 4, 5], k = 3
Output:
[2.0, 3.0, 4.0]
Reasoning:

Averages: (1+2+3)/3=2.0, (2+3+4)/3=3.0, (3+4+5)/3=4.0

solution.py

Test Results

0/0
Run code to see test results.