Update comment

This commit is contained in:
jaknapper 2026-03-13 12:27:10 +00:00 committed by Joe Knapper
parent 96d67672d9
commit 1bb2a125bc
2 changed files with 12 additions and 11 deletions

View file

@ -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,

View file

@ -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.