From db048d367531e0a5941ae8a490e4ef5804d0986c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 18 Dec 2013 14:43:08 +0100 Subject: [PATCH] Improve doc strings of bilateral rank filters --- skimage/filter/rank/bilateral.py | 94 ++++++++++++++++---------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/skimage/filter/rank/bilateral.py b/skimage/filter/rank/bilateral.py index 4509e06b..370ecec0 100644 --- a/skimage/filter/rank/bilateral.py +++ b/skimage/filter/rank/bilateral.py @@ -53,21 +53,22 @@ def mean_bilateral(image, selem, out=None, mask=None, shift_x=False, pixels based on their spatial closeness and radiometric similarity. Spatial closeness is measured by considering only the local pixel - neighborhood given by a structuring element (selem). + neighborhood given by a structuring element. Radiometric similarity is defined by the greylevel interval [g-s0, g+s1] - where g is the current pixel greylevel. Only pixels belonging to the - structuring element AND having a greylevel inside this interval are - averaged. Return greyscale local bilateral_mean of an image. + where g is the current pixel greylevel. + + Only pixels belonging to the structuring element and having a greylevel + inside this interval are averaged. Parameters ---------- - image : ndarray (uint8, uint16) - Image array. - selem : ndarray + image : 2-D array (uint8, uint16) + Input image. + selem : 2-D array The neighborhood expressed as a 2-D array of 1's and 0's. - out : ndarray (same dtype as input) - If None, a new array will be allocated. + out : 2-D array (same dtype as input) + If None, a new array is allocated. mask : ndarray Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default). @@ -81,22 +82,20 @@ def mean_bilateral(image, selem, out=None, mask=None, shift_x=False, Returns ------- - out : ndarray (same dtype as input image) + out : 2-D array (same dtype as input image) Output image. See also -------- - skimage.filter.denoise_bilateral for a gaussian bilateral filter. + skimage.filter.denoise_bilateral for a Gaussian bilateral filter. Examples -------- >>> from skimage import data >>> from skimage.morphology import disk - >>> from skimage.filter.rank import bilateral_mean - >>> # Load test image / cast to uint16 - >>> ima = data.camera().astype(np.uint16) - >>> # bilateral filtering of cameraman image using a flat kernel - >>> bilat_ima = bilateral_mean(ima, disk(20), s0=10,s1=10) + >>> from skimage.filter.rank import mean_bilateral + >>> img = data.camera().astype(np.uint16) + >>> bilat_img = mean_bilateral(img, disk(20), s0=10,s1=10) """ @@ -106,18 +105,22 @@ def mean_bilateral(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 - level inside the interval [g-s0, g+s1]. + """Return the local number (population) of pixels. + + + The number of pixels is defined as the number of pixels which are included + in the structuring element and the mask. Additionally the must have a + greylevel inside the interval [g-s0, g+s1] where g is the greyvalue of the + center pixel. Parameters ---------- - image : ndarray (uint8, uint16) - Image array. - selem : ndarray + image : 2-D array (uint8, uint16) + Input image. + selem : 2-D array The neighborhood expressed as a 2-D array of 1's and 0's. - out : ndarray (same dtype as input) - If None, a new array will be allocated. + out : 2-D array (same dtype as input) + If None, a new array is allocated. mask : ndarray Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default). @@ -131,20 +134,19 @@ def pop_bilateral(image, selem, out=None, mask=None, shift_x=False, Returns ------- - out : ndarray (same dtype as input image) + out : 2-D array (same dtype as input image) Output image. Examples -------- - >>> # Local mean >>> from skimage.morphology import square >>> import skimage.filter.rank as rank - >>> ima16 = 255 * np.array([[0, 0, 0, 0, 0], - ... [0, 1, 1, 1, 0], - ... [0, 1, 1, 1, 0], - ... [0, 1, 1, 1, 0], - ... [0, 0, 0, 0, 0]], dtype=np.uint16) - >>> rank.bilateral_pop(ima16, square(3), s0=10,s1=10) + >>> img = 255 * np.array([[0, 0, 0, 0, 0], + ... [0, 1, 1, 1, 0], + ... [0, 1, 1, 1, 0], + ... [0, 1, 1, 1, 0], + ... [0, 0, 0, 0, 0]], dtype=np.uint16) + >>> rank.pop_bilateral(imgsquare(3), s0=10, s1=10) array([[3, 4, 3, 4, 3], [4, 4, 6, 4, 4], [3, 6, 9, 6, 3], @@ -167,19 +169,19 @@ def sum_bilateral(image, selem, out=None, mask=None, shift_x=False, neighborhood given by a structuring element (selem). Radiometric similarity is defined by the greylevel interval [g-s0, g+s1] - where g is the current pixel greylevel. Only pixels belonging to the - structuring element AND having a greylevel inside this interval are - summed. Return greyscale local bilateral sum of an image. - Result is truncated (8bit or 16bit). + where g is the current pixel greylevel. + + Only pixels belonging to the structuring element AND having a greylevel + inside this interval are summed. Parameters ---------- - image : ndarray (uint8, uint16) - Image array. - selem : ndarray + image : 2-D array (uint8, uint16) + Input image. + selem : 2-D array The neighborhood expressed as a 2-D array of 1's and 0's. - out : ndarray (same dtype as input) - If None, a new array will be allocated. + out : 2-D array (same dtype as input) + If None, a new array is allocated. mask : ndarray Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default). @@ -193,22 +195,20 @@ def sum_bilateral(image, selem, out=None, mask=None, shift_x=False, Returns ------- - out : ndarray (same dtype as input image) + out : 2-D array (same dtype as input image) Output image. See also -------- - skimage.filter.denoise_bilateral for a gaussian bilateral filter. + skimage.filter.denoise_bilateral for a Gaussian bilateral filter. Examples -------- >>> from skimage import data >>> from skimage.morphology import disk >>> from skimage.filter.rank import sum_bilateral - >>> # Load test image / cast to uint16 - >>> ima = data.camera().astype(np.uint16) - >>> # bilateral filtering of cameraman image using a flat kernel - >>> bilat_ima = sum_bilateral(ima, disk(20), s0=10,s1=10) + >>> img = data.camera().astype(np.uint16) + >>> bilat_img = sum_bilateral(img, disk(10), s0=10, s1=10) """