From 1bb2a125bc7acc2c810288e9ff6286ffb5233145 Mon Sep 17 00:00:00 2001 From: jaknapper Date: Fri, 13 Mar 2026 12:27:10 +0000 Subject: [PATCH] Update comment --- .../things/scan_workflows.py | 6 +++--- tests/unit_tests/test_scan_workflows.py | 17 +++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/openflexure_microscope_server/things/scan_workflows.py b/src/openflexure_microscope_server/things/scan_workflows.py index 43f494b2..c92900c2 100644 --- a/src/openflexure_microscope_server/things/scan_workflows.py +++ b/src/openflexure_microscope_server/things/scan_workflows.py @@ -261,16 +261,16 @@ class RectGridWorkflow( def _get_stitching_settings_model(self) -> StitchingSettings: """Return a stitching settings model based on current settings.""" + # Use the save resolution and target stitch resolution to choose a unit fraction, + # which makes correlating faster width, height = self.save_resolution - # Target area in pixels target_area = TARGET_STITCHING_DIMENSION**2 - # Find N so that (width/N) * (height/N) ~ target_area # N^2 ~ (width * height) / target_area downsample_factor = max(1, round((width * height / target_area) ** 0.5)) - correlation_resize = 1 / downsample_factor + return StitchingSettings( overlap=self.overlap, correlation_resize=correlation_resize, diff --git a/tests/unit_tests/test_scan_workflows.py b/tests/unit_tests/test_scan_workflows.py index 02c88cc4..0bb7b13c 100644 --- a/tests/unit_tests/test_scan_workflows.py +++ b/tests/unit_tests/test_scan_workflows.py @@ -434,14 +434,15 @@ def test_histo_workflow_settings_ui(histo_workflow, mocker): @pytest.mark.parametrize( - ("save_res,expected_resize",)[ - ((1400, 1400), 1 / 2), # width=1400 -> N=2 - ((1640, 1232), 1 / 2), # width=1640 -> round(1640/750)=2 - ((760, 750), 1 / 1), # width=760 -> N=1 - ((1499, 1000), 1 / 2), # width ~1500 -> N=2 - ((2250, 1800), 1 / 3), # width=2250 -> N=3 - ((700, 700), 1 / 1), # width < 750 -> N=1 - ] + ("save_res", "expected_resize"), + [ + ((1400, 1400), 1 / 2), + ((1640, 1232), 1 / 2), + ((760, 750), 1 / 1), + ((1499, 1000), 1 / 2), + ((2250, 1800), 1 / 3), + ((700, 700), 1 / 1), + ], ) def test_correlation_resize(histo_workflow, save_res, expected_resize): """Test that scan_workflows chooses a suitable correlation_resize factor.