Text this: Detail-preserving denoising of CT and MRI images via adaptive clustering and non-local means algorithm