For $f \in C^{2}([a,b],\mathbb{R})$, we can integrate by parts to obtain
$\begin{displaystyle}\begin{array}{lcl}\frac{1}{b-a}\int_{a}^{b}\left[f(x)-\frac{f(a)+f(b)}{2}\right]dx&=&\frac{1}{b-a}\left[x\left(f(x)-\frac{f(a)+f(b)}{2}\right)|_{a}^{b}-\int_{a}^{b}f'(x)xdx\right]\\&=&\frac{1}{b-a}\left[b\frac{f(b)-f(a)}{2}+a\frac{f(b)-f(a)}{2}-\int_{a}^{b}f'(x)xdx\right]\\&=&\frac{1}{b-a}\left[\int_{a}^{b}f'(x)\left(\frac{a+b}{2}-x\right)dx\right]\\&=&\frac{1}{b-a}\left[f'(x)\left(x\frac{a+b}{2}-\frac{1}{2}x^{2}\right)|_{a}^{b}-\int_{a}^{b}f''(x)\left(x\frac{a+b}{2}-\frac{1}{2}x^{2}\right)dx\right]\\&=&\frac{1}{b-a}\left[f'(b)\frac{ab}{2}-f'(a)\frac{ab}{2}-\int_{a}^{b}f''(x)\left(x\frac{a+b}{2}-\frac{1}{2}x^{2}\right)dx\right]\\&=&\frac{1}{b-a}\left[\int_{a}^{b}f''(x)\left(\frac{ab}{2}-x\frac{a+b}{2}+\frac{1}{2}x^{2}\right)dx\right]\\&=&\frac{1}{b-a}\int_{a}^{b}f''(x)\frac{(x-a)(x-b)}{2}dx\end{array}\end{displaystyle}$
If $f$ is in addition convex (i.e. $f''\geq 0$), then the the preceding quadrature formula gives us the right Hermite-Hadamard inequality.