Logo elodees  elodees

Une IA bien-veillante pour un monde meilleur













Seuls les caractères alphabétiques accentués ou non ainsi que l'espace sont acceptés

Logo IA




Seuillage Trunc





Pas encore de compte ?

Inscrivez-vous pour accéder à tous les contenus


Testé sous Anaconda et Python 3.7

# Python program to illustrate
# Otsu thresholding type on an image
  
# organizing imports
import cv2
from matplotlib import pyplot as plt
import matplotlib.image as mpimg
 
# path to input image is specified and
# image is loaded with imread command
image_originale = cv2.imread('cat-threshimages.jpg')
 
plt.imshow(image_originale)
plt.axis('off')
plt.show()
 
# cv2.cvtColor is applied over the
# image input with applied parameters
# to convert the image in grayscale
img = cv2.cvtColor(image_originale, cv2.COLOR_BGR2GRAY)
 
plt.imshow(img, 'gray')
plt.axis('off')
plt.show()
 
# applying Otsu thresholding
# as an extra flag in binary 
# thresholding     
th, thresh1 = cv2.threshold(img, 50, 255, cv2.THRESH_TRUNC)
 
# the window showing output image         
# with the corresponding thresholding         
# techniques applied to the input image    
plt.imshow(thresh1, 'gray')
plt.axis('off')
plt.show()
 
mpimg.imsave('CatTruncThresholding-50.jpg', thresh1, cmap='gray')
 
# applying Otsu thresholding
# as an extra flag in binary 
# thresholding     
th, thresh1 = cv2.threshold(img, 100, 255, cv2.THRESH_TRUNC)
 
# the window showing output image         
# with the corresponding thresholding         
# techniques applied to the input image    
plt.imshow(thresh1, 'gray')
plt.axis('off')
plt.show()
 
mpimg.imsave('CatTruncThresholding-100.jpg', thresh1, cmap='gray')
 
# applying Otsu thresholding
# as an extra flag in binary 
# thresholding     
th, thresh1 = cv2.threshold(img, 150, 255, cv2.THRESH_TRUNC)
 
# the window showing output image         
# with the corresponding thresholding         
# techniques applied to the input image    
plt.imshow(thresh1, 'gray')
plt.axis('off')
plt.show()
 
mpimg.imsave('CatTruncThresholding-150.jpg', thresh1, cmap='gray')
 
# applying Otsu thresholding
# as an extra flag in binary 
# thresholding     
th, thresh1 = cv2.threshold(img, 200, 255, cv2.THRESH_TRUNC)
 
# the window showing output image         
# with the corresponding thresholding         
# techniques applied to the input image    
plt.imshow(thresh1, 'gray')
plt.axis('off')
plt.show()
 
mpimg.imsave('CatTruncThresholding-200.jpg', thresh1, cmap='gray')
 


Image gratuite et libre de droits fournie par pexel.com

Image gratuite et libre de droits fournie par pexel.com
Image gratuite et libre de droits fournie par pexel.com


Image gratuite et libre de droits fournie par pexel.com
Image gratuite et libre de droits fournie par pexel.com










Bienvenu, je m’appelle Eric Soupet et je suis l'administrateur du site elodees.com. elodees.com est un état de l'art de l'Intelligence Artificielle et se veut collaboratif, vous pouvez dès à présent proposer du contenu tels que des articles, des événements, des tutoriels, ... alors n'hésitez pas !

Crédit des images de la plate-forme : Pixabay - Pixabay License | Pexels - Pexels License