How to do image processing using python scipy.ndimage?

Description

To know how to do image processing with scipy.ndimage in python.

Input:

Face Image of panda.

Output

Gray scale image.
Rotated image.

  Import necessary library.

  Load image from misc.face() package.

  Convert gray scale image using arguments.

  Rotate the image using scipy.ndimage().

  Plot the final images.

from scipy import misc,ndimage
from matplotlib import pyplot as plt
import numpy as np

#get face image of panda from misc package
image = misc.face()

#plot or show image of face
print(“Original image”)
plt.imshow(image)
plt.show()

#gray scale image
print(“Gray scale image”)
image1 = misc.face(gray = True)
#plot or show image of face
plt.imshow(image1)
plt.show()

#rotating image
print(“Rotated image”)
image_rotate = ndimage.rotate(image, 35)
plt.imshow(image_rotate)
plt.show()

Leave Comment

Your email address will not be published. Required fields are marked *

clear formSubmit