From bcd24eab862d76a3bf29fad22f1df3b65a688fb5 Mon Sep 17 00:00:00 2001 From: emmanuelle Date: Sun, 1 Feb 2015 23:11:34 +0100 Subject: [PATCH] Removed a few redundant lines. --- skimage/restoration/non_local_means.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/skimage/restoration/non_local_means.py b/skimage/restoration/non_local_means.py index a94437c5..2ba98a11 100644 --- a/skimage/restoration/non_local_means.py +++ b/skimage/restoration/non_local_means.py @@ -59,7 +59,7 @@ def nl_means_denoising(image, patch_size=7, patch_distance=11, h=0.1, Hence, changing the size of patches or their maximal distance has a strong effect on computing times, especially for 3-D images. - However, the default behavior corresponds to ``fast=True``, for which + However, the default behavior corresponds to ``fast_mode=True``, for which another version of non-local means [2]_ is used, corresponding to a complexity of @@ -99,27 +99,22 @@ def nl_means_denoising(image, patch_size=7, patch_distance=11, h=0.1, """ 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: # 2-D images if fast_mode: return np.squeeze(np.array(_fast_nl_means_denoising_2d(image, - s=patch_size, d=patch_distance, h=h))) + patch_size, patch_distance, h))) else: return np.squeeze(np.array(_nl_means_denoising_2d(image, - s=patch_size, d=patch_distance, h=h))) - elif image.ndim == 3 and not multichannel: # only grayscale + patch_size, patch_distance, h))) + else: # 3-D grayscale if 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)) - if image.ndim == 3 and multichannel: # 2-D color (RGB) images - if fast_mode: - return np.array(_fast_nl_means_denoising_2d(image, patch_size, - patch_distance, h)) - else: - return np.array(_nl_means_denoising_2d(image, patch_size, - patch_distance, h)) - else: - raise NotImplementedError("Non-local means denoising is only \ - implemented for 2D grayscale and RGB images or 3-D grayscale images.")