From e23c4f3841260c63b40775fbbc6563c6b648b11f Mon Sep 17 00:00:00 2001 From: Olivier Debeir Date: Fri, 10 May 2013 09:10:26 +0200 Subject: [PATCH 1/4] fix:doctring rank/percentile --- skimage/filter/rank/percentile_rank.pyx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/skimage/filter/rank/percentile_rank.pyx b/skimage/filter/rank/percentile_rank.pyx index 9db81bcc..61af0574 100644 --- a/skimage/filter/rank/percentile_rank.pyx +++ b/skimage/filter/rank/percentile_rank.pyx @@ -278,8 +278,8 @@ def percentile(image, selem, out=None, mask=None, shift_x=False, shift_y=False, p0=.0, p1=1.): """Return greyscale local percentile of an image. - percentile is computed on the given structuring element. Only levels between - percentiles [p0, p1] are used. + percentile is computed on the given structuring element. Returns the value of the p0 lower percentile of the + neighborhood value distribution. Parameters ---------- @@ -299,8 +299,7 @@ def percentile(image, selem, out=None, mask=None, shift_x=False, shift_y=False, to the structuring element sizes (center must be inside the given structuring element). p0, p1 : float in [0, ..., 1] - Define the [p0, p1] percentile interval to be considered for computing - the value. + Define the percentile p0. The p1 value in unused. Returns ------- @@ -359,8 +358,9 @@ def percentile_threshold(image, selem, out=None, mask=None, shift_x=False, shift_y=False, p0=.0, p1=1.): """Return greyscale local threshold of an image. - threshold is computed on the given structuring element. Only levels between - percentiles [p0, p1] are used. + threshold is computed on the given structuring element. Returns thresholded image such that pixels + having a higher value than the the p0 percentile of the neighborhood value distribution are set to 2^nbit-1 + (e.g. 255 for 8bit image). Parameters ---------- @@ -380,8 +380,7 @@ def percentile_threshold(image, selem, out=None, mask=None, shift_x=False, to the structuring element sizes (center must be inside the given structuring element). p0, p1 : float in [0, ..., 1] - Define the [p0, p1] percentile interval to be considered for computing - the value. + Define the percentile p0. The p1 value in unused. Returns ------- From 59b37afea85d20040767466ca45441484e47ae78 Mon Sep 17 00:00:00 2001 From: Olivier Debeir Date: Fri, 10 May 2013 16:02:27 +0200 Subject: [PATCH 2/4] typo --- skimage/filter/rank/percentile_rank.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skimage/filter/rank/percentile_rank.pyx b/skimage/filter/rank/percentile_rank.pyx index 61af0574..f9ac9d40 100644 --- a/skimage/filter/rank/percentile_rank.pyx +++ b/skimage/filter/rank/percentile_rank.pyx @@ -299,7 +299,7 @@ def percentile(image, selem, out=None, mask=None, shift_x=False, shift_y=False, to the structuring element sizes (center must be inside the given structuring element). p0, p1 : float in [0, ..., 1] - Define the percentile p0. The p1 value in unused. + Define the percentile p0. The p1 value is unused. Returns ------- @@ -380,7 +380,7 @@ def percentile_threshold(image, selem, out=None, mask=None, shift_x=False, to the structuring element sizes (center must be inside the given structuring element). p0, p1 : float in [0, ..., 1] - Define the percentile p0. The p1 value in unused. + Define the percentile p0. The p1 value is unused. Returns ------- From cdca3f9d40123606e303aa6db1c00b3c959a7a80 Mon Sep 17 00:00:00 2001 From: Olivier Debeir Date: Fri, 10 May 2013 16:04:15 +0200 Subject: [PATCH 3/4] remove long lines --- skimage/filter/rank/percentile_rank.pyx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/skimage/filter/rank/percentile_rank.pyx b/skimage/filter/rank/percentile_rank.pyx index f9ac9d40..a432ed72 100644 --- a/skimage/filter/rank/percentile_rank.pyx +++ b/skimage/filter/rank/percentile_rank.pyx @@ -278,8 +278,8 @@ def percentile(image, selem, out=None, mask=None, shift_x=False, shift_y=False, p0=.0, p1=1.): """Return greyscale local percentile of an image. - percentile is computed on the given structuring element. Returns the value of the p0 lower percentile of the - neighborhood value distribution. + percentile is computed on the given structuring element. Returns the value + of the p0 lower percentile of the neighborhood value distribution. Parameters ---------- @@ -358,8 +358,9 @@ def percentile_threshold(image, selem, out=None, mask=None, shift_x=False, shift_y=False, p0=.0, p1=1.): """Return greyscale local threshold of an image. - threshold is computed on the given structuring element. Returns thresholded image such that pixels - having a higher value than the the p0 percentile of the neighborhood value distribution are set to 2^nbit-1 + threshold is computed on the given structuring element. Returns + thresholded image such that pixels having a higher value than the the p0 + percentile of the neighborhood value distribution are set to 2^nbit-1 (e.g. 255 for 8bit image). Parameters From 809e285250be4c511fb41ae43418ee4fd43f7f1a Mon Sep 17 00:00:00 2001 From: Olivier Debeir Date: Fri, 10 May 2013 16:23:10 +0200 Subject: [PATCH 4/4] fix:remove unused parameters in rank.percentile --- skimage/filter/rank/_crank16_percentiles.pyx | 8 ++++---- skimage/filter/rank/_crank8_percentiles.pyx | 8 ++++---- skimage/filter/rank/percentile_rank.pyx | 16 ++++++++-------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/skimage/filter/rank/_crank16_percentiles.pyx b/skimage/filter/rank/_crank16_percentiles.pyx index 0ab71353..15dabe72 100644 --- a/skimage/filter/rank/_crank16_percentiles.pyx +++ b/skimage/filter/rank/_crank16_percentiles.pyx @@ -299,11 +299,11 @@ def percentile(cnp.ndarray[dtype_t, ndim=2] image, cnp.ndarray[cnp.uint8_t, ndim=2] mask=None, cnp.ndarray[dtype_t, ndim=2] out=None, char shift_x=0, char shift_y=0, int bitdepth=8, - float p0=0., float p1=0.): + float p0=0.): """return p0 percentile """ _core16(kernel_percentile, image, selem, mask, out, shift_x, shift_y, - bitdepth, p0, p1, 0, 0) + bitdepth, p0, .0, 0, 0) def pop(cnp.ndarray[dtype_t, ndim=2] image, @@ -323,8 +323,8 @@ def threshold(cnp.ndarray[dtype_t, ndim=2] image, cnp.ndarray[cnp.uint8_t, ndim=2] mask=None, cnp.ndarray[dtype_t, ndim=2] out=None, char shift_x=0, char shift_y=0, int bitdepth=8, - float p0=0., float p1=0.): + float p0=0.): """return (maxbin-1) if g > percentile p0 """ _core16(kernel_threshold, image, selem, mask, out, shift_x, shift_y, - bitdepth, p0, p1, 0, 0) + bitdepth, p0, 0., 0, 0) diff --git a/skimage/filter/rank/_crank8_percentiles.pyx b/skimage/filter/rank/_crank8_percentiles.pyx index d085957e..1a71e0fa 100644 --- a/skimage/filter/rank/_crank8_percentiles.pyx +++ b/skimage/filter/rank/_crank8_percentiles.pyx @@ -265,11 +265,11 @@ def percentile(cnp.ndarray[dtype_t, ndim=2] image, cnp.ndarray[dtype_t, ndim=2] selem, cnp.ndarray[dtype_t, ndim=2] mask=None, cnp.ndarray[dtype_t, ndim=2] out=None, - char shift_x=0, char shift_y=0, float p0=0., float p1=0.): + char shift_x=0, char shift_y=0, float p0=0.): """return p0 percentile """ _core8(kernel_percentile, image, selem, mask, out, shift_x, shift_y, - p0, p1, 0, 0) + p0, 0., 0, 0) def pop(cnp.ndarray[dtype_t, ndim=2] image, @@ -287,8 +287,8 @@ def threshold(cnp.ndarray[dtype_t, ndim=2] image, cnp.ndarray[dtype_t, ndim=2] selem, cnp.ndarray[dtype_t, ndim=2] mask=None, cnp.ndarray[dtype_t, ndim=2] out=None, - char shift_x=0, char shift_y=0, float p0=0., float p1=0.): + char shift_x=0, char shift_y=0, float p0=0.): """return 255 if g > percentile p0 """ - _core8(kernel_threshold, image, selem, mask, out, shift_x, shift_y, p0, p1, + _core8(kernel_threshold, image, selem, mask, out, shift_x, shift_y, p0, 0., 0, 0) diff --git a/skimage/filter/rank/percentile_rank.pyx b/skimage/filter/rank/percentile_rank.pyx index a432ed72..4b3cace4 100644 --- a/skimage/filter/rank/percentile_rank.pyx +++ b/skimage/filter/rank/percentile_rank.pyx @@ -275,7 +275,7 @@ def percentile_morph_contr_enh( def percentile(image, selem, out=None, mask=None, shift_x=False, shift_y=False, - p0=.0, p1=1.): + p0=.0): """Return greyscale local percentile of an image. percentile is computed on the given structuring element. Returns the value @@ -298,8 +298,8 @@ def percentile(image, selem, out=None, mask=None, shift_x=False, shift_y=False, Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element). - p0, p1 : float in [0, ..., 1] - Define the percentile p0. The p1 value is unused. + p0 : float in [0, ..., 1] + Set the percentile value. Returns ------- @@ -311,7 +311,7 @@ def percentile(image, selem, out=None, mask=None, shift_x=False, shift_y=False, return _apply(_crank8_percentiles.percentile, _crank16_percentiles.percentile, image, selem, out=out, mask=mask, shift_x=shift_x, - shift_y=shift_y, p0=p0, p1=p1) + shift_y=shift_y, p0=p0, p1=0.) def percentile_pop(image, selem, out=None, mask=None, shift_x=False, @@ -355,7 +355,7 @@ def percentile_pop(image, selem, out=None, mask=None, shift_x=False, def percentile_threshold(image, selem, out=None, mask=None, shift_x=False, - shift_y=False, p0=.0, p1=1.): + shift_y=False, p0=.0): """Return greyscale local threshold of an image. threshold is computed on the given structuring element. Returns @@ -380,8 +380,8 @@ def percentile_threshold(image, selem, out=None, mask=None, shift_x=False, Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element). - p0, p1 : float in [0, ..., 1] - Define the percentile p0. The p1 value is unused. + p0 : float in [0, ..., 1] + Set the percentile value. Returns ------- @@ -393,4 +393,4 @@ def percentile_threshold(image, selem, out=None, mask=None, shift_x=False, return _apply( _crank8_percentiles.threshold, _crank16_percentiles.threshold, image, selem, out=out, mask=mask, shift_x=shift_x, - shift_y=shift_y, p0=p0, p1=p1) + shift_y=shift_y, p0=p0, p1=0.)