histogram equalization and common code
minor fixed