add: local Otsu synthetic example

This commit is contained in:
Olivier Debeir
2012-11-12 14:48:38 +01:00
parent db2e066f4c
commit da391089cb
2 changed files with 21 additions and 1 deletions
@@ -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
-1
View File
@@ -364,4 +364,3 @@ def test_entropy():
if __name__ == "__main__":
run_module_suite()