diff --git a/assignment2/.png b/assignment2/.png index 799e680..485ee88 100644 Binary files a/assignment2/.png and b/assignment2/.png differ diff --git a/assignment2/solution.py b/assignment2/solution.py index af72814..c57dcb3 100644 --- a/assignment2/solution.py +++ b/assignment2/solution.py @@ -186,11 +186,10 @@ def one_e(distances: list, selected_dists: list): ############################ def ex2(): - #two_b() - #two_c() + two_b() + two_d() two_e() - def two_b(): """ Implement the function simple_convolution that uses a 1-D signal I and a kernel @@ -289,7 +288,7 @@ def two_e(): # EXCERCISE 3: Image Filtering # ################################ def ex3(): - #three_a() + three_a() three_b() def three_a(): @@ -341,18 +340,17 @@ def three_b(): Convolution can also be used for image sharpening. Look at its definition in the lecture slides and implement it. Test it on the image from file museum.jpg. """ - museum_grayscale = cv2.imread('./data/images/museum.jpg', 0) + museum_grayscale = uz_image.imread_gray('./data/images/museum.jpg', uz_image.ImageType.uint8) - #https://blog.demofox.org/2022/02/26/image-sharpening-convolution-kernels/ - # Pa tui na slajdih lepo pise + #https://blog.demofox.org/2022/02/26/image-sharpening-convolution-kernels/ # Pa tui na slajdih lepo pise kernel = np.array([[-1, -1, -1], [-1, 17, -1], [-1, -1,-1]]) + kernel = kernel * 1./9. - museo = cv2.filter2D(museum_grayscale, cv2.CV_64F, kernel) - museo = cv2.filter2D(museo, cv2.CV_64F, kernel.T) + museo = cv2.filter2D(museum_grayscale, -1, kernel) fig, axs = plt.subplots(1, 2) axs[0].imshow(museum_grayscale, cmap='gray') @@ -369,8 +367,8 @@ def three_b(): def main(): #ex1() - ex2() - # ex3() + #ex2() + ex3() if __name__ == '__main__': main()