Created
September 3, 2019 10:23
-
-
Save ritwikraha/2a216b3889b7ad7725cb8650afa76720 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import matplotlib.pyplot as plt | |
# reading the smooth image and converting it into RGB color space | |
image_smooth = cv2.cvtColor(cv2.imread('smooth.jpg'),cv2.COLOR_BGR2RGB) | |
# calculating edges from the smooth image | |
edge_smooth= cv2.cvtColor(cv2.Canny(image_smooth, 100, 250),cv2.COLOR_BGR2RGB) | |
# reading a normal sharp image and converting the color space | |
image_sharp = cv2.cvtColor(cv2.imread('sharp.jpg'),cv2.COLOR_BGR2RGB) | |
# claculating the edges from the image | |
edge_sharp= cv2.cvtColor(cv2.Canny(image_sharp, 100, 250),cv2.COLOR_BGR2RGB) | |
# putting the titles and the images in a list | |
titles = ['A Smooth Image', 'Edge from Smooth Image', 'A Sharp Image','Edge from Sharp Image'] | |
imgs = [image_smooth,edge_smooth ,image_sharp,edge_sharp] | |
# displaying the images | |
plt.figure(figsize=(60,60)) | |
for i in range(4): | |
plt.subplot(2,2,i+1),plt.imshow(imgs[i]) | |
plt.title(titles[i]) | |
plt.xticks([]),plt.yticks([]) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment