From da391089cbc25ad6db097d3896a184bff786f55e Mon Sep 17 00:00:00 2001 From: Olivier Debeir Date: Mon, 12 Nov 2012 14:48:38 +0100 Subject: [PATCH] add: local Otsu synthetic example --- .../applications/plot_rank_filters.py | 21 +++++++++++++++++++ skimage/filter/rank/tests/test_rank.py | 1 - 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/doc/examples/applications/plot_rank_filters.py b/doc/examples/applications/plot_rank_filters.py index 3fdd5a94..75806486 100644 --- a/doc/examples/applications/plot_rank_filters.py +++ b/doc/examples/applications/plot_rank_filters.py @@ -356,6 +356,27 @@ plt.subplot(2,2,4) plt.imshow(glob_otsu,cmap=plt.cm.gray) plt.xlabel('global Otsu ($t=%d$)'%t_glob_otsu) +""" +.. image:: PLOT2RST.current_figure + +The following example, shows on a synthetic image how local Otsu's threshold handle a global level shift. + """ + +n = 100 +theta = np.linspace(0,10*np.pi,n) +x = np.sin(theta) +m = (np.tile(x,(n,1))* np.linspace(0.1,1,n)*128+128).astype(np.uint8) + +radius = 10 +t = rank.otsu(m,disk(radius)) +plt.figure() +plt.subplot(1,2,1) +plt.imshow(m) +plt.xlabel('original') +plt.subplot(1,2,2) +plt.imshow(m>=t,interpolation='nearest') +plt.xlabel('local Otsu ($radius=%d$)'%radius) + """ .. image:: PLOT2RST.current_figure diff --git a/skimage/filter/rank/tests/test_rank.py b/skimage/filter/rank/tests/test_rank.py index 73f3a5c3..6a8a19d4 100644 --- a/skimage/filter/rank/tests/test_rank.py +++ b/skimage/filter/rank/tests/test_rank.py @@ -364,4 +364,3 @@ def test_entropy(): if __name__ == "__main__": run_module_suite() - \ No newline at end of file