Logo elodees  elodees

A caring AI for a better world













Only alphabetic characters accented or not as well as the space are accepted

Logo IA




Sobel filter









No account yet ?

Sign up to access all content




Tested in Anaconda and Python 3.7

import numpy as np
from skimage.io import imread
from skimage.color import rgb2gray
import matplotlib.pyplot as plt
 
input_pixels = np.array(rgb2gray(imread('resources/city.jpg'))*256, dtype=np.uint8)
plt.axis("off")
plt.imshow(input_pixels, cmap="gray")
 
kernel_horizontal = np.array([[-1, 0, 1], 
                              [-2, 0, 2], 
                              [-1, 0, 1]], dtype = np.float)
 
kernel_vertical   = np.array([[1, 2, 1], 
                              [0, 0, 0], 
                              [-1, -2, -1]], dtype = np.float)
 
from scipy import signal
 
Gx = signal.convolve2d(input_pixels, kernel_horizontal, boundary='symm', mode='same')
Gy = signal.convolve2d(input_pixels, kernel_vertical, boundary='symm', mode='same')
 
gradient_magnitude = np.sqrt(Gx * Gx + Gy * Gy)
gradient_magnitude *= 255.0 / np.max(gradient_magnitude)
 
plt.imshow(gradient_magnitude, cmap="gray")
 


ml_research - GitHub



Original image

Free image provided by pexel.com

Grayscale

Free image provided by pexel.com

Gx

Free image provided by pexel.com


Gy

Free image provided by pexel.com

Sobel filter

Free image provided by pexel.com












Welcome, my name is Eric Soupet and I am the administrator of the site elodees.com. elodees.com is a state of the art of Artificial Intelligence and aims to be collaborative, you can now offer content such as articles, events, tutorials, ... so don't hesitate !

Platform images credit : Pixabay - Pixabay License | Pexels - Pexels License