Quand l’arrière-plan n’est pas si évident
Parfois, il n’est pas si simple d’identifier l’arrière-plan. Si l’arrière-plan de l’image est relativement uniforme, vous pouvez utiliser un seuil global, comme nous l’avons fait avec threshold_otsu(). En revanche, si l’illumination de l’arrière-plan est irrégulière, un seuillage adaptatif avec threshold_local() (aussi appelé seuillage local) peut donner de meilleurs résultats.
Dans cet exercice, vous allez comparer ces deux méthodes de seuillage (global et local) afin de trouver la meilleure façon d’obtenir l’image binaire dont nous avons besoin.
Image chargée sous le nom
page_image.
Cet exercice fait partie du cours
Traitement d’images en Python
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Import the otsu threshold function
from skimage.____ import ____
# Obtain the optimal otsu global thresh value
global_thresh = ____(page_image)
# Obtain the binary image by applying global thresholding
binary_global = page_image ____ ____
# Show the binary image obtained
show_image(binary_global, 'Global thresholding')