Edge Detection
The process of image detection involves detecting edges in the image. It works by detecting discontinuities in the brightness. For high-intensity variations, we can use Sobel, a gradient operator-
Example: Edge detection using SciPy and NumPy
Python3
from scipy import misc, ndimage import matplotlib.pyplot as plt import numpy as np img = np.zeros(( 300 , 300 )) img[ 64 : - 64 , 64 : - 64 ] = 1 img = ndimage.rotate(im, 30 , mode = 'constant' ) img = ndimage.gaussian_filter(im, 7 ) # Original image plt.imshow(im) plt.show() # edge detection x = ndimage.sobel(im, axis = 0 , mode = 'constant' ) y = ndimage.sobel(im, axis = 1 , mode = 'constant' ) Sobel = np.hypot(x, y) plt.imshow(sob) plt.show() |
Output:
Image Processing with SciPy and NumPy in Python
In this tutorial, we will discuss Image Processing in Python using the core scientific modules like NumPy and SciPy. The images are made up of NumPy ndarrays so we can process and manipulate images and SciPy provides the submodule scipy.ndimage that provides functions that can operate on the NumPy arrays.
We will discuss how to open and write to images, and will also cover different manipulation and filtering techniques. So before getting started let’s see how to install both modules.