Nonlinear adaptive image enhancement and filtering using mathematical morphology