diff --git a/modules/__pycache__/advancedSettingsWidget.cpython-310.pyc b/modules/__pycache__/advancedSettingsWidget.cpython-310.pyc index 7236b63a0e28e1ce6261fd142586150be4764839..4f03c691e60160520c3edbe98a564f1e6e0c39f7 100644 Binary files a/modules/__pycache__/advancedSettingsWidget.cpython-310.pyc and b/modules/__pycache__/advancedSettingsWidget.cpython-310.pyc differ diff --git a/modules/__pycache__/circle_edge_kernel.cpython-310.pyc b/modules/__pycache__/circle_edge_kernel.cpython-310.pyc index ee86e4ef66d3ce22af22a0a8c402d0374cd819a3..c67506850ab1a7de874c025489ddea0b3ce36235 100644 Binary files a/modules/__pycache__/circle_edge_kernel.cpython-310.pyc and b/modules/__pycache__/circle_edge_kernel.cpython-310.pyc differ diff --git a/modules/__pycache__/compute_cost_image.cpython-310.pyc b/modules/__pycache__/compute_cost_image.cpython-310.pyc index e755561615f0c50661393a5a4e40992dd71e5376..95190d238dbe08bed73ccd6573db4a551e4bc73c 100644 Binary files a/modules/__pycache__/compute_cost_image.cpython-310.pyc and b/modules/__pycache__/compute_cost_image.cpython-310.pyc differ diff --git a/modules/__pycache__/compute_disk_size.cpython-310.pyc b/modules/__pycache__/compute_disk_size.cpython-310.pyc index 3383772746e94d58575ed8f6aec432708e812f0e..74bb861cd1ee382b9360c0e67aaeb9ed7d1c8fde 100644 Binary files a/modules/__pycache__/compute_disk_size.cpython-310.pyc and b/modules/__pycache__/compute_disk_size.cpython-310.pyc differ diff --git a/modules/__pycache__/load_image.cpython-310.pyc b/modules/__pycache__/load_image.cpython-310.pyc index 4e867587aa08a678807752452ad7df52ecea128e..5c6ee3dd5ebe526caf9fb5f8b9be6b2cd426e502 100644 Binary files a/modules/__pycache__/load_image.cpython-310.pyc and b/modules/__pycache__/load_image.cpython-310.pyc differ diff --git a/modules/__pycache__/mainWindow.cpython-310.pyc b/modules/__pycache__/mainWindow.cpython-310.pyc index f202a4a0c3b8081acdb334f6de92fcb4b3009718..77bebf01c39d59ee355b75213eb3c29101613278 100644 Binary files a/modules/__pycache__/mainWindow.cpython-310.pyc and b/modules/__pycache__/mainWindow.cpython-310.pyc differ diff --git a/modules/__pycache__/preprocess_image.cpython-310.pyc b/modules/__pycache__/preprocess_image.cpython-310.pyc index 32055ff7fcd436221cc6f7f3293f35ea7f856c72..942e404cc02a826f3db27aa44723851cb69d573d 100644 Binary files a/modules/__pycache__/preprocess_image.cpython-310.pyc and b/modules/__pycache__/preprocess_image.cpython-310.pyc differ diff --git a/modules/advancedSettingsWidget.py b/modules/advancedSettingsWidget.py index 8983d37ec11bfbb78686e1ff9734f9c237d79c75..065a8e29b6a404c430db8d265fa872d923e53e4b 100644 --- a/modules/advancedSettingsWidget.py +++ b/modules/advancedSettingsWidget.py @@ -5,7 +5,6 @@ from PyQt5.QtWidgets import ( from PyQt5.QtGui import QPixmap, QImage, QShowEvent from PyQt5.QtCore import Qt import numpy as np -from mainWindow import MainWindow from typing import Optional class AdvancedSettingsWidget(QWidget): @@ -14,7 +13,7 @@ class AdvancedSettingsWidget(QWidget): plus two image previews (contrasted-blurred and cost). The images maintain aspect ratio upon resize. """ - def __init__(self, main_window: MainWindow, parent: Optional[QWidget] = None): + def __init__(self, main_window, parent: Optional[QWidget] = None): """ Constructor. """ diff --git a/modules/circleEditorGraphicsView.py b/modules/circleEditorGraphicsView.py index 5134f532e5f25206c8302ade24c95d1f3acd3a2c..efa7448c947c2b8ea5a9631916eab22a2785a012 100644 --- a/modules/circleEditorGraphicsView.py +++ b/modules/circleEditorGraphicsView.py @@ -3,12 +3,11 @@ from panZoomGraphicsView import PanZoomGraphicsView from PyQt5.QtCore import Qt from PyQt5.QtGui import QMouseEvent, QWheelEvent from draggableCircleItem import DraggableCircleItem -from circleEditorWidget import CircleEditorWidget from typing import Optional # A specialized PanZoomGraphicsView for the circle editor (disk size calibration) class CircleEditorGraphicsView(PanZoomGraphicsView): - def __init__(self, circle_editor_widget: CircleEditorWidget, parent: Optional[QWidget] = None): + def __init__(self, circle_editor_widget, parent: Optional[QWidget] = None): """ Constructor. """ diff --git a/modules/export_path.py b/modules/export_path.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/modules/find_path.py b/modules/find_path.py index 4ae9c7fa5afc77a9a29cf214956f55fbfd225fc7..426563ddd4843ab49ab9c08f8424cbd21508d864 100644 --- a/modules/find_path.py +++ b/modules/find_path.py @@ -1,30 +1,17 @@ from skimage.graph import route_through_array -def find_path(cost_image: "numpy.ndarray", points: list) -> list: - """ - Find the optimal path through a cost image between two points. +def find_path(cost_image, points): - Parameters: - cost_image (numpy.ndarray): A 2D array representing the cost of traversing each pixel. - points (list): A list containing two tuples, each representing the - (row, column) coordinates of the seed and target points. - - Returns: - list: A list of (row, column) tuples representing the path from the seed to the target point. - - Raises: - ValueError: If the points list does not contain exactly two points. - """ if len(points) != 2: raise ValueError("Points should be a list of 2 points: seed and target.") seed_rc, target_rc = points path_rc, cost = route_through_array( - cost_image, - start=seed_rc, - end=target_rc, + cost_image, + start=seed_rc, + end=target_rc, fully_connected=True ) - return path_rc + return path_rc \ No newline at end of file diff --git a/modules/imageGraphicsView.py b/modules/imageGraphicsView.py index 1855d717866a601eafe886b0e311da772f9322da..1fe73941973a08882a943efc0cda6d4c299f67ee 100644 --- a/modules/imageGraphicsView.py +++ b/modules/imageGraphicsView.py @@ -1,8 +1,8 @@ -import math from scipy.signal import savgol_filter from PyQt5.QtWidgets import QGraphicsScene, QGraphicsPixmapItem from PyQt5.QtGui import QPixmap, QColor from PyQt5.QtCore import Qt, QRectF, QPoint +import math import numpy as np from panZoomGraphicsView import PanZoomGraphicsView from labeledPointItem import LabeledPointItem @@ -27,10 +27,10 @@ class ImageGraphicsView(PanZoomGraphicsView): self.image_item = QGraphicsPixmapItem() self.scene.addItem(self.image_item) - self.anchor_points = [] - self.point_items = [] - self.full_path_points = [] - self._full_path_xy = [] + self.anchor_points = [] + self.point_items = [] + self.full_path_points = [] + self._full_path_xy = [] self.dot_radius = 4 self.path_radius = 1 @@ -139,7 +139,7 @@ class ImageGraphicsView(PanZoomGraphicsView): self._rebuild_full_path() def _insert_anchor_between_subpath(self, x_new: float, y_new: float ): - """Insert an anchor point between existing anchor points.""" + """Insert an anchor point between existing anchor points.""" # If somehow we have no path yet # If somehow we have no path yet if not self._full_path_xy: self._insert_anchor_point(-1, x_new, y_new) @@ -174,23 +174,23 @@ class ImageGraphicsView(PanZoomGraphicsView): # Walk left left_anchor_pt = None - i_l = best_idx - while i_l >= 0: - px, py = self._full_path_xy[i_l] + iL = best_idx + while iL >= 0: + px, py = self._full_path_xy[iL] if is_anchor((px, py)): left_anchor_pt = (px, py) break - i_l -= 1 + iL -= 1 # Walk right right_anchor_pt = None - i_r = best_idx - while i_r < len(self._full_path_xy): - px, py = self._full_path_xy[i_r] + iR = best_idx + while iR < len(self._full_path_xy): + px, py = self._full_path_xy[iR] if is_anchor((px, py)): right_anchor_pt = (px, py) break - i_r += 1 + iR += 1 # If we can't find distinct anchors on left & right, # just insert before E. @@ -342,7 +342,7 @@ class ImageGraphicsView(PanZoomGraphicsView): # -------------------------------------------------------------------- # MOUSE EVENTS # -------------------------------------------------------------------- - def mouse_press_event(self, event): + def mousePressEvent(self, event): """Handle mouse press events for dragging a point or adding a point.""" if event.button() == Qt.LeftButton: self._mouse_pressed = True @@ -362,9 +362,9 @@ class ImageGraphicsView(PanZoomGraphicsView): elif event.button() == Qt.RightButton: self._remove_point_by_click(event.pos()) - super().mouse_press_event(event) + super().mousePressEvent(event) - def mouse_move_event(self, event): + def mouseMoveEvent(self, event): """Handle mouse move events for dragging a point or dragging the view""" if self._dragging_idx is not None: scene_pos = self.mapToScene(event.pos()) @@ -390,11 +390,11 @@ class ImageGraphicsView(PanZoomGraphicsView): if dist > self._drag_threshold: self._was_dragging = True - super().mouse_move_event(event) + super().mouseMoveEvent(event) - def mouse_release_event(self, event): + def mouseReleaseEvent(self, event): """Handle mouse release events for dragging a point or adding a point.""" - super().mouse_release_event(event) + super().mouseReleaseEvent(event) if event.button() == Qt.LeftButton and self._mouse_pressed: self._mouse_pressed = False self.setCursor(Qt.ArrowCursor) @@ -489,4 +489,4 @@ class ImageGraphicsView(PanZoomGraphicsView): def get_full_path_xy(self): """Returns the entire path as a list of (x, y) coordinates.""" - return self._full_path_xy + return self._full_path_xy \ No newline at end of file diff --git a/modules/mainWindow.py b/modules/mainWindow.py index cf5039e4ee369c822368423feb95beaa4ccd78d0..16127783ac741536a65f16092625131f07233865 100644 --- a/modules/mainWindow.py +++ b/modules/mainWindow.py @@ -4,8 +4,7 @@ from PyQt5.QtWidgets import ( QMainWindow, QPushButton, QHBoxLayout, QVBoxLayout, QWidget, QFileDialog ) -from PyQt5.QtGui import QPixmap, QImage -from PyQt5.QtCore import QCloseEvent +from PyQt5.QtGui import QPixmap, QImage, QCloseEvent from compute_cost_image import compute_cost_image from preprocess_image import preprocess_image from advancedSettingsWidget import AdvancedSettingsWidget diff --git a/modules/panZoomGraphicsView.py b/modules/panZoomGraphicsView.py index dc86430cf0f11138094e72876f8ec4aed95eacc0..5adb46f298fde323ae5c42a1cdec32d24a2694b8 100644 --- a/modules/panZoomGraphicsView.py +++ b/modules/panZoomGraphicsView.py @@ -15,7 +15,7 @@ class PanZoomGraphicsView(QGraphicsView): # Expands layout self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) - def wheel_event(self, event): + def wheelEvent(self, event): """ Zoom in/out with mouse wheel. """ zoom_in_factor = 1.25 zoom_out_factor = 1 / zoom_in_factor @@ -25,25 +25,25 @@ class PanZoomGraphicsView(QGraphicsView): self.scale(zoom_out_factor, zoom_out_factor) event.accept() - def mouse_press_event(self, event): + def mousePressEvent(self, event): """ If left button: Start panning (unless overridden). """ if event.button() == Qt.LeftButton: self._panning = True self._pan_start = event.pos() self.setCursor(Qt.ClosedHandCursor) - super().mouse_press_event(event) + super().mousePressEvent(event) - def mouse_move_event(self, event): + def mouseMoveEvent(self, event): """ If panning, translate the scene. """ if self._panning and self._pan_start is not None: delta = event.pos() - self._pan_start self._pan_start = event.pos() self.translate(delta.x(), delta.y()) - super().mouse_move_event(event) + super().mouseMoveEvent(event) - def mouse_release_event(self, event): + def mouseReleaseEvent(self, event): """ End panning. """ if event.button() == Qt.LeftButton: self._panning = False self.setCursor(Qt.ArrowCursor) - super().mouse_release_event(event) + super().mouseReleaseEvent(event)