Intensity histogram with multi class segmentation and degeneration detection for quality image denoising and contrast enhancement