Pas encore de compte ?
Testé sous Anaconda et Python 3.7
# -*- coding: utf-8 -*- """ Created on Mon Sep 12 15:46:58 2022 @author: elodees """ import cv2 import numpy as np from matplotlib import pyplot as plt from PIL import Image img = cv2.imread("city.jpg") plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB)) plt.axis('off') plt.title('Originale image') plt.show() height, width, depth = np.shape(img) new_im = Image.new('RGB', (width, height)) pixel_map = new_im.load() # North Direction Edge Kernel = [[-1, -1, -1], [-1, 8, -1], [-1, -1, -1]] H = int(len(Kernel)) for j in range(0, width - H): for i in range(0, height - H): summ = 0 for k in range(0, H): for l in range(0, H): # RGB to Gray img[i+k][j+l][0] = img[i+k][j+l][1] = img[i+k][j+l][2] = 0.2989 * img[i+k][j+l][0] + 0.5870 * img[i+k][j+l][1] + 0.1140 * img[i+k][j+l][2] summ = summ + Kernel[k][l] * img[i+k][j+l][0] if(summ > 255): summ = 255 if(summ < 0): summ = 0 pixel_map[j, i] = (summ, summ, summ) plt.imshow(new_im) plt.axis('off') plt.show()
Image originale
Nuances de gris
Filtre de Outline
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