Commit 39243a3a authored by is181028's avatar is181028
Browse files

New example for niblack/sauvola/otsu

parent 6cc5f925
......@@ -10,3 +10,4 @@ lib64
pip-selfcheck.json
*.log
*.zip
share/
import matplotlib
import matplotlib.pyplot as plt
import os
from skimage import io
from skimage.data import page
from skimage.filters import (threshold_otsu, threshold_niblack,
threshold_sauvola)
from skimage.color import rgb2gray
matplotlib.rcParams['font.size'] = 9
matplotlib.rcParams['font.size'] = 13
image = page()
#image = page()
image = rgb2gray(io.imread('binarisation.png'))
binary_global = image > threshold_otsu(image)
window_size = 25
thresh_niblack = threshold_niblack(image, window_size=window_size, k=0.8)
print(threshold_otsu(image))
window_size = 21
thresh_niblack = threshold_niblack(image, window_size=window_size)
thresh_sauvola = threshold_sauvola(image, window_size=window_size)
binary_niblack = image > thresh_niblack
......@@ -26,7 +30,7 @@ plt.title('Original')
plt.axis('off')
plt.subplot(2, 2, 2)
plt.title('Global Threshold')
plt.title('Otsu Binarization / Global Threshold')
plt.imshow(binary_global, cmap=plt.cm.gray)
plt.axis('off')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment