How to get a Standard Deviation weighted average in image?
The $k$ and $l$ indices are to be understood with indexes under the $\sum$ sign. They can be called "free variables". Suppose that the block $k$ has only two pixels, then $p=1$ and $q=2$. So $\overline{L\_red(k)} $ is just a weighted average (a kind of center of mass) of the $2$ red components from the two pixels  of the block:
$$ \frac{L\_weight(1,1)red_{1,1}(k)+L\_weight(1,2)red_{1,2}(k)}{L\_weight(1,1)+L\_weight(1,2)} $$
which gives you a single value for each block.
Formula (5) has the same interpretation,  you perform the weighted average of those averaged values over blocks, with weights $SD\_red(k)$. 

it is quite easy to use Matlab's block processing tools.