From 2c7849db3a45bcb252904c7c0d75983d9a4ac937 Mon Sep 17 00:00:00 2001
From: iliya <iliya.saroukhanian@etu.hesge.ch>
Date: Sat, 13 Apr 2024 15:58:54 +0200
Subject: [PATCH] feat: gauss (i dont effing know tbhh) lab4

---
 labo4.py | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/labo4.py b/labo4.py
index b320a38..32d1c6a 100644
--- a/labo4.py
+++ b/labo4.py
@@ -108,11 +108,21 @@ def sharpen(img: Img, isotropy: Isotropy) -> Img:
     return new_image
 
 
+def gauss_kernel(length: int = 3, sigma: float = 1.0) -> Img:
+    half = (length - 1) / 2
+    x_axis = np.linspace(-half, half, length)
+
+    gauss = np.exp(-0.5 * np.square(x_axis) / np.square(sigma))
+    kernel = np.outer(gauss, gauss)
+
+    return kernel / np.sum(kernel)
+
+
 if __name__ == "__main__":
-    img = load_img("resources/hotel.png")
+    img = load_img("resources/noisy_hotel.png")
     gray = rgb_to_gray(img)
 
-    laplacian = laplace(gray, Isotropy.ISO_45)
+    laplacian = laplace(xcorr(gray, gauss_kernel()), Isotropy.ISO_45)
     thresholded = thresholding(laplacian, 50)
 
     sharp_iso_90 = sharpen(gray, Isotropy.ISO_90)
-- 
GitLab