From 4cfed8cb0e19b57450dcf1bd8c1f4b8ed52de491 Mon Sep 17 00:00:00 2001
From: Christian <s224389@dtu.dk>
Date: Mon, 20 Jan 2025 11:07:05 +0100
Subject: [PATCH] Started formatting

---
 modules/advancedSettingsWidget.py |  2 --
 modules/compute_cost_image.py     | 22 +++++++++++++++++-----
 modules/export_path.py            |  0
 modules/mainWindow.py             |  2 --
 4 files changed, 17 insertions(+), 9 deletions(-)
 create mode 100644 modules/export_path.py

diff --git a/modules/advancedSettingsWidget.py b/modules/advancedSettingsWidget.py
index 071bd68..c111863 100644
--- a/modules/advancedSettingsWidget.py
+++ b/modules/advancedSettingsWidget.py
@@ -6,8 +6,6 @@ from PyQt5.QtGui import QPixmap, QImage
 from PyQt5.QtCore import Qt
 import numpy as np
 
-
-
 class AdvancedSettingsWidget(QWidget):
     """
     Shows toggle rainbow, circle editor, line smoothing slider, contrast slider,
diff --git a/modules/compute_cost_image.py b/modules/compute_cost_image.py
index 1da0a6a..3c88768 100644
--- a/modules/compute_cost_image.py
+++ b/modules/compute_cost_image.py
@@ -4,12 +4,24 @@ from compute_disk_size import compute_disk_size
 from load_image import load_image
 from preprocess_image import preprocess_image
 from circle_edge_kernel import circle_edge_kernel
-
-def compute_cost_image(path, user_radius, sigma=3, clip_limit=0.01):
-
+import numpy as np
+
+def compute_cost_image(path: str, user_radius: int, sigma: int = 3, clip_limit: float = 0.01) -> np.ndarray:
+    """
+    Compute the cost image for a given image path, user radius, and optional parameters.
+    
+    Args:
+        path: The path to the image file.
+        user_radius: The radius of the disk.
+        sigma: The standard deviation for Gaussian smoothing.
+        clip_limit: The limit for contrasting the image.
+
+    Returns:
+        The cost image as a NumPy array.
+    """
     disk_size = compute_disk_size(user_radius)
 
-    ### Load image
+    # Load image
     image = load_image(path)
 
     # Apply smoothing
@@ -18,7 +30,7 @@ def compute_cost_image(path, user_radius, sigma=3, clip_limit=0.01):
     # Apply Canny edge detection
     canny_img = canny(smoothed_img)
 
-    # Do disk thing
+    # Perform disk convolution
     binary_img = canny_img
     kernel = circle_edge_kernel(k_size=disk_size)
     convolved = convolve2d(binary_img, kernel, mode='same', boundary='fill')
diff --git a/modules/export_path.py b/modules/export_path.py
new file mode 100644
index 0000000..e69de29
diff --git a/modules/mainWindow.py b/modules/mainWindow.py
index 5ec3e71..45ca7e8 100644
--- a/modules/mainWindow.py
+++ b/modules/mainWindow.py
@@ -244,8 +244,6 @@ class MainWindow(QMainWindow):
 
         print(f"Exported path with {len(full_xy)} points to {file_path}")
 
-
-
     def clear_points(self):
         self.image_view.clear_guide_points()
 
-- 
GitLab