An algorithm for image denoising with automatic noise estimate