From 6ee96054c9633a662432e52572788d4840c92013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 7 Jul 2013 18:42:35 +0200 Subject: [PATCH] Append percentile, bilateral function name part --- skimage/filter/rank/__init__.py | 32 +++++++++++++------------- skimage/filter/rank/bilateral.py | 6 ++--- skimage/filter/rank/percentile.py | 32 +++++++++++++------------- skimage/filter/rank/tests/test_rank.py | 20 ++++++++-------- 4 files changed, 45 insertions(+), 45 deletions(-) diff --git a/skimage/filter/rank/__init__.py b/skimage/filter/rank/__init__.py index 023127e7..b25abb8c 100644 --- a/skimage/filter/rank/__init__.py +++ b/skimage/filter/rank/__init__.py @@ -1,37 +1,37 @@ from .generic import (autolevel, bottomhat, equalize, gradient, maximum, mean, subtract_mean, median, minimum, modal, enhance_contrast, pop, threshold, tophat, noise_filter, entropy, otsu) -from .percentile import (percentile_autolevel, percentile_gradient, - percentile_mean, percentile_subtract_mean, - percentile_enhance_contrast, percentile, - percentile_pop, percentile_threshold) -from .bilateral import bilateral_mean, bilateral_pop +from .percentile import (autolevel_percentile, gradient_percentile, + mean_percentile, subtract_mean_percentile, + enhance_contrast_percentile, percentile, + pop_percentile, threshold_percentile) +from .bilateral import mean_bilateral, pop_bilateral __all__ = ['autolevel', + 'autolevel_percentile', 'bottomhat', 'equalize', 'gradient', + 'gradient_percentile', 'maximum', 'mean', + 'mean_percentile', + 'mean_bilateral', 'subtract_mean', + 'subtract_mean_percentile', 'median', 'minimum', 'modal', 'enhance_contrast', + 'enhance_contrast_percentile', 'pop', + 'pop_percentile', + 'pop_bilateral', 'threshold', + 'threshold_percentile', 'tophat', 'noise_filter', 'entropy', - 'otsu', - 'percentile_autolevel', - 'percentile_gradient', - 'percentile_mean', - 'percentile_subtract_mean', - 'percentile_enhance_contrast', - 'percentile', - 'percentile_pop', - 'percentile_threshold', - 'bilateral_mean', - 'bilateral_pop'] + 'otsu' + 'percentile'] diff --git a/skimage/filter/rank/bilateral.py b/skimage/filter/rank/bilateral.py index 560bc68c..f0bc2b38 100644 --- a/skimage/filter/rank/bilateral.py +++ b/skimage/filter/rank/bilateral.py @@ -27,7 +27,7 @@ from . import bilateral_cy from .generic import _handle_input -__all__ = ['bilateral_mean', 'bilateral_pop'] +__all__ = ['mean_bilateral', 'pop_bilateral'] def _apply(func, image, selem, out, mask, shift_x, shift_y, s0, s1): @@ -40,7 +40,7 @@ def _apply(func, image, selem, out, mask, shift_x, shift_y, s0, s1): return out -def bilateral_mean(image, selem, out=None, mask=None, shift_x=False, +def mean_bilateral(image, selem, out=None, mask=None, shift_x=False, shift_y=False, s0=10, s1=10): """Apply a flat kernel bilateral filter. @@ -99,7 +99,7 @@ def bilateral_mean(image, selem, out=None, mask=None, shift_x=False, mask=mask, shift_x=shift_x, shift_y=shift_y, s0=s0, s1=s1) -def bilateral_pop(image, selem, out=None, mask=None, shift_x=False, +def pop_bilateral(image, selem, out=None, mask=None, shift_x=False, shift_y=False, s0=10, s1=10): """Return the number (population) of pixels actually inside the bilateral neighborhood, i.e. being inside the structuring element AND having a gray diff --git a/skimage/filter/rank/percentile.py b/skimage/filter/rank/percentile.py index b01d314d..e91e0d82 100644 --- a/skimage/filter/rank/percentile.py +++ b/skimage/filter/rank/percentile.py @@ -1,6 +1,6 @@ """Inferior and superior ranks, provided by the user, are passed to the kernel function to provide a softer version of the rank filters. E.g. -percentile_autolevel will stretch image levels between percentile [p0, p1] +``autolevel_percentile`` will stretch image levels between percentile [p0, p1] instead of using [min, max]. It means that isolated bright or dark pixels will not produce halos. @@ -27,10 +27,10 @@ from . import percentile_cy from .generic import _handle_input -__all__ = ['percentile_autolevel', 'percentile_gradient', - 'percentile_mean', 'percentile_subtract_mean', - 'percentile_enhance_contrast', 'percentile', 'percentile_pop', - 'percentile_threshold'] +__all__ = ['autolevel_percentile', 'gradient_percentile', + 'mean_percentile', 'subtract_mean_percentile', + 'enhance_contrast_percentile', 'percentile', 'pop_percentile', + 'threshold_percentile'] def _apply(func, image, selem, out, mask, shift_x, shift_y, p0, p1): @@ -43,7 +43,7 @@ def _apply(func, image, selem, out, mask, shift_x, shift_y, p0, p1): return out -def percentile_autolevel(image, selem, out=None, mask=None, shift_x=False, +def autolevel_percentile(image, selem, out=None, mask=None, shift_x=False, shift_y=False, p0=0, p1=1): """Return greyscale local autolevel of an image. @@ -81,11 +81,11 @@ def percentile_autolevel(image, selem, out=None, mask=None, shift_x=False, shift_y=shift_y, p0=p0, p1=p1) -def percentile_gradient(image, selem, out=None, mask=None, shift_x=False, +def gradient_percentile(image, selem, out=None, mask=None, shift_x=False, shift_y=False, p0=0, p1=1): - """Return greyscale local percentile_gradient of an image. + """Return greyscale local gradient of an image. - percentile_gradient is computed on the given structuring element. Only + gradient is computed on the given structuring element. Only levels between percentiles [p0, p1] are used. Parameters @@ -119,7 +119,7 @@ def percentile_gradient(image, selem, out=None, mask=None, shift_x=False, shift_y=shift_y, p0=p0, p1=p1) -def percentile_mean(image, selem, out=None, mask=None, shift_x=False, +def mean_percentile(image, selem, out=None, mask=None, shift_x=False, shift_y=False, p0=0, p1=1): """Return greyscale local mean of an image. @@ -157,8 +157,8 @@ def percentile_mean(image, selem, out=None, mask=None, shift_x=False, shift_y=shift_y, p0=p0, p1=p1) -def percentile_subtract_mean(image, selem, out=None, mask=None, - shift_x=False, shift_y=False, p0=0, p1=1): +def subtract_mean_percentile(image, selem, out=None, mask=None, + shift_x=False, shift_y=False, p0=0, p1=1): """Return greyscale local subtract_mean of an image. subtract_mean is computed on the given structuring element. Only levels @@ -195,8 +195,8 @@ def percentile_subtract_mean(image, selem, out=None, mask=None, shift_y=shift_y, p0=p0, p1=p1) -def percentile_enhance_contrast(image, selem, out=None, mask=None, - shift_x=False, shift_y=False, p0=0, p1=1): +def enhance_contrast_percentile(image, selem, out=None, mask=None, + shift_x=False, shift_y=False, p0=0, p1=1): """Return greyscale local enhance_contrast of an image. enhance_contrast is computed on the given structuring element. Only levels @@ -270,7 +270,7 @@ def percentile(image, selem, out=None, mask=None, shift_x=False, shift_y=False, shift_y=shift_y, p0=p0, p1=0.) -def percentile_pop(image, selem, out=None, mask=None, shift_x=False, +def pop_percentile(image, selem, out=None, mask=None, shift_x=False, shift_y=False, p0=0, p1=1): """Return greyscale local pop of an image. @@ -308,7 +308,7 @@ def percentile_pop(image, selem, out=None, mask=None, shift_x=False, shift_y=shift_y, p0=p0, p1=p1) -def percentile_threshold(image, selem, out=None, mask=None, shift_x=False, +def threshold_percentile(image, selem, out=None, mask=None, shift_x=False, shift_y=False, p0=0): """Return greyscale local threshold of an image. diff --git a/skimage/filter/rank/tests/test_rank.py b/skimage/filter/rank/tests/test_rank.py index 166fe67d..d2906f98 100644 --- a/skimage/filter/rank/tests/test_rank.py +++ b/skimage/filter/rank/tests/test_rank.py @@ -33,10 +33,10 @@ def test_random_sizes(): shift_x=+1, shift_y=+1) assert_array_equal(image16.shape, out16.shape) - rank.percentile_mean(image=image16, mask=mask, out=out16, + rank.mean_percentile(image=image16, mask=mask, out=out16, selem=elem, shift_x=0, shift_y=0, p0=.1, p1=.9) assert_array_equal(image16.shape, out16.shape) - rank.percentile_mean(image=image16, mask=mask, out=out16, + rank.mean_percentile(image=image16, mask=mask, out=out16, selem=elem, shift_x=+1, shift_y=+1, p0=.1, p1=.9) assert_array_equal(image16.shape, out16.shape) @@ -78,7 +78,7 @@ def test_bitdepth(): for i in range(5): image = np.ones((100, 100), dtype=np.uint16) * 255 * 2 ** i - r = rank.percentile_mean(image=image, selem=elem, mask=mask, + r = rank.mean_percentile(image=image, selem=elem, mask=mask, out=out, shift_x=0, shift_y=0, p0=.1, p1=.9) @@ -156,7 +156,7 @@ def test_compare_autolevels(): selem = disk(20) loc_autolevel = rank.autolevel(image, selem=selem) - loc_perc_autolevel = rank.percentile_autolevel(image, selem=selem, + loc_perc_autolevel = rank.autolevel_percentile(image, selem=selem, p0=.0, p1=1.) assert_array_equal(loc_autolevel, loc_perc_autolevel) @@ -170,7 +170,7 @@ def test_compare_autolevels_16bit(): selem = disk(20) loc_autolevel = rank.autolevel(image, selem=selem) - loc_perc_autolevel = rank.percentile_autolevel(image, selem=selem, + loc_perc_autolevel = rank.autolevel_percentile(image, selem=selem, p0=.0, p1=1.) assert_array_equal(loc_autolevel, loc_perc_autolevel) @@ -418,7 +418,7 @@ def test_selem_dtypes(): rank.mean(image=image, selem=elem, out=out, mask=mask, shift_x=0, shift_y=0) assert_array_equal(image, out) - rank.percentile_mean(image=image, selem=elem, out=out, mask=mask, + rank.mean_percentile(image=image, selem=elem, out=out, mask=mask, shift_x=0, shift_y=0) assert_array_equal(image, out) @@ -443,10 +443,10 @@ def test_bilateral(): image[10, 11] = 1010 image[10, 9] = 900 - assert rank.bilateral_mean(image, selem, s0=1, s1=1)[10, 10] == 1000 - assert rank.bilateral_pop(image, selem, s0=1, s1=1)[10, 10] == 1 - assert rank.bilateral_mean(image, selem, s0=11, s1=11)[10, 10] == 1005 - assert rank.bilateral_pop(image, selem, s0=11, s1=11)[10, 10] == 2 + assert rank.mean_bilateral(image, selem, s0=1, s1=1)[10, 10] == 1000 + assert rank.pop_bilateral(image, selem, s0=1, s1=1)[10, 10] == 1 + assert rank.mean_bilateral(image, selem, s0=11, s1=11)[10, 10] == 1005 + assert rank.pop_bilateral(image, selem, s0=11, s1=11)[10, 10] == 2 if __name__ == "__main__":