Project 2
import cv2 as cv
import numpy as np
img = cv.imread('C:\\Users\\Welcome\\Pictures\\Skill-lync\\cat.jpg')
gray = cv.cvtColor(img,cv.COLOR_BGR2GRAY)
img_gaussian = cv.GaussianBlur(gray,(3,3),0)
# Prewitt filter
kernelx = np.array([[1,1,1],[0,0,0],[-1,-1,-1]])
kernely = np.array([[-1,0,1],[-1,0,1],[-1,0,1]])
img_prewittx = cv.filter2D(img_gaussian,-1,kernelx)
img_prewitty = cv.filter2D(img_gaussian,-1,kernely)
# Laplacian filter
gradients_laplacian = cv.Laplacian(img,-1)
cv.imshow('Prewitt X',img_prewittx)
cv.imshow('Prewitt Y',img_prewitty)
cv.imshow('Prewitt',img_prewittx + img_prewitty)
cv.imshow('Laplacian',gradients_laplacian)
cv.waitKey(0)
cv.destroyAllWindows()
# Original image





In case of prewitt filter only first order derivatives are used so edges detected as not so much prominent.
But in case of laplacian filter 2nd order derivatives are used so the edges as much more prominent.
So as compare to prewitt filter laplacian filter is more efficient.