diff --git a/skimage/filter/rank/bilateral.py b/skimage/filter/rank/bilateral.py index 386c88bc..e159d512 100644 --- a/skimage/filter/rank/bilateral.py +++ b/skimage/filter/rank/bilateral.py @@ -27,6 +27,9 @@ References import numpy as np from skimage import img_as_ubyte +from ... import get_log +log = get_log() + from . import bilateral16_cy from .generic import find_bitdepth @@ -60,6 +63,9 @@ def _apply(func8, func16, image, selem, out, mask, shift_x, shift_y, s0, s1): if out is None: out = np.zeros(image.shape, dtype=np.uint16) bitdepth = find_bitdepth(image) + if bitdepth > 10: + log.warn("Bitdepth of %d may result in bad rank filter " + "performance." % bitdepth) func16(image, selem, shift_x=shift_x, shift_y=shift_y, mask=mask, bitdepth=bitdepth + 1, out=out, s0=s0, s1=s1) else: diff --git a/skimage/filter/rank/generic.py b/skimage/filter/rank/generic.py index bcfda1bc..d9b3569b 100644 --- a/skimage/filter/rank/generic.py +++ b/skimage/filter/rank/generic.py @@ -17,6 +17,9 @@ References import numpy as np from skimage import img_as_ubyte, img_as_uint +from ... import get_log +log = get_log() + from . import generic8_cy, generic16_cy @@ -60,6 +63,9 @@ def _apply(func8, func16, image, selem, out, mask, shift_x, shift_y): if out is None: out = np.zeros(image.shape, dtype=np.uint16) bitdepth = find_bitdepth(image) + if bitdepth > 10: + log.warn("Bitdepth of %d may result in bad rank filter " + "performance." % bitdepth) func16(image, selem, shift_x=shift_x, shift_y=shift_y, mask=mask, bitdepth=bitdepth + 1, out=out) diff --git a/skimage/filter/rank/percentile.py b/skimage/filter/rank/percentile.py index f302074c..b75d994f 100644 --- a/skimage/filter/rank/percentile.py +++ b/skimage/filter/rank/percentile.py @@ -23,6 +23,9 @@ References import numpy as np from skimage import img_as_ubyte +from ... import get_log +log = get_log() + from . import percentile8_cy, percentile16_cy from .generic import find_bitdepth @@ -59,6 +62,9 @@ def _apply(func8, func16, image, selem, out, mask, shift_x, shift_y, p0, p1): if out is None: out = np.zeros(image.shape, dtype=np.uint16) bitdepth = find_bitdepth(image) + if bitdepth > 10: + log.warn("Bitdepth of %d may result in bad rank filter " + "performance." % bitdepth) func16(image, selem, shift_x=shift_x, shift_y=shift_y, mask=mask, bitdepth=bitdepth + 1, out=out, p0=p0, p1=p1) else: