Today we explored kernels in more depth.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# 1. Open any image; # 2. Build a kernel for sharpening an image # (you will need to research this); # 3. Apply this filter to the image. import numpy as np import cv2 from matplotlib import pyplot as plt from matplotlib import image as image import easygui I = cv2.imread("Lenna.png") G = cv2.cvtColor(I, cv2.COLOR_BGR2GRAY) k = np.array([[0,-1,0], [-1,5,-1], [0,-1,0]], dtype=float) F = cv2.filter2D(G,ddepth=-1,kernel=k) cv2.imshow("image", F) key = cv2.waitKey(0) |
The second part of this lab was used to finish off our first modules .assignment.