# Sum of spatio-temporal window

I would like to get confirmation about a formula. It looks quite simple but I can't make it work, so I start to have some doubt.

Let's say I have 2 images $I_t$ and $I_{t-1}$ which are 2 consecutives video frames. Now, I have for some pixel $p_t(x_0,y_0)$ in $I_t$ a corresponding pixel $p_{t-1}(x'_0,y'_0)$ in the image $I_{t-1}$.

I define a local window as $w^{3D}=w^{2D}_t \cup w^{2D}_{t-1}$ and $w^{2D}_t$ is a $3*3$ window around $p_t$ and $w^{2D}_{t-1}$ is a $3*3$ window around $p_{t-1}$ if there is a corresponding pixel. Otherwise, $w^{3D}=w^{2D}_t \cup \varnothing$.

I want to construct a sparse matrix $L$, size $N*N$ where $N$ is the number of pixels in the image $I_t$.

For each $(i,j)$th element of L, I have :

$L(i,j)=\sum_{k\mid(i,j)\in w^{3D}_k} (...)$ (so if i and j are neighbour in the image or equal)

I have some problems to understand which window is included in the sum. For me, the number of windows that I have to sum is not dependant of $w^{2D}_{t-1}$. I mean it can be $\varnothing$ or not, I still sum the same number of window because $i$ and $j$ are index pixel of $I_t$. Is that correct ?

Is the formula below lead to the same result ?

$L(i,j)=\sum_{k\mid(i,j)\in w^{2D}_k} (...)$

Edit:

If it is not understandable, please let me know, I will refine the question.

-