For this problem I noticed that the indices of the inner summations were from h to w_i - 1 but it looks like the expression accounts for an extra term since you have w_i - h instead of w_h - 1 - h.
Let me clear it.
sum (k=h to w_i - 1) = sum (k=1 to w_i-1) - sum (k=1 to h-1)= (w_i - 1) - (h-1) = w_i - h;
I hope this is what you were talking about.
Please someone help me, this is the second time I am posting this.