Challenge

Project 2

Prewit function :

#input is a grayscale converted ,gaussian filtered image. These functions shown below
def prewittFilter(image):
    verticalFilter = np.array([[1,0,-1],[1,0,-1],[1,0,-1]])
    horizontalFilter = np.array([[-1,-1,-1],[0,0,0,],[1,1,1]])
    verticalFiltered = cv2.filter2D(image,-1,verticalFilter)
    horizontalFiltered = cv2.filter2D(image,-1,horizontalFilter)
    absgrad_x = cv2.convertScaleAbs(verticalFiltered)
    absgrad_y = cv2.convertScaleAbs(horizontalFiltered)
    grad = cv2.addWeighted(absgrad_x,.5, absgrad_y,.5,0)
    return grad

Output of prewith operator

Laplacian filter

code:

def laplaceFilter(image,ddepth,kernelSize):
    greyImage = getGrayScaleImage(gaussianFilter(image,5,5))
    dst = cv2.Laplacian(greyImage, ddepth, ksize=kernelSize)
    return cv2.convertScaleAbs(dst)


imageFile1 = 'street.jpg'
imgForLaplace = cv2.imread(imageFile1)
laplaceEdges = laplaceFilter(imgForLaplace,cv2.CV_16S,3)
disp("laplace", laplaceEdges)

Output of laplace filter

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.

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.