How to get a Standard Deviation weighted average in image?

Now I'm trying to implement a SDLWGW algorithm by the Matlab. currently I'm referencing from

Automatic White Balancing Using Luminance Component and Standard Deviation of RGB Components

the problem is I can't understand how to get a $SDLWA_{R}$ and the bar of $L_{red}(k)$? Also what if the $L_{weight}(i,j)$ is $0.9$ then how to calculate the bar of $L_{red}(k)$?

I can't understand it.

I want to know that what is the different between $SD_{red}(k)$ and $SD_{red}(l)$?

$$SDLWA_{R}=\sum_{k=1}^{n}\frac{SD_{red}(k)}{\sum_{l=1}^{n}SD_{red}(l)}\times red_{i,j}(k)$$

What is the $SD_{red}(l)$? Especially, what is the $l$?

$$\sum_{l=1}^{n}SD_{red}(l)$$

update 1

I have got a question one more,

The paper was written like this L_weight(i,j) is a positive single-peak function (e.g triangular function or Gaussian function) value for the luminance value at i-th row, j-th column of the k-th block. but I can't understand what is the mean? How can I make L_weight(i,j) ? Would you please give me any hint please ?

update2.

I'm trying to understand a below answer.

Q1. What if I've got a this block then I think that the k is to be 12 and p is 5, and q is 5. am I correct? Q2. How to get a $\overline{L\_red(k)}$ value as below the case?

Q2-1. Especially, I want to know that what does exactly indicate the $L\_weight(1,1)red_{1,1}(k)$ and $L\_weight(1,1)$, as below the case? I think we know the value of the $red_{1,1}(k)$ But I'm confused that how to know the value of $L\_weight(1,1)$ ?

[![enter image description here]]

update 3

Does anyone know the relationship between Gaussian weight and one Block ?

• The bar denotes the average over a set of pixels. Please try to rewrite it, and propose a beginning of a Matlab code, so that we can help you where you stop understanding – Laurent Duval Mar 4 '16 at 23:20
• @LaurentDuval would you give some hint about what is the different between x,y and i,j in Figure3? I don't have a quite bit understand. I can to assume that that i,j are involved in K then what is the x,y? – jo mal Mar 4 '16 at 23:47
• This person has created new accounts to spam questions on this particular topic. It seems like he/she is trying to accomplish a very specific task of image processing, but without the required background and knowledge. Please see: stackoverflow.com/questions/35808504/… – Mai Mar 5 '16 at 1:03
• @jojek Thanks, I have no idea, what do you think? – jo mal Mar 5 '16 at 11:01

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)$.
• $L\_weight(i,j)$ is a discrete function with the same size of each block, so you multiply coordinate-wise each pixel of the block by the corresponding pixel in $L\_weight(i,j)$ (Q2-1), sum all $p\times q$ products, and divide by the sum of pixles in $L\_weight(i,j)$ (Q2). On the bottom of page 495, the authors seem to take a constant value. Q1: $p=q=5$, but the block is the first one, $k=1$. – Laurent Duval Mar 5 '16 at 15:15