Challenge

Project 2

!pip install opencv-python

import cv2 as computervision
import numpy as np

image=computervision.imread(r"C:\Users\mahejang\Downloads\Challenge 2-1\Challenge 2\Challenge_2.png")
assert not isinstance(image,type(None)), 'image not found'

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)

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)

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.