def denoise_nl_means(image, patch_size=7, patch_distance=11, h=0.1, multichannel=None, fast_mode=True):
 if (multichannel is None):
  warn('denoise_nl_means will default to multichannel=False in v0.15')
  multichannel = True
 if (image.ndim == 2):
  image = image[..., np.newaxis]
  multichannel = True
 if (image.ndim != 3):
  raise NotImplementedError('Non-local means denoising is only         implemented for 2D grayscale and RGB images or 3-D grayscale images.')
 if multichannel:
  if fast_mode:
   return np.squeeze(np.array(_fast_nl_means_denoising_2d(image, patch_size, patch_distance, h)))
  else:
   return np.squeeze(np.array(_nl_means_denoising_2d(image, patch_size, patch_distance, h)))
 elif fast_mode:
  return np.array(_fast_nl_means_denoising_3d(image, s=patch_size, d=patch_distance, h=h))
 else:
  return np.array(_nl_means_denoising_3d(image, patch_size, patch_distance, h))

def denoise_nl_means ( image , patch_size = 7 , patch_distance = 11 , h = 0.1 , multichannel = None , fast_mode = True ) : if ( multichannel is None ) : warn ( 'denoise_nl_means will default to multichannel=False in v0.15' ) multichannel = True if ( image . ndim == 2 ) : image = image [ ... , np . newaxis ] multichannel = True if ( image . ndim != 3 ) : raise NotImplementedError ( 'Non-local means denoising is only         implemented for 2D grayscale and RGB images or 3-D grayscale images.' ) if multichannel : if fast_mode : return np . squeeze ( np . array ( _fast_nl_means_denoising_2d ( image , patch_size , patch_distance , h ) ) ) else : return np . squeeze ( np . array ( _nl_means_denoising_2d ( image , patch_size , patch_distance , h ) ) ) elif fast_mode : return np . array ( _fast_nl_means_denoising_3d ( image , s = patch_size , d = patch_distance , h = h ) ) else : return np . array ( _nl_means_denoising_3d ( image , patch_size , patch_distance , h ) )
perform non-local means denoising on 2-d or 3-d grayscale images .