import cv2
import  numpy as np
from matplotlib import pyplot as plt

img=cv2.imread("messi5.jpg",cv2.IMREAD_GRAYSCALE)
lap=cv2.Laplacian(img,cv2.CV_64F,ksize=3)
lap=np.uint8(np.absolute(lap))
sobelX=cv2.Sobel(img,cv2.CV_64F,1,0)
sobelY=cv2.Sobel(img,cv2.CV_64F,0,1)

sobelX=np.uint(np.absolute(sobelX))
sobelY=np.uint8(np.absolute(sobelY))

#sobelCombined=cv2.bitwise_or(sobelX,sobelY)

titles=['image','Laplacian','sobelX','sobelY','sobelCombined']
images=[img,lap,sobelX,sobelY]

for i in range(4):
    plt.subplot(2,2,i+1),plt.imshow(images[i],'gray')
    plt.title(titles[i])
    plt.xticks([]),plt.yticks([])

plt.show()