mirror of
https://github.com/wassname/scikit-image.git
synced 2026-09-09 11:33:41 +08:00
Solving white space + improving code +PEP8
Solving white space + Correcting code Solving white spaces Solving white spaces Solving white spaces Answering comments Correcting silly mistakes Solving white spaces Trying again... now with Travis enabled
This commit is contained in:
@@ -10,23 +10,21 @@ structuring element.
|
||||
|
||||
The example compares the local threshold with the global threshold.
|
||||
|
||||
.. note: local is much slower than global thresholding
|
||||
.. Note: local is much slower than global thresholding
|
||||
|
||||
.. [1] http://en.wikipedia.org/wiki/Otsu's_method
|
||||
|
||||
"""
|
||||
import matplotlib
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from skimage import data
|
||||
from skimage.morphology import disk
|
||||
from skimage.filters import threshold_otsu, rank
|
||||
from skimage.util import img_as_ubyte
|
||||
|
||||
import matplotlib
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
matplotlib.rcParams['font.size'] = 9
|
||||
|
||||
|
||||
img = img_as_ubyte(data.page())
|
||||
|
||||
radius = 15
|
||||
@@ -36,26 +34,26 @@ local_otsu = rank.otsu(img, selem)
|
||||
threshold_global_otsu = threshold_otsu(img)
|
||||
global_otsu = img >= threshold_global_otsu
|
||||
|
||||
fig, ax = plt.subplots(2, 2, figsize=(8, 5), sharex=True, sharey=True,
|
||||
subplot_kw={'adjustable': 'box-forced'})
|
||||
ax0, ax1, ax2, ax3 = ax.ravel()
|
||||
|
||||
fig, ax = plt.subplots(2, 2, figsize=(8, 5), sharex=True, sharey=True, subplot_kw={'adjustable':'box-forced'})
|
||||
ax1, ax2, ax3, ax4 = ax.ravel()
|
||||
fig.colorbar(ax0.imshow(img, cmap=plt.cm.gray),
|
||||
ax=ax0, orientation='horizontal')
|
||||
ax0.set_title('Original')
|
||||
ax0.axis('off')
|
||||
|
||||
fig.colorbar(ax1.imshow(img, cmap=plt.cm.gray),
|
||||
fig.colorbar(ax1.imshow(local_otsu, cmap=plt.cm.gray),
|
||||
ax=ax1, orientation='horizontal')
|
||||
ax1.set_title('Original')
|
||||
ax1.set_title('Local Otsu (radius=%d)' % radius)
|
||||
ax1.axis('off')
|
||||
|
||||
fig.colorbar(ax2.imshow(local_otsu, cmap=plt.cm.gray),
|
||||
ax=ax2, orientation='horizontal')
|
||||
ax2.set_title('Local Otsu (radius=%d)' % radius)
|
||||
ax2.imshow(img >= local_otsu, cmap=plt.cm.gray)
|
||||
ax2.set_title('Original >= Local Otsu' % threshold_global_otsu)
|
||||
ax2.axis('off')
|
||||
|
||||
ax3.imshow(img >= local_otsu, cmap=plt.cm.gray)
|
||||
ax3.set_title('Original >= Local Otsu' % threshold_global_otsu)
|
||||
ax3.imshow(global_otsu, cmap=plt.cm.gray)
|
||||
ax3.set_title('Global Otsu (threshold = %d)' % threshold_global_otsu)
|
||||
ax3.axis('off')
|
||||
|
||||
ax4.imshow(global_otsu, cmap=plt.cm.gray)
|
||||
ax4.set_title('Global Otsu (threshold = %d)' % threshold_global_otsu)
|
||||
ax4.axis('off')
|
||||
|
||||
plt.show()
|
||||
|
||||
Reference in New Issue
Block a user