TransWikia.com

Average image over $N$ frames with one frame buffer

Signal Processing Asked by user674907 on November 5, 2021

Can you give some filter that is averaging an image over $N$ samples in a recursive way that only needs one frame buffer?

$frac{1}{N} sum_{k=1}^{N} y_{k}(m,n)$

I can only imagine filters that need $N-1$ frame buffers.

2 Answers

This is a form the recursive averaging filter: say $v_k = frac{1}{N}sum_{n=k-N+1}^{k} y_n$ is the average at $k$ over the $N$ passed frames (the notation applies to every pixel value $y$, independantly). Then:

$$v_{k+1} = frac{1}{N}sum_{n=k-N}^{k+1} y_n = frac{1}{N}(y_{k+1}-y_{k-N+1})+v_{k}$$

so you can bufferize the pixel ($y_{k-N+1}$) that leaves the $N$-length frame only. If b is a single buffer of the past $N$th input, then the output o could be written as:

o += (i-b)/N

The following diagram comes from Implementing a moving average (boxcar) filter, which provides full details about the algorithm.

Diagram view of the moving average recursive implementation

Answered by Laurent Duval on November 5, 2021

Don't fully understand the question; your formula already describes your solution:

  1. Take the first frame into your framebuffer
  2. For every pixel of the second frame, add it to pixel at the same position in the frame buffer.
  3. Repeat 2. for the rest of your frames.
  4. Multiply every pixel of the resulting frame by $frac1N$.

Done!

(Note: depending on the data type, might be advantageous to multiply every pixel with $frac1N$ before addition/move to the framebuffer pixel)

Answered by Marcus Müller on November 5, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP