Skip to content

Instantly share code, notes, and snippets.

@cyberboysumanjay
Created June 28, 2018 11:20
Show Gist options
  • Select an option

  • Save cyberboysumanjay/a81066d5451bda30b8255fcb1c01f7d7 to your computer and use it in GitHub Desktop.

Select an option

Save cyberboysumanjay/a81066d5451bda30b8255fcb1c01f7d7 to your computer and use it in GitHub Desktop.
Image Processing in python using OpenCV
import numpy as np
import cv2
from matplotlib import pyplot as plt
img=cv2.imread('chess_board.jpg',0)
sobelx=cv2.Sobel(img,cv2.CV_64F,1,0,ksize=5)
sobely=cv2.Sobel(img,cv2.CV_64F,0,1,ksize=5)
plt.subplot(2,2,1),plt.imshow(img,cmap='gray')
plt.title("Original"),plt.xticks([]),plt.yticks([])
plt.subplot(2,2,2),plt.imshow(sobelx,cmap='gray')
plt.title('Sobel X'),plt.xticks([]),plt.yticks([])
plt.subplot(2,2,3),plt.imshow(sobely,cmap='gray')
plt.title('Sobel Y'),plt.xticks([]),plt.yticks([])
laplacian=cv2.Laplacian(img,cv2.CV_64F)
plt.subplot(2,2,4),plt.imshow(laplacian,cmap='gray')
plt.title('Laplacian'),plt.xticks([]),plt.yticks([])
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment