CommencerCommencer gratuitement

Appliquer un seuillage

Dans cet exercice, vous allez choisir le type de seuillage le plus adapté pour binariser une image d’outils de tricot et de loisirs créatifs. Vous pourrez ainsi distinguer plus nettement la forme des objets, des cœurs en papier aux ciseaux.

Several tools for handcraft art
Image chargée sous tools_image.

Quel type de seuillage utiliseriez-vous au vu des caractéristiques de l’image ? L’éclairage et l’intensité du fond sont-ils homogènes ou non homogènes ?

Cet exercice fait partie du cours

Traitement d’images en Python

Afficher le cours

Instructions

  • Importez les fonctions de seuillage appropriées ainsi que rgb2gray().
  • Convertissez l’image en niveaux de gris.
  • Calculez le seuil optimal.
  • Obtenez l’image binaire en appliquant le seuillage.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Import threshold and gray convertor functions
from skimage.____ import ____
from skimage.color import ____

# Turn the image grayscale
gray_tools_image = ____

# Obtain the optimal thresh
thresh = ____(gray_tools_image)

# Obtain the binary image by applying thresholding
binary_image = gray_tools_image > ____

# Show the resulting binary image
show_image(binary_image, 'Binarized image')
Modifier et exécuter le code