Doubly Adaptive Nonlocal Means Image Denoising Algorithm Based on Mathematical Morphology