0
$\begingroup$

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.

$\endgroup$
1
$\begingroup$

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)

| improve this answer | |
$\endgroup$
  • $\begingroup$ If u draw that in a z transform you would need N-1 frame buffers? What u describe is a typical moving average filter? I asked for a recursive one frame buffer solution. :) $\endgroup$ – user674907 May 17 at 21:28
  • $\begingroup$ A moving-average filter can have a recursive implementation @user674907 $\endgroup$ – Ben Jul 21 at 13:27
1
$\begingroup$

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

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ Thank u! I need some time to think about this and draw it. $\endgroup$ – user674907 May 17 at 21:40
  • $\begingroup$ Did you have time enough to think about it? $\endgroup$ – Laurent Duval Jun 21 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.