diff --git a/skimage/filter/rank/__init__.py b/skimage/filter/rank/__init__.py index 9ad816ce..023127e7 100644 --- a/skimage/filter/rank/__init__.py +++ b/skimage/filter/rank/__init__.py @@ -1,9 +1,9 @@ from .generic import (autolevel, bottomhat, equalize, gradient, maximum, mean, - meansubtraction, median, minimum, modal, morph_contr_enh, + subtract_mean, median, minimum, modal, enhance_contrast, pop, threshold, tophat, noise_filter, entropy, otsu) from .percentile import (percentile_autolevel, percentile_gradient, - percentile_mean, percentile_mean_subtraction, - percentile_morph_contr_enh, percentile, + percentile_mean, percentile_subtract_mean, + percentile_enhance_contrast, percentile, percentile_pop, percentile_threshold) from .bilateral import bilateral_mean, bilateral_pop @@ -14,11 +14,11 @@ __all__ = ['autolevel', 'gradient', 'maximum', 'mean', - 'meansubtraction', + 'subtract_mean', 'median', 'minimum', 'modal', - 'morph_contr_enh', + 'enhance_contrast', 'pop', 'threshold', 'tophat', @@ -28,8 +28,8 @@ __all__ = ['autolevel', 'percentile_autolevel', 'percentile_gradient', 'percentile_mean', - 'percentile_mean_subtraction', - 'percentile_morph_contr_enh', + 'percentile_subtract_mean', + 'percentile_enhance_contrast', 'percentile', 'percentile_pop', 'percentile_threshold', diff --git a/skimage/filter/rank/generic.py b/skimage/filter/rank/generic.py index 44a4e05b..f22dcc4c 100644 --- a/skimage/filter/rank/generic.py +++ b/skimage/filter/rank/generic.py @@ -23,7 +23,7 @@ from . import generic_cy __all__ = ['autolevel', 'bottomhat', 'equalize', 'gradient', 'maximum', 'mean', - 'meansubtraction', 'median', 'minimum', 'modal', 'morph_contr_enh', + 'subtract_mean', 'median', 'minimum', 'modal', 'enhance_contrast', 'pop', 'threshold', 'tophat', 'noise_filter', 'entropy', 'otsu'] @@ -294,7 +294,7 @@ def mean(image, selem, out=None, mask=None, shift_x=False, shift_y=False): mask=mask, shift_x=shift_x, shift_y=shift_y) -def meansubtraction(image, selem, out=None, mask=None, shift_x=False, +def subtract_mean(image, selem, out=None, mask=None, shift_x=False, shift_y=False): """Return image subtracted from its local mean. @@ -317,11 +317,11 @@ def meansubtraction(image, selem, out=None, mask=None, shift_x=False, Returns ------- out : ndarray (same dtype as input image) - The result of the local meansubtraction. + The result of the local mean subtraction. """ - return _apply(generic_cy._meansubtraction, image, selem, + return _apply(generic_cy._subtract_mean, image, selem, out=out, mask=mask, shift_x=shift_x, shift_y=shift_y) @@ -434,7 +434,7 @@ def modal(image, selem, out=None, mask=None, shift_x=False, shift_y=False): out=out, mask=mask, shift_x=shift_x, shift_y=shift_y) -def morph_contr_enh(image, selem, out=None, mask=None, shift_x=False, +def enhance_contrast(image, selem, out=None, mask=None, shift_x=False, shift_y=False): """Enhance an image replacing each pixel by the local maximum if pixel greylevel is closest to maximimum than local minimum OR local minimum @@ -459,21 +459,21 @@ def morph_contr_enh(image, selem, out=None, mask=None, shift_x=False, Returns ------- out : ndarray (same dtype as input image) - The result of the local morph_contr_enh. + The result of the local enhance_contrast. Examples -------- >>> from skimage import data >>> from skimage.morphology import disk - >>> from skimage.filter.rank import morph_contr_enh + >>> from skimage.filter.rank import enhance_contrast >>> # Load test image >>> ima = data.camera() >>> # Local mean - >>> avg = morph_contr_enh(ima, disk(20)) + >>> avg = enhance_contrast(ima, disk(20)) """ - return _apply(generic_cy._morph_contr_enh, image, selem, + return _apply(generic_cy._enhance_contrast, image, selem, out=out, mask=mask, shift_x=shift_x, shift_y=shift_y) diff --git a/skimage/filter/rank/generic_cy.pyx b/skimage/filter/rank/generic_cy.pyx index 0e972c30..ffb52cc8 100644 --- a/skimage/filter/rank/generic_cy.pyx +++ b/skimage/filter/rank/generic_cy.pyx @@ -122,11 +122,11 @@ cdef inline dtype_t _kernel_mean(Py_ssize_t* histo, float pop, dtype_t g, return (0) -cdef inline dtype_t _kernel_meansubtraction(Py_ssize_t* histo, float pop, - dtype_t g, Py_ssize_t max_bin, - Py_ssize_t mid_bin, float p0, - float p1, Py_ssize_t s0, - Py_ssize_t s1): +cdef inline dtype_t _kernel_subtract_mean(Py_ssize_t* histo, float pop, + dtype_t g, Py_ssize_t max_bin, + Py_ssize_t mid_bin, float p0, + float p1, Py_ssize_t s0, + Py_ssize_t s1): cdef Py_ssize_t i cdef Py_ssize_t mean = 0 @@ -189,11 +189,11 @@ cdef inline dtype_t _kernel_modal(Py_ssize_t* histo, float pop, dtype_t g, return (0) -cdef inline dtype_t _kernel_morph_contr_enh(Py_ssize_t* histo, float pop, - dtype_t g, Py_ssize_t max_bin, - Py_ssize_t mid_bin, float p0, - float p1, Py_ssize_t s0, - Py_ssize_t s1): +cdef inline dtype_t _kernel_enhance_contrast(Py_ssize_t* histo, float pop, + dtype_t g, Py_ssize_t max_bin, + Py_ssize_t mid_bin, float p0, + float p1, Py_ssize_t s0, + Py_ssize_t s1): cdef Py_ssize_t i, imin, imax @@ -422,17 +422,17 @@ def _mean(dtype_t[:, ::1] image, shift_x, shift_y, 0, 0, 0, 0, max_bin) -def _meansubtraction(dtype_t[:, ::1] image, - char[:, ::1] selem, - char[:, ::1] mask, - dtype_t[:, ::1] out, - char shift_x, char shift_y, Py_ssize_t max_bin): +def _subtract_mean(dtype_t[:, ::1] image, + char[:, ::1] selem, + char[:, ::1] mask, + dtype_t[:, ::1] out, + char shift_x, char shift_y, Py_ssize_t max_bin): if dtype_t is uint8_t: - _core[uint8_t](_kernel_meansubtraction[uint8_t], image, selem, mask, + _core[uint8_t](_kernel_subtract_mean[uint8_t], image, selem, mask, out, shift_x, shift_y, 0, 0, 0, 0, max_bin) elif dtype_t is uint16_t: - _core[uint16_t](_kernel_meansubtraction[uint16_t], image, selem, mask, + _core[uint16_t](_kernel_subtract_mean[uint16_t], image, selem, mask, out, shift_x, shift_y, 0, 0, 0, 0, max_bin) @@ -464,17 +464,17 @@ def _minimum(dtype_t[:, ::1] image, shift_x, shift_y, 0, 0, 0, 0, max_bin) -def _morph_contr_enh(dtype_t[:, ::1] image, - char[:, ::1] selem, - char[:, ::1] mask, - dtype_t[:, ::1] out, - char shift_x, char shift_y, Py_ssize_t max_bin): +def _enhance_contrast(dtype_t[:, ::1] image, + char[:, ::1] selem, + char[:, ::1] mask, + dtype_t[:, ::1] out, + char shift_x, char shift_y, Py_ssize_t max_bin): if dtype_t is uint8_t: - _core[uint8_t](_kernel_morph_contr_enh[uint8_t], image, selem, mask, + _core[uint8_t](_kernel_enhance_contrast[uint8_t], image, selem, mask, out, shift_x, shift_y, 0, 0, 0, 0, max_bin) elif dtype_t is uint16_t: - _core[uint16_t](_kernel_morph_contr_enh[uint16_t], image, selem, mask, + _core[uint16_t](_kernel_enhance_contrast[uint16_t], image, selem, mask, out, shift_x, shift_y, 0, 0, 0, 0, max_bin) diff --git a/skimage/filter/rank/percentile.py b/skimage/filter/rank/percentile.py index 10c4bb9e..73929b0a 100644 --- a/skimage/filter/rank/percentile.py +++ b/skimage/filter/rank/percentile.py @@ -28,8 +28,8 @@ from .generic import _handle_input __all__ = ['percentile_autolevel', 'percentile_gradient', - 'percentile_mean', 'percentile_mean_subtraction', - 'percentile_morph_contr_enh', 'percentile', 'percentile_pop', + 'percentile_mean', 'percentile_subtract_mean', + 'percentile_enhance_contrast', 'percentile', 'percentile_pop', 'percentile_threshold'] @@ -157,11 +157,11 @@ def percentile_mean(image, selem, out=None, mask=None, shift_x=False, shift_y=shift_y, p0=p0, p1=p1) -def percentile_mean_subtraction(image, selem, out=None, mask=None, +def percentile_subtract_mean(image, selem, out=None, mask=None, shift_x=False, shift_y=False, p0=0, p1=1): - """Return greyscale local mean_subtraction of an image. + """Return greyscale local subtract_mean of an image. - mean_subtraction is computed on the given structuring element. Only levels + subtract_mean is computed on the given structuring element. Only levels between percentiles [p0, p1] are used. Parameters @@ -185,21 +185,21 @@ def percentile_mean_subtraction(image, selem, out=None, mask=None, Returns ------- - local mean_subtraction : ndarray (same dtype as input) - The result of the local mean_subtraction. + local subtract_mean : ndarray (same dtype as input) + The result of the local subtract_mean. """ - return _apply(percentile_cy._mean_subtraction, + return _apply(percentile_cy._subtract_mean, image, selem, out=out, mask=mask, shift_x=shift_x, shift_y=shift_y, p0=p0, p1=p1) -def percentile_morph_contr_enh(image, selem, out=None, mask=None, +def percentile_enhance_contrast(image, selem, out=None, mask=None, shift_x=False, shift_y=False, p0=0, p1=1): - """Return greyscale local morph_contr_enh of an image. + """Return greyscale local enhance_contrast of an image. - morph_contr_enh is computed on the given structuring element. Only levels + enhance_contrast is computed on the given structuring element. Only levels between percentiles [p0, p1] are used. Parameters @@ -223,12 +223,12 @@ def percentile_morph_contr_enh(image, selem, out=None, mask=None, Returns ------- - local morph_contr_enh : ndarray (same dtype as input) - The result of the local morph_contr_enh. + local enhance_contrast : ndarray (same dtype as input) + The result of the local enhance_contrast. """ - return _apply(percentile_cy._morph_contr_enh, + return _apply(percentile_cy._enhance_contrast, image, selem, out=out, mask=mask, shift_x=shift_x, shift_y=shift_y, p0=p0, p1=p1) diff --git a/skimage/filter/rank/percentile_cy.pyx b/skimage/filter/rank/percentile_cy.pyx index 6df271fa..bb4419de 100644 --- a/skimage/filter/rank/percentile_cy.pyx +++ b/skimage/filter/rank/percentile_cy.pyx @@ -91,11 +91,11 @@ cdef inline dtype_t _kernel_mean(Py_ssize_t* histo, float pop, dtype_t g, return (0) -cdef inline dtype_t _kernel_mean_subtraction(Py_ssize_t* histo, float pop, - dtype_t g, Py_ssize_t max_bin, - Py_ssize_t mid_bin, float p0, - float p1, Py_ssize_t s0, - Py_ssize_t s1): +cdef inline dtype_t _kernel_subtract_mean(Py_ssize_t* histo, float pop, + dtype_t g, Py_ssize_t max_bin, + Py_ssize_t mid_bin, float p0, + float p1, Py_ssize_t s0, + Py_ssize_t s1): cdef Py_ssize_t i, sum, mean, n @@ -116,11 +116,11 @@ cdef inline dtype_t _kernel_mean_subtraction(Py_ssize_t* histo, float pop, return (0) -cdef inline dtype_t _kernel_morph_contr_enh(Py_ssize_t* histo, float pop, - dtype_t g, Py_ssize_t max_bin, - Py_ssize_t mid_bin, float p0, - float p1, Py_ssize_t s0, - Py_ssize_t s1): +cdef inline dtype_t _kernel_enhance_contrast(Py_ssize_t* histo, float pop, + dtype_t g, Py_ssize_t max_bin, + Py_ssize_t mid_bin, float p0, + float p1, Py_ssize_t s0, + Py_ssize_t s1): cdef Py_ssize_t i, imin, imax, sum, delta @@ -252,22 +252,22 @@ def _mean(dtype_t[:, ::1] image, shift_x, shift_y, p0, p1, 0, 0, max_bin) -def _mean_subtraction(dtype_t[:, ::1] image, - char[:, ::1] selem, - char[:, ::1] mask, - dtype_t[:, ::1] out, - char shift_x, char shift_y, float p0, float p1, - Py_ssize_t max_bin): +def _subtract_mean(dtype_t[:, ::1] image, + char[:, ::1] selem, + char[:, ::1] mask, + dtype_t[:, ::1] out, + char shift_x, char shift_y, float p0, float p1, + Py_ssize_t max_bin): if dtype_t is uint8_t: - _core[uint8_t](_kernel_mean_subtraction[uint8_t], image, selem, mask, + _core[uint8_t](_kernel_subtract_mean[uint8_t], image, selem, mask, out, shift_x, shift_y, p0, p1, 0, 0, max_bin) elif dtype_t is uint16_t: - _core[uint16_t](_kernel_mean_subtraction[uint16_t], image, selem, mask, + _core[uint16_t](_kernel_subtract_mean[uint16_t], image, selem, mask, out, shift_x, shift_y, p0, p1, 0, 0, max_bin) -def _morph_contr_enh(dtype_t[:, ::1] image, +def _enhance_contrast(dtype_t[:, ::1] image, char[:, ::1] selem, char[:, ::1] mask, dtype_t[:, ::1] out, @@ -275,10 +275,10 @@ def _morph_contr_enh(dtype_t[:, ::1] image, Py_ssize_t max_bin): if dtype_t is uint8_t: - _core[uint8_t](_kernel_morph_contr_enh[uint8_t], image, selem, mask, + _core[uint8_t](_kernel_enhance_contrast[uint8_t], image, selem, mask, out, shift_x, shift_y, p0, p1, 0, 0, max_bin) elif dtype_t is uint16_t: - _core[uint16_t](_kernel_morph_contr_enh[uint16_t], image, selem, mask, + _core[uint16_t](_kernel_enhance_contrast[uint16_t], image, selem, mask, out, shift_x, shift_y, p0, p1, 0, 0, max_bin) diff --git a/skimage/filter/rank/tests/test_rank.py b/skimage/filter/rank/tests/test_rank.py index f55d3522..166fe67d 100644 --- a/skimage/filter/rank/tests/test_rank.py +++ b/skimage/filter/rank/tests/test_rank.py @@ -183,7 +183,7 @@ def test_compare_ubyte_vs_float(): image_float = img_as_float(image_uint) methods = ['autolevel', 'bottomhat', 'equalize', 'gradient', 'threshold', - 'meansubtraction', 'morph_contr_enh', 'pop', 'tophat'] + 'subtract_mean', 'enhance_contrast', 'pop', 'tophat'] for method in methods: func = getattr(rank, method) @@ -205,8 +205,8 @@ def test_compare_8bit_unsigned_vs_signed(): assert_array_equal(image_u, img_as_ubyte(image_s)) methods = ['autolevel', 'bottomhat', 'equalize', 'gradient', 'maximum', - 'mean', 'meansubtraction', 'median', 'minimum', 'modal', - 'morph_contr_enh', 'pop', 'threshold', 'tophat'] + 'mean', 'subtract_mean', 'median', 'minimum', 'modal', + 'enhance_contrast', 'pop', 'threshold', 'tophat'] for method in methods: func = getattr(rank, method) @@ -224,8 +224,8 @@ def test_compare_8bit_vs_16bit(): assert_array_equal(image8, image16) methods = ['autolevel', 'bottomhat', 'equalize', 'gradient', 'maximum', - 'mean', 'meansubtraction', 'median', 'minimum', 'modal', - 'morph_contr_enh', 'pop', 'threshold', 'tophat'] + 'mean', 'subtract_mean', 'median', 'minimum', 'modal', + 'enhance_contrast', 'pop', 'threshold', 'tophat'] for method in methods: func = getattr(rank, method)