Challenge

Project 2

!pip install opencv-python

import cv2 as computervision
import numpy as np

image=computervision.imread(r"Challenge_2.png")
assert not isinstance(image,type(None)), 'image not found'

Prewitt Filter

gray = computervision.cvtColor(image, computervision.COLOR_BGR2GRAY)
img_gaussian = computervision.GaussianBlur(gray,(3,3),0)
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 = computervision.filter2D(img_gaussian, -1, kernelx)
img_prewitty = computervision.filter2D(img_gaussian, -1, kernely)
img_prewitt=img_prewittx+img_prewitty
computervision.imwrite("prewitt_image.png",img_prewitt)

Laplacian Filter

ddepth = computervision.CV_16S
kernel_size = 3
img_gaussian = computervision.GaussianBlur(image, (3, 3), 0)
img_gray = computervision.cvtColor(img_gaussian, computervision.COLOR_BGR2GRAY)
laplacian_img = computervision.Laplacian(img_gray, ddepth, ksize=kernel_size)
computervision.imwrite("laplacian_image.png",laplacian_img)

Compare both filter

S.NO Opertor Time Space Noise sensitivity False Edges
1 Prewit low lower Least Sensitivity More
2 Laplacian of
Gausian
low least Least Sensitivity More
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.