From 82ea5cf446ac873fef03398b42e7b3e2499930da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 27 Apr 2013 16:13:09 +0200 Subject: [PATCH] Rename mean filter example and improve description --- doc/examples/applications/plot_morphology.py | 6 +-- doc/examples/plot_16bitbilateral.py | 47 -------------------- doc/examples/plot_hough_transform.py | 2 +- doc/examples/plot_rank_mean.py | 45 +++++++++++++++++++ doc/examples/plot_swirl.py | 2 +- 5 files changed, 50 insertions(+), 52 deletions(-) delete mode 100644 doc/examples/plot_16bitbilateral.py create mode 100644 doc/examples/plot_rank_mean.py diff --git a/doc/examples/applications/plot_morphology.py b/doc/examples/applications/plot_morphology.py index d3c53829..84cf2972 100644 --- a/doc/examples/applications/plot_morphology.py +++ b/doc/examples/applications/plot_morphology.py @@ -178,7 +178,7 @@ element, but the thicker region at the top disappears. Black tophat ============ -The ``black_tophat`` of an image is defined as its morphological **closing +The ``black_tophat`` of an image is defined as its morphological **closing minus the original image**. This operation returns the *dark spots of the image that are smaller than the structuring element*. """ @@ -264,8 +264,8 @@ Additional Resources ==================== 1. `MathWorks tutorial on morphological processing -`_ -2. `Auckland university's tutorial on Morphological Image Processing +`_ +2. `Auckland university's tutorial on Morphological Image Processing `_ 3. http://en.wikipedia.org/wiki/Mathematical_morphology diff --git a/doc/examples/plot_16bitbilateral.py b/doc/examples/plot_16bitbilateral.py deleted file mode 100644 index 473fcadd..00000000 --- a/doc/examples/plot_16bitbilateral.py +++ /dev/null @@ -1,47 +0,0 @@ -""" -============================== -Bilateral mean -============================== -This example compares - -* local mean -* percentile mean -* bilateral mean - -build on the local histogram distribution -local mean uses all pixels belonging to the structuring element to compute average gray level, -percentile mean uses only values between percentiles p0 and p1 (here 10% and 90%), -whereas bilateral mean uses only pixels of the structuring element having a gray level situated inside -g-s0 and g+s1 (here g-500 and g+500). -The filters are applied on a 16 bit image (actual bitdepth is 12bit). - -Percentile and usual mean give here similar results, these filters smooth the complete image (background and details). -Bilateral mean exhibits a high filtering rate for continuous area (i.e. background) while image higher frequencies -remains untouched. - -""" -import numpy as np -import matplotlib.pyplot as plt - -from skimage import data -from skimage.morphology import disk -import skimage.filter.rank as rank - -a16 = (data.coins()).astype('uint16') * 16 -selem = disk(20) - -f1 = rank.percentile_mean(a16, selem=selem, p0=.1, p1=.9) -f2 = rank.bilateral_mean(a16, selem=selem, s0=500, s1=500) -f3 = rank.mean(a16, selem=selem) - -# display results -fig, axes = plt.subplots(nrows=3, figsize=(15, 10)) -ax0, ax1, ax2 = axes - -ax0.imshow(np.hstack((a16, f1))) -ax0.set_title('percentile mean') -ax1.imshow(np.hstack((a16, f2))) -ax1.set_title('bilateral mean') -ax2.imshow(np.hstack((a16, f3))) -ax2.set_title('local mean') -plt.show() diff --git a/doc/examples/plot_hough_transform.py b/doc/examples/plot_hough_transform.py index 47b24c13..e31c812c 100644 --- a/doc/examples/plot_hough_transform.py +++ b/doc/examples/plot_hough_transform.py @@ -1,4 +1,4 @@ -r''' +''' =============== Hough transform =============== diff --git a/doc/examples/plot_rank_mean.py b/doc/examples/plot_rank_mean.py new file mode 100644 index 00000000..88b53ec8 --- /dev/null +++ b/doc/examples/plot_rank_mean.py @@ -0,0 +1,45 @@ +""" +============ +Mean filters +============ + +This example compares the following mean filters of the rank filter package: + + * **local mean**: all pixels belonging to the structuring element to compute + average gray level + * **percentile mean**: only use values between percentiles p0 and p1 + (here 10% and 90%) + * **bilateral mean**: only use pixels of the structuring element having a gray + level situated inside g-s0 and g+s1 (here g-500 and g+500) + +Percentile and usual mean give here similar results, these filters smooth the +complete image (background and details). Bilateral mean exhibits a high +filtering rate for continuous area (i.e. background) while higher image +frequencies remain untouched. + +""" +import numpy as np +import matplotlib.pyplot as plt + +from skimage import data +from skimage.morphology import disk +import skimage.filter.rank as rank + +a16 = (data.coins()).astype('uint16') * 16 +selem = disk(20) + +f1 = rank.percentile_mean(a16, selem=selem, p0=.1, p1=.9) +f2 = rank.bilateral_mean(a16, selem=selem, s0=500, s1=500) +f3 = rank.mean(a16, selem=selem) + +# display results +fig, axes = plt.subplots(nrows=3, figsize=(15, 10)) +ax0, ax1, ax2 = axes + +ax0.imshow(np.hstack((a16, f1))) +ax0.set_title('percentile mean') +ax1.imshow(np.hstack((a16, f2))) +ax1.set_title('bilateral mean') +ax2.imshow(np.hstack((a16, f3))) +ax2.set_title('local mean') +plt.show() diff --git a/doc/examples/plot_swirl.py b/doc/examples/plot_swirl.py index 18947dcb..69c0006b 100644 --- a/doc/examples/plot_swirl.py +++ b/doc/examples/plot_swirl.py @@ -1,4 +1,4 @@ -r""" +""" ===== Swirl =====