The Analysis of Image Contrast: From Quality Assessment to Automatic Enhancement