Calculating Haar features
As mentioned the Haar filters use a lookup table with the say $A_{i,j} = \sum_{k=0}^{i} \sum_{l=1}^{j} I_{k,l}$
Now consider a the convolution with a filter $H \in \mathbb{R}^{m \times n}$, such that $H_{i,j}=1$, the convolution will can be calculated as
$$\begin{eqnarray}Y_{i,j} &amp;=&amp; \sum_{k=1}^{m} \sum_{l=1}^{n} H_{k,l} I_{i-k+1, j-k+1} \\
&amp;=&amp;  \sum_{k=1}^{m} \sum_{l=1}^{n} I_{i-k+1, j-k+1} \\
&amp;=&amp;  \sum_{k=i-m+1}^{i} \sum_{l=j-n+1}^{j} I_{k, l} \\
&amp;=&amp;  \sum_{k=i-m+1}^{i} \left( \sum_{l=0}^{j} I_{k, l} -  \sum_{l=0}^{j-n} I_{k, l}\right) \\
&amp;=&amp;  \sum_{k=0}^{i} \left( \sum_{l=0}^{j} I_{k, l} -  \sum_{l=0}^{j-n} I_{k, l}\right) - \sum_{k=0}^{i-m+1} \left( \sum_{l=0}^{j} I_{k, l} -  \sum_{l=0}^{j-n} I_{k, l}\right)\\
&amp;=&amp;  \left(A_{i,j} -  A_{i,j-n}\right) - \left( A_{i-m,j} -  A_{i-m, j-n}\right)\\
\end{eqnarray}
$$
Of course you can generalize this for $H_{i,j} = c$ for constant $c$ (by multiplying the resulting image), and you can use the shifting properties of the convolution if the filter is padded.
Now looking to your $H$, it can be decomposed in two rectangular regions constant regions. It can be decomposed as
$$H_1 + H_2 = \begin{bmatrix} 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 \\ 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 \\0 &amp; 0 &amp; 0 &amp; 1 &amp; 0\end{bmatrix} + (-1) \begin{bmatrix} 0 &amp; 1 &amp; 1 &amp; 0 &amp; 0 \\  0 &amp; 1 &amp; 1 &amp; 0 &amp; 0  \\  0 &amp; 1 &amp; 1 &amp; 0 &amp; 0 \end{bmatrix}$$
To convolve with a the non-zero submatrix of $H_1$, a matrix in $\mathbb{R}^{3 \times 1}$ you will use $A_{i,j} + A_{i-3, j-1} - A_{i, j-1} - A_{i-3,j}$
To convolve with the non-zero submatrix of $H_2$, a matrix in $\mathbb{R}^{3 \times 2}$ you will use $A_{i,j} + A_{i-3, j-2} - A_{i, j-2} - A_{i-3,j}$
Of course you can have other conventions for the indices...