Brightness preserving histogram equalization with maximum entropy: a variational perspective