User:Escuerdo/sandbox

For a time series of N frames and a window size of M for the moving average (where M is an odd integer), the nth term of the new time series is given by

$$ F_n=\sum_{i=n-m}^{n+m}\frac{f_i}{2m+1} $$

Where $$m=\frac{M-1}{2}$$ if both

$$n > \frac{M-1}{2}$$ and $$n < N-\frac{M-1}{2}$$ are true.

Otherwise,

$$m=min\{n-1,N-n\}$$

Given the original $$m \times n$$ image,

$$R = \begin{bmatrix} r_{1,1} & r_{1,2} & \cdots & r_{1,n} \\ r_{2,1} & r_{2,2} & \cdots & r_{2,n} \\ \vdots & \vdots  & \ddots & \vdots  \\ r_{m,1} & r_{m,2} & \cdots & r_{m,n} \end{bmatrix}$$

along with the Gaussian filter

$$G = \begin{bmatrix} g_{1,1} & g_{1,2} & g_{1,3} \\ g_{2,1} & g_{2,2} & g_{2,3} \\ g_{3,1} & g_{3,2} & g_{3,3} \end{bmatrix} = \begin{bmatrix} 0.0113 & 0.0838 & 0.0113 \\ 0.0838 & 0.6193 & 0.0838 \\ 0.0113 & 0.0838 & 0.0113 \end{bmatrix}$$

The pixels of the filtered image, P, are calculated as

$$p_{a,b}=\sum_{i=-1}^{1}\sum_{j=-1}^{1}(g_{i+2,j+2})(r_{(a+i \bmod{m}),(b+j \bmod{n})})$$

where the residue class of $$\pmod{n}$$ is $$\{1,\cdots,n\}$$.

Given the original $$m \times n$$ image,

$$R = \begin{bmatrix} r_{1,1} & r_{1,2} & \cdots & r_{1,n} \\ r_{2,1} & r_{2,2} & \cdots & r_{2,n} \\ \vdots & \vdots  & \ddots & \vdots  \\ r_{m,1} & r_{m,2} & \cdots & r_{m,n} \end{bmatrix}$$

along with the Gaussian filter

$$G = \begin{bmatrix} g_{1,1} & g_{1,2} & g_{1,3} \\ g_{2,1} & g_{2,2} & g_{2,3} \\ g_{3,1} & g_{3,2} & g_{3,3} \end{bmatrix} = \begin{bmatrix} 0.0113 & 0.0838 & 0.0113 \\ 0.0838 & 0.6193 & 0.0838 \\ 0.0113 & 0.0838 & 0.0113 \end{bmatrix}$$,

and the function, $$C(a,m)=\begin{cases} 1 & a < 1 \\ a & 1 \le a \le m \\ m & a > m \\ \end{cases}$$,

the values for the pixels of the filtered image, P, are calculated as

$$p_{a,b}=\sum_{i=-1}^{1}\sum_{j=-1}^{1}(g_{i+2,j+2})(r_{C(a+i,m),C(b+j,n)})$$.